diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbdee6e..1bd60c59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,9 @@ set(PACKAGE "ocpn_draw") SET(VERSION_MAJOR "1") SET(VERSION_MINOR "6") -SET(VERSION_PATCH "94") +SET(VERSION_PATCH "95") set(VERSION_TWEAK "0") -SET(VERSION_DATE "27/05/2020") +SET(VERSION_DATE "29/05/2020") SET(OCPN_MIN_VERSION "ov50") SET(OCPN_API_VERSION_MAJOR "1") SET(OCPN_API_VERSION_MINOR "16") @@ -67,23 +67,6 @@ option(PLUGIN_USE_SVG "Use SVG graphics" ON) set(CMAKE_CXX_STANDARD 11) -if(NOT ${PACKAGE} MATCHES "(.*)_pi") - set(PACKAGE_NAME ${PACKAGE}_pi) - set(PACKAGE_FILE_NAME "${PACKAGE}_pi") -else(NOT ${PACKAGE} MATCHES "(.*)_pi") - set(PACKAGE_NAME ${PACKAGE}) - set(PACKAGE_FILE_NAME "${PACKAGE}") -endif(NOT ${PACKAGE} MATCHES "(.*)_pi") -string(TOUPPER "${PACKAGE}" TITLE_NAME) - -project(${PACKAGE_NAME} VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}) -message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}") - -set(PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}") - -message(STATUS "${VERBOSE_NAME} Version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}") -message(STATUS "OPCN_FLATPAK: ${OCPN_FLATPAK}") - # Use local version of GLU library SET(USE_LOCAL_GLU TRUE) # Prefer libGL.so to libOpenGL.so, see CMP0072 @@ -97,85 +80,13 @@ SET_PROPERTY( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" " MESSAGE (STATUS "Build type: ${CMAKE_BUILD_TYPE}") -# set(PKG_NVR ${PACKAGE_NAME}-${PROJECT_VERSION}-${OCPN_MIN_VERSION}-${OCPN_API_VERSION_MAJOR}.${OCPN_API_VERSION_MINOR}) -set(PKG_NVR ${PACKAGE_NAME}-${PROJECT_VERSION}) -set(PKG_URL "https://dl.cloudsmith.io/public/--pkg_repo--/raw/names/--name--/versions/--version--/--filename--") include("cmake/PluginSetup.cmake") -if(DEFINED ENV{OCPN_TARGET}) - set(PACKAGING_NAME "${PKG_NVR}_${PKG_TARGET}-${ARCH}_${PKG_TARGET_VERSION}-$ENV{OCPN_TARGET}") -else(DEFINED ENV{OCPN_TARGET}) - set(PACKAGING_NAME "${PKG_NVR}_${PKG_TARGET}-${ARCH}_${PKG_TARGET_VERSION}") -endif(DEFINED ENV{OCPN_TARGET}) -message(STATUS "PACKAGING_NAME: ${PACKAGING_NAME}") - -set(PLUGIN_NAME ${PACKAGE}-plugin-${PKG_TARGET}-${PKG_TARGET_VERSION}) - SET(CMAKE_VERBOSE_MAKEFILE ON) option(Plugin_CXX11 "Use c++11" OFF) -if(Plugin_CXX11) - message(STATUS "Attempting to use c++11") - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) - check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X) - if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(Plugin_USE_CXX11 ON) - elseif(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - set(Plugin_USE_CXX11 ON) - else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") - set(Plugin_USE_CXX11 OFF) - endif() -else() - set(Plugin_USE_CXX11 OFF) -endif() - -if(Plugin_USE_CXX11) - message(STATUS "Allowing use of c++11") -endif() - -### -message(STATUS "CMAKE version: ${CMAKE_VERSION}") -if(CMAKE_VERSION VERSION_GREATER 3.4) - set(ENABLE_CLANG_TIDY - OFF - CACHE BOOL "Add clang-tidy automatically to builds") - if(ENABLE_CLANG_TIDY) - find_program( - CLANG_TIDY_EXE - NAMES "clang-tidy" - PATHS /usr/local/opt/llvm/bin) - if(CLANG_TIDY_EXE) - message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") - # For more, see http://clang.llvm.org/extra/clang-tidy/ set(CLANG_TIDY_CHECKS "-*,modernize-*") - set(CLANG_TIDY_CHECKS "-*,performance-*") - set(CMAKE_CXX_CLANG_TIDY - "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'" - CACHE STRING "" FORCE) - else() - message(AUTHOR_WARNING "clang-tidy not found!") - set(CMAKE_CXX_CLANG_TIDY - "" - CACHE STRING "" FORCE) # delete it - endif() - endif() -endif() - -if(CMAKE_VERSION VERSION_GREATER 3.9) - set(ENABLE_CPPCHECK - OFF - CACHE BOOL "Add cppcheck automatically to builds") - if(ENABLE_CPPCHECK) - find_program(CPPCHECK_EXECUTABLE NAMES "cppcheck") - set(CMAKE_CXX_CPPCHECK ${CPPCHECK_EXECUTABLE}) - endif() -endif() - ## ## ----- Modify section above if there are special requirements for the plugin ----- ## ## diff --git a/cmake/PluginConfigure.cmake b/cmake/PluginConfigure.cmake index 84026231..dd64e011 100644 --- a/cmake/PluginConfigure.cmake +++ b/cmake/PluginConfigure.cmake @@ -37,6 +37,28 @@ else() OUTPUT_VARIABLE GIT_REPOSITORY_TAG OUTPUT_STRIP_TRAILING_WHITESPACE ) + execute_process( + COMMAND git remote + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REPOSITORY_REMOTE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX MATCH ".*[\n\r]" FIRST_LINE ${GIT_REPOSITORY_REMOTE}) + if(NOT ${FIRST_LINE} STREQUAL "") + string(REGEX REPLACE "[\n\r]" "" GIT_REPOSITORY_REMOTE ${FIRST_LINE}) + endif() + execute_process( + COMMAND git remote get-url ${GIT_REPOSITORY_REMOTE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REPOSITORY_URL + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(FIND ${GIT_REPOSITORY_URL} ${GIT_REPOSITORY_SERVER} START_URL REVERSE) + string(LENGTH ${GIT_REPOSITORY_SERVER} STRING_LENGTH) + math(EXPR START_URL "${START_URL}+1+${STRING_LENGTH}") + string(LENGTH ${GIT_REPOSITORY_URL} STRING_LENGTH) + message(STATUS "START_URL: ${START_URL}, STRING_LENGTH: ${STRING_LENGTH}") + string(SUBSTRING ${GIT_REPOSITORY_URL} ${START_URL} ${STRING_LENGTH} GIT_REPOSITORY) endif() message(STATUS "GIT_REPOSITORY: ${GIT_REPOSITORY}") message(STATUS "Git Branch: \"${GIT_REPOSITORY_BRANCH}\"") diff --git a/cmake/PluginSetup.cmake b/cmake/PluginSetup.cmake index 7391bb76..814fd925 100644 --- a/cmake/PluginSetup.cmake +++ b/cmake/PluginSetup.cmake @@ -1,5 +1,24 @@ # # Export variables used in plugin setup: GIT_HASH, GIT_COMMIT, PKG_TARGET, PKG_TARGET_VERSION and PKG_NVR +if(NOT ${PACKAGE} MATCHES "(.*)_pi") + set(PACKAGE_NAME ${PACKAGE}_pi) + set(PACKAGE_FILE_NAME "${PACKAGE}_pi") +else(NOT ${PACKAGE} MATCHES "(.*)_pi") + set(PACKAGE_NAME ${PACKAGE}) + set(PACKAGE_FILE_NAME "${PACKAGE}") +endif(NOT ${PACKAGE} MATCHES "(.*)_pi") +string(TOUPPER "${PACKAGE}" TITLE_NAME) + +project(${PACKAGE_NAME} VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}) +message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}") + +set(PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}") + +message(STATUS "${VERBOSE_NAME} Version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}") +message(STATUS "OPCN_FLATPAK: ${OCPN_FLATPAK}") + +set(PKG_NVR ${PACKAGE_NAME}-${PROJECT_VERSION}) +set(PKG_URL "https://dl.cloudsmith.io/public/--pkg_repo--/raw/names/--name--/versions/--version--/--filename--") execute_process( COMMAND git log -1 --format=%h @@ -110,15 +129,6 @@ if(UNIX AND NOT APPLE) ELSE () SET (ARCH "armhf") ENDIF () - else() - if(CMAKE_SIZEOF_VOID_P MATCHES "8") - set(ARCH "x86_64") - set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") - else(CMAKE_SIZEOF_VOID_P MATCHES "8") - set(ARCH "i386") - # note: in a chroot must use "setarch i686 make package" - set(CPACK_RPM_PACKAGE_ARCHITECTURE "i686") - endif(CMAKE_SIZEOF_VOID_P MATCHES "8") endif() endif(UNIX AND NOT APPLE) message(STATUS "ARCH: ${ARCH}") @@ -129,3 +139,73 @@ string(STRIP ${PKG_TARGET_VERSION} PKG_TARGET_VERSION) string(TOLOWER ${PKG_TARGET_VERSION} PKG_TARGET_VERSION) set(PKG_TARGET_NVR ${PKG_TARGET}-${PKG_TARGET_VERSION}) message(STATUS "PluginSetup: PKG_TARGET: ${PKG_TARGET}, PKG_TARGET_VERSION: ${PKG_TARGET_VERSION}") + +if(DEFINED ENV{OCPN_TARGET}) + set(PACKAGING_NAME "${PKG_NVR}_${PKG_TARGET}-${ARCH}_${PKG_TARGET_VERSION}-$ENV{OCPN_TARGET}") +else(DEFINED ENV{OCPN_TARGET}) + set(PACKAGING_NAME "${PKG_NVR}_${PKG_TARGET}-${ARCH}_${PKG_TARGET_VERSION}") +endif(DEFINED ENV{OCPN_TARGET}) +message(STATUS "PACKAGING_NAME: ${PACKAGING_NAME}") + +set(PLUGIN_NAME ${PACKAGE}-plugin-${PKG_TARGET}-${ARCH}_${PKG_TARGET_VERSION}) + +if(Plugin_CXX11) + message(STATUS "Attempting to use c++11") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) + check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(Plugin_USE_CXX11 ON) + elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + set(Plugin_USE_CXX11 ON) + else() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + set(Plugin_USE_CXX11 OFF) + endif() +else() + set(Plugin_USE_CXX11 OFF) +endif() + +if(Plugin_USE_CXX11) + message(STATUS "Allowing use of c++11") +endif() + +message(STATUS "CMAKE version: ${CMAKE_VERSION}") +if(CMAKE_VERSION VERSION_GREATER 3.4) + set(ENABLE_CLANG_TIDY + OFF + CACHE BOOL "Add clang-tidy automatically to builds") + if(ENABLE_CLANG_TIDY) + find_program( + CLANG_TIDY_EXE + NAMES "clang-tidy" + PATHS /usr/local/opt/llvm/bin) + if(CLANG_TIDY_EXE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + # For more, see http://clang.llvm.org/extra/clang-tidy/ set(CLANG_TIDY_CHECKS "-*,modernize-*") + set(CLANG_TIDY_CHECKS "-*,performance-*") + set(CMAKE_CXX_CLANG_TIDY + "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'" + CACHE STRING "" FORCE) + else() + message(AUTHOR_WARNING "clang-tidy not found!") + set(CMAKE_CXX_CLANG_TIDY + "" + CACHE STRING "" FORCE) # delete it + endif() + endif() +endif() + +if(CMAKE_VERSION VERSION_GREATER 3.9) + set(ENABLE_CPPCHECK + OFF + CACHE BOOL "Add cppcheck automatically to builds") + if(ENABLE_CPPCHECK) + find_program(CPPCHECK_EXECUTABLE NAMES "cppcheck") + set(CMAKE_CXX_CPPCHECK ${CPPCHECK_EXECUTABLE}) + endif() +endif() + + diff --git a/cmake/in-files/cloudsmith-upload.sh.in b/cmake/in-files/cloudsmith-upload.sh.in index 08521088..b181f694 100644 --- a/cmake/in-files/cloudsmith-upload.sh.in +++ b/cmake/in-files/cloudsmith-upload.sh.in @@ -102,7 +102,12 @@ echo $tarball echo $tarball_basename source $BUILD_DIR/pkg_version.sh -tarball_name=@PACKAGE_NAME@-@PACKAGE_VERSION@-${PKG_TARGET}-@ARCH@_${PKG_TARGET_VERSION}-${OCPN_TARGET}-tarball +if [ -n "${OCPN_TARGET}" ]; then + tarball_name=@PACKAGE_NAME@-@PACKAGE_VERSION@-${PKG_TARGET}-@ARCH@_${PKG_TARGET_VERSION}-${OCPN_TARGET}-tarball +else + tarball_name=@PACKAGE_NAME@-@PACKAGE_VERSION@-${PKG_TARGET}-@ARCH@_${PKG_TARGET_VERSION}-tarball +fi + if [ "$(ls $BUILD_DIR/*.${PKG_EXT})" ]; then pkg=$(ls $BUILD_DIR/*.${PKG_EXT}) else @@ -151,7 +156,7 @@ fi echo $VERSION echo $REPO -if [ "$APPVEYOR" ]; then +if [ "$APPVEYOR" ] || [ LOCAL_BUILD=true ]; then echo 'substituting xml file variables for windows build' while read line; do line=${line//--pkg_repo--/$REPO} @@ -159,7 +164,7 @@ if [ "$APPVEYOR" ]; then line=${line//--version--/$VERSION} line=${line//--filename--/$tarball_basename} echo $line - done < $xml > xml.tmp && cat xml.tmp && cp xml.tmp $xml && rm xml.tmp + done < "$xml" > xml.tmp && cat xml.tmp && cp xml.tmp $xml && rm xml.tmp else echo 'substituting xml file variables for non-windows build' sudo sed -i -e "s|--pkg_repo--|$REPO|" $xml