diff options
author | Sven Göthel <[email protected]> | 2024-05-07 08:53:50 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-05-07 08:53:50 +0200 |
commit | ae78309e3dc42d0b6f68e7bdcdea1b30007f9ab6 (patch) | |
tree | 6da27e86f49061e585d39396852fe8cdee621eda /JaulibSetup.cmake | |
parent | 173378e3a443aae0afa8264b568415bee2b4995c (diff) |
Build Environment: Better CMake Usage incl. Eclipse (IDE) default CDT CMake
Diffstat (limited to 'JaulibSetup.cmake')
-rw-r--r-- | JaulibSetup.cmake | 300 |
1 files changed, 235 insertions, 65 deletions
diff --git a/JaulibSetup.cmake b/JaulibSetup.cmake index 36c73f2..dfb547e 100644 --- a/JaulibSetup.cmake +++ b/JaulibSetup.cmake @@ -4,51 +4,169 @@ include_guard(GLOBAL) -macro(JaulibSetup) +macro(JaulibPreset) + # Poor man's IDE integration, hard-coded presets for undefined variables + message(STATUS "JaulibPreset: Start") + if( (NOT DEFINED JAU_CMAKE_ENFORCE_PRESETS) AND (DEFINED ENV{JAU_CMAKE_ENFORCE_PRESETS}) ) + set (JAU_CMAKE_ENFORCE_PRESETS $ENV{JAU_CMAKE_ENFORCE_PRESETS}) + message(STATUS "JaulibPreset: JAU_CMAKE_ENFORCE_PRESETS -> ${JAU_CMAKE_ENFORCE_PRESETS} (env)") + endif() + if( JAU_CMAKE_ENFORCE_PRESETS OR + ( (NOT DEFINED CMAKE_INSTALL_PREFIX) AND (NOT DEFINED CMAKE_CXX_CLANG_TIDY) ) ) + message(STATUS "JaulibPreset: Enforcing hardcoded CMake Presets!") + if(JAU_CMAKE_ENFORCE_PRESETS) + message(STATUS "JaulibPreset: ... triggered by CMake variable JAU_CMAKE_ENFORCE_PRESETS ${JAU_CMAKE_ENFORCE_PRESETS}.") + elseif( (NOT DEFINED CMAKE_INSTALL_PREFIX) AND (NOT DEFINED CMAKE_CXX_CLANG_TIDY) ) + message(STATUS "JaulibPreset: ... triggered by undefined CMAKE_INSTALL_PREFIX && CMAKE_CXX_CLANG_TIDY.") + endif() + if (DEFINED ENV{CMAKE_BUILD_PARALLEL_LEVEL}) + message(STATUS "JaulibPreset: Parallel build: CMAKE_BUILD_PARALLEL_LEVEL = $ENV{CMAKE_BUILD_PARALLEL_LEVEL}.") + else() + message(STATUS "JaulibPreset: Parallel build: Consider setting environment variable CMAKE_BUILD_PARALLEL_LEVEL.") + endif() + # + # Defaulting presets: clang, clang-tidy, C++20, CMAKE_BUILD_TYPE, +testing + # + if( (NOT DEFINED CMAKE_INSTALL_PREFIX) ) + set(JAU_CMAKE_OVERRIDE_INSTALL_PREFIX ON) + message(STATUS "JaulibPreset: Setting CMAKE_INSTALL_PREFIX earmarked") + endif() + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 20) + message(STATUS "JaulibPreset: Setting CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD}") + endif() + if(NOT DEFINED CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug") + message(STATUS "JaulibPreset: Setting CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}") + endif() + if( (NOT DEFINED BUILD_TESTING) ) + set(BUILD_TESTING ON) + message(STATUS "JaulibPreset: Setting BUILD_TESTING ${BUILD_TESTING}") + endif() + if( (NOT DEFINED CMAKE_C_COMPILER) ) + set(CMAKE_C_COMPILER "clang") + message(STATUS "JaulibPreset: Setting CMAKE_C_COMPILER ${CMAKE_C_COMPILER}") + endif() + if( (NOT DEFINED CMAKE_CXX_COMPILER) ) + set(CMAKE_CXX_COMPILER "clang++") + message(STATUS "JaulibPreset: Setting CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}") + endif() + if( (NOT DEFINED CMAKE_CXX_CLANG_TIDY) ) + set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-p;${CMAKE_BINARY_DIR}") + message(STATUS "JaulibPreset: Setting CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}") + endif() + + # find_library will not work pre-project stage, hence try later.. + if(NOT DEFINED USE_LIBCURL) + set(TRY_LIBCURL ON) + message(STATUS "JaulibPreset: Setting TRY_LIBCURL ${TRY_LIBCURL}") + endif() -message(STATUS "JaulibSetup: ${PROJECT_NAME}") + # find_library will not work pre-project stage, hence try later.. + if(NOT DEFINED USE_LIBUNWIND) + set(TRY_LIBUNWIND ON) + message(STATUS "JaulibPreset: Setting TRY_LIBUNWIND ${TRY_LIBUNWIND}") + endif() + + # find_package will not work pre-project stage, hence try later.. + if(NOT DEFINED BUILDJAVA) + set(TRY_JAVA ON) + message(STATUS "JaulibPreset: Setting TRY_JAVA ${TRY_JAVA}") + endif() + endif() + message(STATUS "JaulibPreset: End") +endmacro() + +macro(JaulibSetup) +message(STATUS "JaulibSetup: Start: ${PROJECT_NAME}") set(ENV{LANG} en_US.UTF-8) set(ENV{LC_MEASUREMENT} en_US.UTF-8) # Determine OS_AND_ARCH as library appendix, e.g. 'direct_bt-linux-amd64' string(TOLOWER ${CMAKE_SYSTEM_NAME} OS_NAME) -if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm") +string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} OS_ARCH0) +if(${OS_ARCH0} STREQUAL "arm") set(OS_ARCH "armhf") -elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") +elseif(${OS_ARCH0} STREQUAL "armv7l") set(OS_ARCH "armhf") -elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") +elseif(${OS_ARCH0} STREQUAL "aarch64") set(OS_ARCH "arm64") -elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") +elseif(${OS_ARCH0} STREQUAL "x86_64") set(OS_ARCH "amd64") +elseif( ( ${OS_ARCH0} STREQUAL "x86" ) OR ( ${OS_ARCH0} STREQUAL "i386" ) ( ${OS_ARCH0} STREQUAL "i686" ) ) + set(OS_ARCH "i586") else() - set(OS_ARCH ${CMAKE_SYSTEM_PROCESSOR}) + set(OS_ARCH ${OS_ARCH0}) endif() set(OS_AND_ARCH ${OS_NAME}-${OS_ARCH}) set(os_and_arch_slash ${OS_NAME}/${OS_ARCH}) set(os_and_arch_dot ${OS_NAME}.${OS_ARCH}) -message (STATUS "OS_NAME ${OS_NAME}") -message (STATUS "OS_ARCH ${OS_ARCH} (${CMAKE_SYSTEM_PROCESSOR})") -message (STATUS "OS_AND_ARCH ${OS_AND_ARCH}") +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + set(TOOLSET "clang") +elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + set(TOOLSET "gcc") +else() + string(TOLOWER ${CMAKE_CXX_COMPILER_ID} TOOLSET) +endif() +if(JAU_CMAKE_OVERRIDE_INSTALL_PREFIX) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist/default-debug") + else() + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist/default-release") + endif() + message(STATUS "JaulibSetup: Setting CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}") +endif() +set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}-${OS_AND_ARCH}-${TOOLSET}") -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +message (STATUS "JaulibSetup: OS_NAME ${OS_NAME}") +message (STATUS "JaulibSetup: OS_ARCH ${OS_ARCH} (${CMAKE_SYSTEM_PROCESSOR})") +message (STATUS "JaulibSetup: OS_AND_ARCH ${OS_AND_ARCH}") +message (STATUS "JaulibSetup: TOOLSET ${TOOLSET}") +message (STATUS "JaulibSetup: CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}") + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DEBUG ON) +endif() +if(NOT DEFINED CC_INSTRUMENTATION) + set(CC_INSTRUMENTATION OFF) +endif() +if(NOT DEFINED CC_INSTRUMENTATION_UNDEFINED) + set(CC_INSTRUMENTATION_UNDEFINED OFF) +endif() +if(NOT DEFINED CC_INSTRUMENTATION_THREAD) + set(CC_INSTRUMENTATION_THREAD OFF) +endif() +if(CC_INSTRUMENTATION OR CC_INSTRUMENTATION_UNDEFINED OR CC_INSTRUMENTATION_THREAD) + set(DEBUG ON) +endif() +message(STATUS "JaulibSetup: Compiler = ${CMAKE_CXX_COMPILER_ID}") +message(STATUS "JaulibSetup: Build Type = ${CMAKE_BUILD_TYPE}") +message(STATUS "JaulibSetup: DEBUG = ${DEBUG}") +message(STATUS "JaulibSetup: CC_INSTRUMENTATION = All ${CC_INSTRUMENTATION}, Undef ${CC_INSTRUMENTATION_UNDEFINED}, Thread ${CC_INSTRUMENTATION_THREAD}") if(DEFINED CMAKE_CXX_CLANG_TIDY) - message(STATUS "clang-tidy preset: ${CMAKE_CXX_CLANG_TIDY}") + message(STATUS "JaulibSetup: clang-tidy preset: ${CMAKE_CXX_CLANG_TIDY}") else() - message(STATUS "clang-tidy not used") + message(STATUS "JaulibSetup: clang-tidy not used") endif() if(DEFINED CMAKE_CXX_STANDARD) set (CMAKE_CXX_STANDARD_REQUIRED ON) - message(STATUS "CMAKE_CXX_STANDARD (preset): ${CMAKE_CXX_STANDARD}, CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}") + message(STATUS "JaulibSetup: CMAKE_CXX_STANDARD (preset): ${CMAKE_CXX_STANDARD}, CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}") else() - set (CMAKE_CXX_STANDARD 17) + set (CMAKE_CXX_STANDARD 20) set (CMAKE_CXX_STANDARD_REQUIRED ON) - message(STATUS "CMAKE_CXX_STANDARD (default): ${CMAKE_CXX_STANDARD}, CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}") + message(STATUS "JaulibSetup: CMAKE_CXX_STANDARD (default): ${CMAKE_CXX_STANDARD}, CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}") endif() +# +# Post initial setup / var-check +# + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # for all set (CC_FLAGS_WARNING "-Wall -Wextra -Werror") set (GCC_FLAGS_WARNING_FORMAT "-Wformat=2 -Wformat-overflow=2 -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat-y2k") @@ -61,7 +179,7 @@ set (GCC_FLAGS_WARNING_NO_ERROR "-Wno-error=array-bounds -Wno-error=null-derefer # debug only set (GCC_FLAGS_STACK "-fstack-protector-strong") -set (GCC_FLAGS_SANITIZE_ALLLEAK "-fsanitize-address-use-after-scope -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize=leak -fsanitize-recover=address") +set (GCC_FLAGS_SANITIZE_ALL "-fsanitize-address-use-after-scope -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize=leak -fsanitize-recover=address") set (GCC_FLAGS_SANITIZE_UNDEFINED "-fsanitize=undefined -fsanitize-recover=address") set (GCC_FLAGS_SANITIZE_THREAD "-fsanitize-address-use-after-scope -fsanitize=undefined -fsanitize=thread -fsanitize-recover=address") # -fsanitize=address cannot be combined with -fsanitize=thread @@ -75,7 +193,7 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CC_FLAGS_WARNING}") endif() -message(STATUS "${PROJECT_NAME} USE_STRIP = ${USE_STRIP} (pre-set)") +message(STATUS "JaulibSetup: USE_STRIP = ${USE_STRIP} (pre-set)") if(DEBUG) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -85,19 +203,19 @@ if(DEBUG) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DDEBUG") endif() - if(INSTRUMENTATION) + if(CC_INSTRUMENTATION) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_FLAGS_SANITIZE_ALLLEAK}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_FLAGS_SANITIZE_ALL}") endif() - elseif(INSTRUMENTATION_UNDEFINED) + elseif(CC_INSTRUMENTATION_UNDEFINED) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_FLAGS_SANITIZE_UNDEFINED}") endif() - elseif(INSTRUMENTATION_THREAD) + elseif(CC_INSTRUMENTATION_THREAD) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_FLAGS_SANITIZE_THREAD}") endif() - endif(INSTRUMENTATION) + endif(CC_INSTRUMENTATION) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG") if(GPROF) @@ -108,24 +226,24 @@ else() find_program(STRIP strip) if (STRIP STREQUAL "STRIP-NOTFOUND") set(USE_STRIP OFF) - message(STATUS "${PROJECT_NAME} USE_STRIP:=false, strip not found") + message(STATUS "JaulibSetup: USE_STRIP:=false, strip not found") elseif(NOT DEFINED USE_STRIP) set(USE_STRIP ON) - message(STATUS "${PROJECT_NAME} USE_STRIP:=true, !DEBUG and not set") + message(STATUS "JaulibSetup: USE_STRIP:=true, !DEBUG and not set") endif() endif() endif(DEBUG) -message(STATUS "${PROJECT_NAME} USE_STRIP = ${USE_STRIP} (final)") +message(STATUS "JaulibSetup: USE_STRIP = ${USE_STRIP} (final)") if(DONT_USE_RTTI) - message(STATUS "${PROJECT_NAME} RTTI disabled") + message(STATUS "JaulibSetup: RTTI disabled") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-rtti") #set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -fno-rtti") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-rtti") else() - message(STATUS "${PROJECT_NAME} RTTI enabled") + message(STATUS "JaulibSetup: RTTI enabled") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -frtti") #set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -frtti") @@ -154,11 +272,11 @@ endif() set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries") -message(STATUS "${PROJECT_NAME} CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") -message(STATUS "${PROJECT_NAME} CMAKE_SHARED_LINKER_FLAGS = ${CMAKE_SHARED_LINKER_FLAGS}") -message(STATUS "${PROJECT_NAME} CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}") -message(STATUS "${PROJECT_NAME} CMAKE_CXX_STANDARD_LIBRARIES = ${CMAKE_CXX_STANDARD_LIBRARIES}") -message(STATUS "${PROJECT_NAME} LIB_INSTALL_DIR = ${LIB_INSTALL_DIR}") +message(STATUS "JaulibSetup: CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") +message(STATUS "JaulibSetup: CMAKE_SHARED_LINKER_FLAGS = ${CMAKE_SHARED_LINKER_FLAGS}") +message(STATUS "JaulibSetup: CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}") +message(STATUS "JaulibSetup: CMAKE_CXX_STANDARD_LIBRARIES = ${CMAKE_CXX_STANDARD_LIBRARIES}") +message(STATUS "JaulibSetup: LIB_INSTALL_DIR = ${LIB_INSTALL_DIR}") # Set CMAKE_INSTALL_XXXDIR (XXX {BIN LIB ..} if not defined # (was: CMAKE_LIB_INSTALL_DIR) @@ -167,12 +285,30 @@ include(GNUInstallDirs) # Appends the cmake/modules path to MAKE_MODULE_PATH variable. set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) -message(STATUS "${PROJECT_NAME} USE_LIBCURL = ${USE_LIBCURL} (pre-set)") +if(TRY_ALL) + set(TRY_JAVA ON) + set(TRY_LIBUNWIND ON) + set(TRY_LIBCURL ON) + message(STATUS "JaulibSetup: TRY_ALL -> TRY_JAVA, TRY_LIBUNWIND, TRY_LIBCURL") +endif(TRY_ALL) + +message(STATUS "JaulibSetup: USE_LIBCURL = ${USE_LIBCURL} (pre-set)") +if ((NOT DEFINED USE_LIBCURL) AND TRY_LIBCURL) + find_library(LIBCURL_LIBNAME "curl") + if(NOT LIBCURL_LIBNAME) + set(LIBCURL_LIBNAME "") + set(USE_LIBCURL OFF) + message(STATUS "JaulibSetup: TRY_LIBCURL: CURL disabled, not found") + else() + set(USE_LIBCURL ON) + message(STATUS "JaulibSetup: TRY_LIBCURL: CURL found, USE_LIBCURL ${USE_LIBCURL}") + endif() +endif() if(NOT DEFINED USE_LIBCURL) set(USE_LIBCURL OFF) - message(STATUS "${PROJECT_NAME} USE_LIBCURL ${USE_LIBCURL} (default)") + message(STATUS "JaulibSetup: USE_LIBCURL ${USE_LIBCURL} (default)") else() - message(STATUS "${PROJECT_NAME} USE_LIBCURL ${USE_LIBCURL} (user)") + message(STATUS "JaulibSetup: USE_LIBCURL ${USE_LIBCURL} (user)") endif() if(USE_LIBCURL) find_library(LIBCURL_LIBNAME "curl" REQUIRED) @@ -180,14 +316,25 @@ if(USE_LIBCURL) else() set(LIBCURL_LIBNAME "") endif() -message(STATUS "${PROJECT_NAME} USE_LIBCURL ${USE_LIBCURL} -> libname ${LIBCURL_LIBNAME}") - -message(STATUS "${PROJECT_NAME} USE_LIBUNWIND = ${USE_LIBUNWIND} (pre-set)") +message(STATUS "JaulibSetup: USE_LIBCURL ${USE_LIBCURL} -> libname ${LIBCURL_LIBNAME}") + +message(STATUS "JaulibSetup: USE_LIBUNWIND = ${USE_LIBUNWIND} (pre-set)") +if ((NOT DEFINED USE_LIBUNWIND) AND TRY_LIBUNWIND) + find_library(LIBUNWIND_LIBNAME "unwind") + if(NOT LIBUNWIND_LIBNAME) + set(LIBUNWIND_LIBNAME "") + set(USE_LIBUNWIND OFF) + message(STATUS "JaulibSetup: TRY_LIBUNWIND: UNWIND disabled, not found") + else() + set(USE_LIBUNWIND ON) + message(STATUS "JaulibSetup: TRY_LIBUNWIND: UNWIND found, USE_LIBUNWIND ${USE_LIBUNWIND}") + endif() +endif() if(NOT DEFINED USE_LIBUNWIND) set(USE_LIBUNWIND OFF) - message(STATUS "${PROJECT_NAME} USE_LIBUNWIND ${USE_LIBUNWIND} (default)") + message(STATUS "JaulibSetup: USE_LIBUNWIND ${USE_LIBUNWIND} (default)") else() - message(STATUS "${PROJECT_NAME} USE_LIBUNWIND ${USE_LIBUNWIND} (user)") + message(STATUS "JaulibSetup: USE_LIBUNWIND ${USE_LIBUNWIND} (user)") endif() if(USE_LIBUNWIND) find_library(LIBUNWIND_LIBNAME "unwind" REQUIRED) @@ -195,7 +342,7 @@ if(USE_LIBUNWIND) else() set(LIBUNWIND_LIBNAME "") endif() -message(STATUS "${PROJECT_NAME} USE_LIBUNWIND ${USE_LIBUNWIND} -> libname ${LIBUNWIND_LIBNAME}") +message(STATUS "JaulibSetup: USE_LIBUNWIND ${USE_LIBUNWIND} -> libname ${LIBUNWIND_LIBNAME}") # Make a version file containing the current version from git. include (GetGitRevisionDescription) @@ -203,17 +350,17 @@ include (GetGitRevisionDescription) git_describe (VERSION "--tags") get_git_head_revision(GIT_REFSPEC VERSION_SHA1 ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) git_local_changes(GIT_WORKDIR_DIRTY) -message(STATUS "${PROJECT_NAME} git_describe ${VERSION}") -message(STATUS "${PROJECT_NAME} get_git_head_revision ${GIT_REFSPEC}") -message(STATUS "${PROJECT_NAME} get_git_head_revision ${VERSION_SHA1}") -message(STATUS "${PROJECT_NAME} git_local_changes ${GIT_WORKDIR_DIRTY}") +message(STATUS "JaulibSetup: ${PROJECT_NAME} git_describe ${VERSION}") +message(STATUS "JaulibSetup: ${PROJECT_NAME} get_git_head_revision ${GIT_REFSPEC}") +message(STATUS "JaulibSetup: ${PROJECT_NAME} get_git_head_revision ${VERSION_SHA1}") +message(STATUS "JaulibSetup: ${PROJECT_NAME} git_local_changes ${GIT_WORKDIR_DIRTY}") if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND") - message (WARNING " - Install git to compile for production!") + message (WARNING "JaulibSetup: - Install git to compile for production!") set (VERSION "v1.0.0-dirty") endif () -message (STATUS "${PROJECT_NAME} version ${VERSION}") +message (STATUS "JaulibSetup: ${PROJECT_NAME} version ${VERSION}") #parse the version information into pieces. string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}") @@ -242,50 +389,72 @@ set (VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") set (VERSION_API "${VERSION_MAJOR}.${VERSION_MINOR}") if ("${GIT_WORKDIR_DIRTY}" STREQUAL "CLEAN") - message (STATUS "${PROJECT_NAME} git repo is CLEAN") + message (STATUS "JaulibSetup: ${PROJECT_NAME} git repo is CLEAN") else() - message (STATUS "${PROJECT_NAME} git repo is DIRTY") + message (STATUS "JaulibSetup: ${PROJECT_NAME} git repo is DIRTY") endif() -message (STATUS "${PROJECT_NAME} version major ${VERSION_MAJOR}, minor ${VERSION_MINOR}, patch ${VERSION_PATCH}, post version commits ${VERSION_COMMITS}, ssha1 ${VERSION_SHA1_SHORT}, sha1 ${VERSION_SHA1}") -message (STATUS "${PROJECT_NAME} VERSION_LONG ${VERSION_LONG}") -message (STATUS "${PROJECT_NAME} VERSION_SHORT ${VERSION_SHORT}") -message (STATUS "${PROJECT_NAME} VERSION_API ${VERSION_API}") +message (STATUS "JaulibSetup: ${PROJECT_NAME} version major ${VERSION_MAJOR}, minor ${VERSION_MINOR}, patch ${VERSION_PATCH}, post version commits ${VERSION_COMMITS}, ssha1 ${VERSION_SHA1_SHORT}, sha1 ${VERSION_SHA1}") +message (STATUS "JaulibSetup: ${PROJECT_NAME} VERSION_LONG ${VERSION_LONG}") +message (STATUS "JaulibSetup: ${PROJECT_NAME} VERSION_SHORT ${VERSION_SHORT}") +message (STATUS "JaulibSetup: ${PROJECT_NAME} VERSION_API ${VERSION_API}") string(TIMESTAMP BUILD_TSTAMP "%Y-%m-%d %H:%M:%S") +if ((NOT DEFINED BUILDJAVA) AND TRY_JAVA) + find_package(Java 11) + find_package(JNI) + include(UseJava) + if(Java_FOUND) + message (STATUS "JaulibSetup: TRY_JAVA Java: ${Java_VERSION} or '${Java_VERSION_STRING}'") + else (Java_FOUND) + message (STATUS "JaulibSetup: TRY_JAVA Java not found") + endif (Java_FOUND) + if (JNI_FOUND) + message (STATUS "JaulibSetup: TRY_JAVA JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}") + message (STATUS "JaulibSetup: TRY_JAVA JNI_LIBRARIES=${JNI_LIBRARIES}") + else (JNI_FOUND) + message (STATUS "JaulibSetup: TRY_JAVA JNI not found") + endif (JNI_FOUND) + if(Java_FOUND AND JNI_FOUND) + set(BUILDJAVA ON) + else() + set(BUILDJAVA OFF) + endif() + message (STATUS "JaulibSetup: TRY_JAVA BUILDJAVA ${BUILDJAVA}") +endif() IF(BUILDJAVA) - message (STATUS "JAVA_HOME (var,pre ) = ${JAVA_HOME}") - message (STATUS "JAVA_HOME (env,pre ) = $ENV{JAVA_HOME}") + message (STATUS "JaulibSetup: JAVA_HOME (var,pre ) = ${JAVA_HOME}") + message (STATUS "JaulibSetup: JAVA_HOME (env,pre ) = $ENV{JAVA_HOME}") if (NOT DEFINED JAVA_HOME) if (DEFINED ENV{JAVA_HOME}) set (JAVA_HOME $ENV{JAVA_HOME}) endif() endif () - message (STATUS "JAVA_HOME (var,post) = ${JAVA_HOME}") + message (STATUS "JaulibSetup: JAVA_HOME (var,post) = ${JAVA_HOME}") find_package(Java 11 REQUIRED) find_package(JNI REQUIRED) include(UseJava) if(Java_FOUND) - message (STATUS "Java: ${Java_VERSION} or '${Java_VERSION_STRING}'") + message (STATUS "JaulibSetup: Java: ${Java_VERSION} or '${Java_VERSION_STRING}'") else (Java_FOUND) - message (STATUS "Error: Java not found") + message (STATUS "JaulibSetup: Error: Java not found") endif (Java_FOUND) if (JNI_FOUND) - message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}") - message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}") + message (STATUS "JaulibSetup: JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}") + message (STATUS "JaulibSetup: JNI_LIBRARIES=${JNI_LIBRARIES}") else (JNI_FOUND) - message (STATUS "Error: JNI not found") + message (STATUS "JaulibSetup: Error: JNI not found") endif (JNI_FOUND) set (JAVAC ${Java_JAVAC_EXECUTABLE}) set (JAR ${Java_JAR_EXECUTABLE}) - message (STATUS "JAVAC = ${JAVAC}") - message (STATUS "JAR = ${JAR}") + message (STATUS "JaulibSetup: JAVAC = ${JAVAC}") + message (STATUS "JaulibSetup: JAR = ${JAR}") set(CMAKE_JAVA_COMPILE_FLAGS ${CMAKE_JAVA_COMPILE_FLAGS} -source 11 -target 11 -encoding UTF-8) if(DEBUG) @@ -304,8 +473,9 @@ IF(BUILDJAVA) # set(CMAKE_JAVA_COMPILE_FLAGS ${CMAKE_JAVA_COMPILE_FLAGS} -g:none) endif() endif(DEBUG) - message(STATUS "${PROJECT_NAME} JAVAC_FLAGS = ${CMAKE_JAVA_COMPILE_FLAGS}") + message(STATUS "JaulibSetup: JAVAC_FLAGS = ${CMAKE_JAVA_COMPILE_FLAGS}") ENDIF(BUILDJAVA) +message(STATUS "JaulibSetup: End: ${PROJECT_NAME}") endmacro() |