diff options
Diffstat (limited to 'Modules')
146 files changed, 2206 insertions, 826 deletions
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index bc78016..3e8c511 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -26,6 +26,6 @@ endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + string(APPEND PACKAGE_VERSION " (${installedBits}bit)") set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index de4a23a..5741007 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -42,6 +42,6 @@ endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + string(APPEND PACKAGE_VERSION " (${installedBits}bit)") set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index a32245d..0fad8a3 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -41,6 +41,6 @@ endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + string(APPEND PACKAGE_VERSION " (${installedBits}bit)") set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 0e547c4..1bb16ac 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -76,10 +76,11 @@ endif() # Support for CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT and friends: set(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT "$ENV{ASM${ASM_DIALECT}FLAGS} ${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT STREQUAL " ") - set(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT) -endif() + +foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT}" CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT) +endforeach() + set (CMAKE_ASM${ASM_DIALECT}_FLAGS "${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}" CACHE STRING "Flags used by the assembler during all build types.") diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index f1db46e..f4044e5 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -50,7 +50,7 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) endif() endif() set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_ANSI_CXXFLAGS}") include(TestForANSIStreamHeaders) include(CheckIncludeFileCXX) include(TestForSTDNamespace) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index fa87ca8..98eedc4 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -111,10 +111,11 @@ if(NOT CMAKE_MODULE_EXISTS) endif() set(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_C_FLAGS_INIT STREQUAL " ") - set(CMAKE_C_FLAGS_INIT) -endif() + +foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_C_FLAGS${c}_INIT}" CMAKE_C_FLAGS${c}_INIT) +endforeach() + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING "Flags used by the compiler during all build types.") diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index b35280f..07e4f39 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -206,10 +206,11 @@ endforeach() # use _INIT variables so that this only happens the first time # and you can set these flags in the cmake cache set(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_CXX_FLAGS_INIT STREQUAL " ") - set(CMAKE_CXX_FLAGS_INIT) -endif() + +foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_CXX_FLAGS${c}_INIT}" CMAKE_CXX_FLAGS${c}_INIT) +endforeach() + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING "Flags used by the compiler during all build types.") diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index fa025a8..8bf7288 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -16,11 +16,15 @@ # cache values that can be initialized in the platform-compiler.cmake file # it may be included by more than one language. -if(NOT "x$ENV{LDFLAGS}" STREQUAL "x") - set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") - set (CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") - set (CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") -endif() +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") +string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") +string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") + +foreach(t EXE SHARED MODULE STATIC) + foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_${t}_LINKER_FLAGS${c}_INIT}" CMAKE_${t}_LINKER_FLAGS${c}_INIT) + endforeach() +endforeach() if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) # default build type is none diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 1d341e5..17e5302 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -120,18 +120,18 @@ function(compiler_id_detection outvar lang) if (CID_ID_STRING) set(PREFIX ${CID_PREFIX}) string(CONFIGURE "${_compiler_id_simulate_${Id}}" SIMULATE_BLOCK @ONLY) - set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_ID \"${Id}\"${SIMULATE_BLOCK}") + string(APPEND id_content "# define ${CID_PREFIX}COMPILER_ID \"${Id}\"${SIMULATE_BLOCK}") endif() if (CID_ID_DEFINE) - set(id_content "${id_content}# undef ${CID_PREFIX}COMPILER_IS_${Id}\n") - set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_IS_${Id} 1\n") + string(APPEND id_content "# undef ${CID_PREFIX}COMPILER_IS_${Id}\n") + string(APPEND id_content "# define ${CID_PREFIX}COMPILER_IS_${Id} 1\n") endif() if (CID_VERSION_STRINGS) set(PREFIX ${CID_PREFIX}) set(MACRO_DEC DEC) set(MACRO_HEX HEX) string(CONFIGURE "${_compiler_id_version_compute_${Id}}" VERSION_BLOCK @ONLY) - set(id_content "${id_content}${VERSION_BLOCK}\n") + string(APPEND id_content "${VERSION_BLOCK}\n") endif() set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}\n${id_content}") set(pp_if "#elif") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index f8c6303..73d9fb3 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -34,6 +34,7 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) # Load system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-C OPTIONAL) include(Platform/${CMAKE_SYSTEM_NAME}-C OPTIONAL) if(NOT CMAKE_C_COMPILER_NAMES) set(CMAKE_C_COMPILER_NAMES cc) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 3c9bbc2..063b68e 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -33,6 +33,7 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) # Load system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-CXX OPTIONAL) include(Platform/${CMAKE_SYSTEM_NAME}-CXX OPTIONAL) if(NOT CMAKE_CXX_COMPILER_NAMES) set(CMAKE_CXX_COMPILER_NAMES CC) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 465989d..64d9bed 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -365,14 +365,15 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT} # Find the executable produced by the compiler, try all files in the # binary dir. + string(REGEX REPLACE "([][])" "[\\1]" _glob_id_dir "${CMAKE_${lang}_COMPILER_ID_DIR}") file(GLOB files RELATIVE ${CMAKE_${lang}_COMPILER_ID_DIR} # normal case - ${CMAKE_${lang}_COMPILER_ID_DIR}/* + ${_glob_id_dir}/* # com.apple.package-type.bundle.unit-test - ${CMAKE_${lang}_COMPILER_ID_DIR}/*.xctest/* + ${_glob_id_dir}/*.xctest/* ) list(REMOVE_ITEM files "${src}") set(COMPILER_${lang}_PRODUCED_FILES "") @@ -492,11 +493,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) if(NOT DEFINED COMPILER_VERSION AND HAVE_COMPILER_VERSION_MAJOR) set(COMPILER_VERSION "${COMPILER_VERSION_MAJOR}") if(HAVE_COMPILER_VERSION_MINOR) - set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_MINOR}") + string(APPEND COMPILER_VERSION ".${COMPILER_VERSION_MINOR}") if(HAVE_COMPILER_VERSION_PATCH) - set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_PATCH}") + string(APPEND COMPILER_VERSION ".${COMPILER_VERSION_PATCH}") if(HAVE_COMPILER_VERSION_TWEAK) - set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_TWEAK}") + string(APPEND COMPILER_VERSION ".${COMPILER_VERSION_TWEAK}") endif() endif() endif() diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 4f2a70c..596fc5f 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -20,6 +20,7 @@ # as a default compiler include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Fortran OPTIONAL) include(Platform/${CMAKE_SYSTEM_NAME}-Fortran OPTIONAL) if(NOT CMAKE_Fortran_COMPILER_NAMES) set(CMAKE_Fortran_COMPILER_NAMES f95) @@ -140,10 +141,10 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) set(_version_info "") foreach(m MAJOR MINOR PATCH TWEAK) set(_COMP "_${m}") - set(_version_info "${_version_info} + string(APPEND _version_info " #if defined(COMPILER_VERSION${_COMP})") foreach(d 1 2 3 4 5 6 7 8) - set(_version_info "${_version_info} + string(APPEND _version_info " # undef DEC # undef HEX # define DEC(n) DEC_${d}(n) @@ -171,7 +172,7 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) # endif ") endforeach() - set(_version_info "${_version_info} + string(APPEND _version_info " #endif") endforeach() set(CMAKE_Fortran_COMPILER_ID_VERSION_INFO "${_version_info}") diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 1fd0972..45dbfcc 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -173,10 +173,11 @@ endif() set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_Fortran_FLAGS_INIT STREQUAL " ") - set(CMAKE_Fortran_FLAGS_INIT) -endif() + +foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_Fortran_FLAGS${c}_INIT}" CMAKE_Fortran_FLAGS${c}_INIT) +endforeach() + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING "Flags for Fortran compiler.") diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index 1256f56..234322c 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -237,20 +237,30 @@ function(ios_install_combined target destination) endif() set(cmd xcrun -f lipo) + + # Do not merge OUTPUT_VARIABLE and ERROR_VARIABLE since latter may contain + # some diagnostic information even for the successful run. execute_process( COMMAND ${cmd} RESULT_VARIABLE result OUTPUT_VARIABLE output - ERROR_VARIABLE output + ERROR_VARIABLE error_output OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) if(NOT result EQUAL 0) message( - FATAL_ERROR "Command failed (${result}): ${cmd}\n\nOutput:\n${output}" + FATAL_ERROR "Command failed (${result}): ${cmd}\n\nOutput:\n${output}\nOutput(error):\n${error_output}" ) endif() set(_lipo_path ${output}) + list(LENGTH _lipo_path len) + if(NOT len EQUAL 1) + message(FATAL_ERROR "Unexpected xcrun output: ${_lipo_path}") + endif() + if(NOT EXISTS "${_lipo_path}") + message(FATAL_ERROR "File not found: ${_lipo_path}") + endif() set(CURRENT_CONFIG "${CMAKE_INSTALL_CONFIG_NAME}") set(CURRENT_TARGET "${target}") diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 5e5302f..828ea9e 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -280,7 +280,7 @@ get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") # Handle "/usr move" symlinks created by some Linux distros. - set(PACKAGE_INIT "${PACKAGE_INIT} + string(APPEND PACKAGE_INIT " # Use original install prefix when loaded through a \"/usr move\" # cross-prefix symbolic link such as /lib -> /usr/lib. get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH) @@ -294,7 +294,7 @@ unset(_realCurr) endif() if(NOT CCF_NO_SET_AND_CHECK_MACRO) - set(PACKAGE_INIT "${PACKAGE_INIT} + string(APPEND PACKAGE_INIT " macro(set_and_check _var _file) set(\${_var} \"\${_file}\") if(NOT EXISTS \"\${_file}\") @@ -306,7 +306,7 @@ endmacro() if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO) - set(PACKAGE_INIT "${PACKAGE_INIT} + string(APPEND PACKAGE_INIT " macro(check_required_components _NAME) foreach(comp \${\${_NAME}_FIND_COMPONENTS}) if(NOT \${_NAME}_\${comp}_FOUND) @@ -319,7 +319,7 @@ endmacro() ") endif() - set(PACKAGE_INIT "${PACKAGE_INIT} + string(APPEND PACKAGE_INIT " ####################################################################################") configure_file("${_inputFile}" "${_outputFile}" @ONLY) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index ef9a2eb..f6d07e5 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -32,7 +32,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj # whole line and just the command (argv[0]). set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)") set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ") - set(log "${log} link line regex: [${linker_regex}]\n") + string(APPEND log " link line regex: [${linker_regex}]\n") string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") foreach(line IN LISTS output_lines) set(cmd) @@ -44,7 +44,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" _dir_regex "${CMAKE_BINARY_DIR}") string(REGEX REPLACE " -[FL]${_dir_regex}/([^ ]| [^-])+( |$)" " " xline "${line}") if(NOT "x${xline}" STREQUAL "x${line}") - set(log "${log} reduced line: [${line}]\n to: [${xline}]\n") + string(APPEND log " reduced line: [${line}]\n to: [${xline}]\n") set(line "${xline}") endif() endif() @@ -56,67 +56,67 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj list(GET args 0 cmd) endif() if("${cmd}" MATCHES "${linker_regex}") - set(log "${log} link line: [${line}]\n") + string(APPEND log " link line: [${line}]\n") string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}") foreach(arg IN LISTS args) if("${arg}" MATCHES "^-L(.:)?[/\\]") # Unix search path. string(REGEX REPLACE "^-L" "" dir "${arg}") list(APPEND implicit_dirs_tmp ${dir}) - set(log "${log} arg [${arg}] ==> dir [${dir}]\n") + string(APPEND log " arg [${arg}] ==> dir [${dir}]\n") elseif("${arg}" MATCHES "^-l([^:].*)$") # Unix library. set(lib "${CMAKE_MATCH_1}") list(APPEND implicit_libs_tmp ${lib}) - set(log "${log} arg [${arg}] ==> lib [${lib}]\n") + string(APPEND log " arg [${arg}] ==> lib [${lib}]\n") elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$") # Unix library full path. list(APPEND implicit_libs_tmp ${arg}) - set(log "${log} arg [${arg}] ==> lib [${arg}]\n") + string(APPEND log " arg [${arg}] ==> lib [${arg}]\n") elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$" AND obj_regex AND "${arg}" MATCHES "${obj_regex}") # Object file full path. list(APPEND implicit_libs_tmp ${arg}) - set(log "${log} arg [${arg}] ==> obj [${arg}]\n") + string(APPEND log " arg [${arg}] ==> obj [${arg}]\n") elseif("${arg}" MATCHES "^-Y(P,)?[^0-9]") # Sun search path ([^0-9] avoids conflict with Mac -Y<num>). string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}") string(REPLACE ":" ";" dirs "${dirs}") list(APPEND implicit_dirs_tmp ${dirs}) - set(log "${log} arg [${arg}] ==> dirs [${dirs}]\n") + string(APPEND log " arg [${arg}] ==> dirs [${dirs}]\n") elseif("${arg}" MATCHES "^-l:") # HP named library. list(APPEND implicit_libs_tmp ${arg}) - set(log "${log} arg [${arg}] ==> lib [${arg}]\n") + string(APPEND log " arg [${arg}] ==> lib [${arg}]\n") elseif("${arg}" MATCHES "^-z(all|default|weak)extract") # Link editor option. list(APPEND implicit_libs_tmp ${arg}) - set(log "${log} arg [${arg}] ==> opt [${arg}]\n") + string(APPEND log " arg [${arg}] ==> opt [${arg}]\n") else() - set(log "${log} arg [${arg}] ==> ignore\n") + string(APPEND log " arg [${arg}] ==> ignore\n") endif() endforeach() break() elseif("${line}" MATCHES "LPATH(=| is:? *)(.*)$") - set(log "${log} LPATH line: [${line}]\n") + string(APPEND log " LPATH line: [${line}]\n") # HP search path. string(REPLACE ":" ";" paths "${CMAKE_MATCH_2}") list(APPEND implicit_dirs_tmp ${paths}) - set(log "${log} dirs [${paths}]\n") + string(APPEND log " dirs [${paths}]\n") else() - set(log "${log} ignore line: [${line}]\n") + string(APPEND log " ignore line: [${line}]\n") endif() endforeach() # Look for library search paths reported by linker. if("${output_lines}" MATCHES ";Library search paths:((;\t[^;]+)+)") string(REPLACE ";\t" ";" implicit_dirs_match "${CMAKE_MATCH_1}") - set(log "${log} Library search paths: [${implicit_dirs_match}]\n") + string(APPEND log " Library search paths: [${implicit_dirs_match}]\n") list(APPEND implicit_dirs_tmp ${implicit_dirs_match}) endif() if("${output_lines}" MATCHES ";Framework search paths:((;\t[^;]+)+)") string(REPLACE ";\t" ";" implicit_fwks_match "${CMAKE_MATCH_1}") - set(log "${log} Framework search paths: [${implicit_fwks_match}]\n") + string(APPEND log " Framework search paths: [${implicit_fwks_match}]\n") list(APPEND implicit_fwks_tmp ${implicit_fwks_match}) endif() @@ -124,12 +124,12 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj # We remove items that are not language-specific. set(implicit_libs "") foreach(lib IN LISTS implicit_libs_tmp) - if("x${lib}" MATCHES "^x(crt.*\\.o|gcc.*|System.*)$") - set(log "${log} remove lib [${lib}]\n") + if("x${lib}" MATCHES "^x(crt.*\\.o|gcc.*|System.*|.*libclang_rt.*)$") + string(APPEND log " remove lib [${lib}]\n") elseif(IS_ABSOLUTE "${lib}") get_filename_component(abs "${lib}" ABSOLUTE) if(NOT "x${lib}" STREQUAL "x${abs}") - set(log "${log} collapse lib [${lib}] ==> [${abs}]\n") + string(APPEND log " collapse lib [${lib}] ==> [${abs}]\n") endif() list(APPEND implicit_libs "${abs}") else() @@ -151,15 +151,15 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj set(msg "") list(APPEND implicit_${t} "${dir}") endif() - set(log "${log} collapse ${desc_${t}} dir [${d}] ==> [${dir}]${msg}\n") + string(APPEND log " collapse ${desc_${t}} dir [${d}] ==> [${dir}]${msg}\n") endforeach() list(REMOVE_DUPLICATES implicit_${t}) endforeach() # Log results. - set(log "${log} implicit libs: [${implicit_libs}]\n") - set(log "${log} implicit dirs: [${implicit_dirs}]\n") - set(log "${log} implicit fwks: [${implicit_fwks}]\n") + string(APPEND log " implicit libs: [${implicit_libs}]\n") + string(APPEND log " implicit dirs: [${implicit_dirs}]\n") + string(APPEND log " implicit fwks: [${implicit_fwks}]\n") # Return results. set(${lib_var} "${implicit_libs}" PARENT_SCOPE) diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake index 474fa41..61a0909 100644 --- a/Modules/CMakePrintHelpers.cmake +++ b/Modules/CMakePrintHelpers.cmake @@ -55,9 +55,9 @@ function(CMAKE_PRINT_VARIABLES) set(msg "") foreach(var ${ARGN}) if(msg) - set(msg "${msg} ; ") + string(APPEND msg " ; ") endif() - set(msg "${msg}${var}=\"${${var}}\"") + string(APPEND msg "${var}=\"${${var}}\"") endforeach() message(STATUS "${msg}") endfunction() @@ -132,21 +132,21 @@ function(CMAKE_PRINT_PROPERTIES ) if(keyword STREQUAL "TARGET") if(NOT TARGET ${item}) set(itemExists FALSE) - set(msg "${msg}\n No such TARGET \"${item}\" !\n\n") + string(APPEND msg "\n No such TARGET \"${item}\" !\n\n") endif() endif() if (itemExists) - set(msg "${msg} Properties for ${keyword} ${item}:\n") + string(APPEND msg " Properties for ${keyword} ${item}:\n") foreach(prop ${CPP_PROPERTIES}) get_property(propertySet ${keyword} ${item} PROPERTY "${prop}" SET) if(propertySet) get_property(property ${keyword} ${item} PROPERTY "${prop}") - set(msg "${msg} ${item}.${prop} = \"${property}\"\n") + string(APPEND msg " ${item}.${prop} = \"${property}\"\n") else() - set(msg "${msg} ${item}.${prop} = <NOTFOUND>\n") + string(APPEND msg " ${item}.${prop} = <NOTFOUND>\n") endif() endforeach() endif() diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index 94abd4b..60276e2 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -28,9 +28,9 @@ set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) +string(STRIP "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CMAKE_RC_FLAGS_INIT) - -set (CMAKE_RC_FLAGS "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CACHE STRING +set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_INIT}" CACHE STRING "Flags for Windows Resource Compiler.") # These are the only types of flags that should be passed to the rc diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 77f854d..675b38b 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -332,7 +332,7 @@ function(cpack_encode_variables) set(value "${${var}}") endif() - set(commands "${commands}\nSET(${var} \"${value}\")") + string(APPEND commands "\nSET(${var} \"${value}\")") endif() endforeach() @@ -455,6 +455,7 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF) option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF) option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF) + option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF) else() option(CPACK_BINARY_TZ "Enable to build TZ packages" ON) endif() @@ -483,6 +484,7 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2) @@ -531,6 +533,7 @@ mark_as_advanced( CPACK_BINARY_NSIS CPACK_BINARY_OSXX11 CPACK_BINARY_PACKAGEMAKER + CPACK_BINARY_PRODUCTBUILD CPACK_BINARY_RPM CPACK_BINARY_STGZ CPACK_BINARY_TBZ2 diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index 038a717..6552a2d 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -75,9 +75,17 @@ # # The dependencies (list of components) on which this component depends. # +# .. variable:: CPACK_COMPONENT_<compName>_HIDDEN +# +# True if this component is hidden from the user. +# # .. variable:: CPACK_COMPONENT_<compName>_REQUIRED # -# True is this component is required. +# True if this component is required. +# +# .. variable:: CPACK_COMPONENT_<compName>_DISABLED +# +# True if this component is not selected to be installed by default. # # .. command:: cpack_add_component # @@ -360,6 +368,20 @@ macro(cpack_append_string_variable_set_command var strvar) endif () endmacro() +# Macro that appends a SET command for the given list variable name (var) +# to the macro named strvar, but only if the variable named "var" +# has been defined. It's like add variable, but wrap each item to quotes. +# The string will eventually be appended to a CPack configuration file. +macro(cpack_append_list_variable_set_command var strvar) + if (DEFINED ${var}) + string(APPEND ${strvar} "set(${var}") + foreach(_val IN LISTS ${var}) + string(APPEND ${strvar} "\n \"${_val}\"") + endforeach() + string(APPEND ${strvar} ")\n") + endif () +endmacro() + # Macro that appends a SET command for the given variable name (var) # to the macro named strvar, but only if the variable named "var" # has been set to true. The string will eventually be @@ -395,11 +417,11 @@ macro(cpack_add_component compname) # moduled was included. if(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) get_cmake_property(_CPACK_ADDCOMP_COMPONENTS COMPONENTS) - set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") + string(APPEND _CPACK_ADDCOMP_STR "\nSET(CPACK_COMPONENTS_ALL") foreach(COMP ${_CPACK_ADDCOMP_COMPONENTS}) - set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR} ${COMP}") + string(APPEND _CPACK_ADDCOMP_STR " ${COMP}") endforeach() - set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR})\n") + string(APPEND _CPACK_ADDCOMP_STR ")\n") endif() endif() @@ -487,8 +509,8 @@ macro(cpack_add_install_type insttype) set(_CPACK_INSTTYPE_STR "\n# Configuration for installation type \"${insttype}\"\n") - set(_CPACK_INSTTYPE_STR - "${_CPACK_INSTTYPE_STR}list(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n") + string(APPEND _CPACK_INSTTYPE_STR + "list(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n") cpack_append_string_variable_set_command( CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME}_DISPLAY_NAME _CPACK_INSTTYPE_STR) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 083fc28..ebc5c90 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -571,7 +571,7 @@ macro(cpack_ifw_configure_component compname) endforeach() foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS}) - cpack_append_variable_set_command( + cpack_append_list_variable_set_command( CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME} _CPACK_IFWCOMP_STR) endforeach() @@ -604,7 +604,7 @@ macro(cpack_ifw_configure_component_group grpname) endforeach() foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS}) - cpack_append_variable_set_command( + cpack_append_list_variable_set_command( CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME} _CPACK_IFWGRP_STR) endforeach() @@ -645,7 +645,7 @@ macro(cpack_ifw_add_repository reponame) endforeach() list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame}) - set(_CPACK_IFWREPO_STR "${_CPACK_IFWREPO_STR}list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n") + string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n") if(CPack_CMake_INCLUDED) file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}") @@ -687,7 +687,7 @@ macro(cpack_ifw_update_repository reponame) OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REMOVE OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REPLACE) list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame}) - set(_CPACK_IFWREPO_STR "${_CPACK_IFWREPO_STR}list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n") + string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n") else() set(_CPACK_IFWREPO_STR) endif() diff --git a/Modules/CPackProductBuild.cmake b/Modules/CPackProductBuild.cmake new file mode 100644 index 0000000..6545a3a --- /dev/null +++ b/Modules/CPackProductBuild.cmake @@ -0,0 +1,38 @@ +#.rst: +# CPackProductBuild +# ----------------- +# +# productbuild CPack generator (Mac OS X). +# +# Variables specific to CPack productbuild generator +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# The following variable is specific to installers built on Mac +# OS X using productbuild: +# +# .. variable:: CPACK_COMMAND_PRODUCTBUILD +# +# Path to the productbuild(1) command used to generate a product archive for +# the OS X Installer or Mac App Store. This variable can be used to override +# the automatically detected command (or specify its location if the +# auto-detection fails to find it.) +# +# .. variable:: CPACK_COMMAND_PKGBUILD +# +# Path to the pkgbuild(1) command used to generate an OS X component package +# on OS X. This variable can be used to override the automatically detected +# command (or specify its location if the auto-detection fails to find it.) +# + +#============================================================================= +# Copyright 2006-2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 9cc496f..c195746 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -761,7 +761,7 @@ function(cpack_rpm_prepare_relocation_paths) if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION) - set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n") + string(APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n") list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") if(CPACK_RPM_PACKAGE_DEBUG) @@ -779,7 +779,7 @@ function(cpack_rpm_prepare_relocation_paths) endif() if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}") - set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PREPARED_RELOCATION_PATH}\n") + string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n") list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}") endif() endforeach() @@ -859,7 +859,9 @@ function(cpack_rpm_prepare_content_list) if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) - message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") + endif() list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") endif() endif() @@ -952,7 +954,7 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") set(INDENT "") else() - set(SCRIPT_PART "${SCRIPT_PART} if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") + string(APPEND SCRIPT_PART " if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") set(INDENT " ") endif() @@ -969,14 +971,14 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) - set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") - set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") - set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") - set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}fi\n") + string(APPEND SCRIPT_PART " ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + string(APPEND SCRIPT_PART " ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") + string(APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + string(APPEND SCRIPT_PART " ${INDENT}fi\n") endforeach() if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") - set(SCRIPT_PART "${SCRIPT_PART} fi\n") + string(APPEND SCRIPT_PART " fi\n") endif() endif() endforeach() @@ -996,16 +998,16 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) - set(SCRIPT_PART "${SCRIPT_PART} if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") - set(SCRIPT_PART "${SCRIPT_PART} ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") - set(SCRIPT_PART "${SCRIPT_PART} CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") - set(SCRIPT_PART "${SCRIPT_PART} fi\n") + string(APPEND SCRIPT_PART " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + string(APPEND SCRIPT_PART " ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") + string(APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + string(APPEND SCRIPT_PART " fi\n") endforeach() endif() if(PARTS_CNT) set(SCRIPT "${SCRIPT_PART}") - set(SCRIPT "${SCRIPT}fi\n") + string(APPEND SCRIPT "fi\n") endif() endforeach() @@ -1016,7 +1018,7 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) string(LENGTH "${POINT_PATH}" POINT_PATH_LEN) if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) - set(SCRIPT "${SCRIPT}if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") + string(APPEND SCRIPT "if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) @@ -1028,13 +1030,13 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) - set(SCRIPT "${SCRIPT} if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") - set(SCRIPT "${SCRIPT} ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n") - set(SCRIPT "${SCRIPT} CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") - set(SCRIPT "${SCRIPT} fi\n") + string(APPEND SCRIPT " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + string(APPEND SCRIPT " ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n") + string(APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + string(APPEND SCRIPT " fi\n") endforeach() - set(SCRIPT "${SCRIPT}fi\n") + string(APPEND SCRIPT "fi\n") endif() endforeach() @@ -1050,9 +1052,9 @@ function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) - set(SCRIPT "${SCRIPT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") - set(SCRIPT "${SCRIPT} ln -s \"${POINT_}\" \"${SYMLINK_}\"\n") - set(SCRIPT "${SCRIPT}fi\n") + string(APPEND SCRIPT "if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + string(APPEND SCRIPT " ln -s \"${POINT_}\" \"${SYMLINK_}\"\n") + string(APPEND SCRIPT "fi\n") endforeach() endif() @@ -1215,7 +1217,7 @@ function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXE set(DIRECTIVE "%dir ") endif() - set(INSTALL_FILES "${INSTALL_FILES}${DIRECTIVE}\"${F}\"\n") + string(APPEND INSTALL_FILES "${DIRECTIVE}\"${F}\"\n") endforeach() if(REQUIRES_SYMLINK_RELOCATION_SCRIPT) @@ -1346,7 +1348,7 @@ function(cpack_rpm_generate_package) endif() if(CPACK_RPM_PACKAGE_COMPONENT) - set(CPACK_RPM_PACKAGE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}") + string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME") @@ -1405,7 +1407,7 @@ function(cpack_rpm_generate_package) endif() if(CPACK_RPM_PACKAGE_RELEASE_DIST) - set(CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}%{?dist}") + string(APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}") endif() # CPACK_RPM_PACKAGE_LICENSE @@ -1524,13 +1526,13 @@ function(cpack_rpm_generate_package) string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) - set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") + string(APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}") # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file. set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND) if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1) string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}") - set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})") + string(APPEND _PACKAGE_HEADER_NAME ")") endif() if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") @@ -1683,17 +1685,17 @@ function(cpack_rpm_generate_package) set(CPACK_RPM_USER_INSTALL_FILES "") foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) - string(REGEX REPLACE "%[A-Za-z0-9\(\),-]* " "" F_PATH ${F}) - string(REGEX MATCH "%[A-Za-z0-9\(\),-]*" F_PREFIX ${F}) + string(REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${F}) + string(REGEX MATCH "%[A-Za-z]+(\\([^()]*\\))?" F_PREFIX ${F}) if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>") endif() if(F_PREFIX) - set(F_PREFIX "${F_PREFIX} ") + string(APPEND F_PREFIX " ") endif() # Rebuild the user list file - set(CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\"${F_PATH}\"\n") + string(APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}\"${F_PATH}\"\n") # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) @@ -1706,7 +1708,7 @@ function(cpack_rpm_generate_package) # Rebuild CPACK_RPM_INSTALL_FILES set(CPACK_RPM_INSTALL_FILES "") foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n") endforeach() else() set(CPACK_RPM_USER_INSTALL_FILES "") @@ -1727,12 +1729,12 @@ function(cpack_rpm_generate_package) # Rebuild INSTALL_FILES set(CPACK_RPM_INSTALL_FILES "") foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n") endforeach() # Build ABSOLUTE_INSTALL_FILES set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) - set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \"${F}\"\n") + string(APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config \"${F}\"\n") endforeach() if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 3c90561..10926c0 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -237,6 +237,17 @@ # * ARPURLUPDATEINFO - Update information URL # * ARPHELPTELEPHONE - Help and support telephone number # * ARPSIZE - Size (in kilobytes) of the application +# +# .. variable:: CPACK_WIX_ROOT_FEATURE_TITLE +# +# Sets the name of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components. +# +# .. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION +# +# Sets the description of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DESCRIPTION for components. +# #============================================================================= # Copyright 2014-2015 Kitware, Inc. diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index a27eb4b..ce725c5 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -224,16 +224,16 @@ if(BUILD_TESTING) set(BUILD_NAME_SYSTEM_NAME "Win32") endif() if(UNIX OR BORLAND) - get_filename_component(DART_CXX_NAME - "${CMAKE_CXX_COMPILER}" ${DART_NAME_COMPONENT}) + get_filename_component(DART_COMPILER_NAME + "${DART_COMPILER}" ${DART_NAME_COMPONENT}) else() - get_filename_component(DART_CXX_NAME + get_filename_component(DART_COMPILER_NAME "${CMAKE_MAKE_PROGRAM}" ${DART_NAME_COMPONENT}) endif() - if(DART_CXX_NAME MATCHES "devenv") - GET_VS_VERSION_STRING("${CMAKE_GENERATOR}" DART_CXX_NAME) + if(DART_COMPILER_NAME MATCHES "devenv") + GET_VS_VERSION_STRING("${CMAKE_GENERATOR}" DART_COMPILER_NAME) endif() - set(BUILDNAME "${BUILD_NAME_SYSTEM_NAME}-${DART_CXX_NAME}") + set(BUILDNAME "${BUILD_NAME_SYSTEM_NAME}-${DART_COMPILER_NAME}") endif() # the build command diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index c79119f..1a57d00 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -59,7 +59,7 @@ if(CTEST_USE_LAUNCHERS) "${__launch_common_options} --output <OUTPUT>") if("${CMAKE_GENERATOR}" MATCHES "Ninja") - set(__launch_compile_options "${__launch_compile_options} --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>") + string(APPEND __launch_compile_options " --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>") endif() set(CTEST_LAUNCH_COMPILE diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index ef1e39d..cfbc28f 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -60,7 +60,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}") + string(APPEND CMAKE_C_FLAGS " ${ARGV2}") endif() try_compile(${VARIABLE} diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 9a6df3b..59df7cb 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -59,7 +59,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}") + string(APPEND CMAKE_CXX_FLAGS " ${ARGV2}") endif() try_compile(${VARIABLE} diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 843cd35..3657c95 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -55,11 +55,11 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(CHECK_INCLUDE_FILES_CONTENT "/* */\n") set(MACRO_CHECK_INCLUDE_FILES_FLAGS ${CMAKE_REQUIRED_FLAGS}) foreach(FILE ${INCLUDE}) - set(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + "#include <${FILE}>\n") endforeach() - set(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n\nint main(void){return 0;}\n") + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + "\n\nint main(void){return 0;}\n") configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY) diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index e203d4c..b9345e7 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -75,8 +75,8 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB endif() foreach(_FILE ${_HEADER}) - set(CHECK_PROTOTYPE_DEFINITION_HEADER - "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") + string(APPEND CHECK_PROTOTYPE_DEFINITION_HEADER + "#include <${_FILE}>\n") endforeach() set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index 6c15205..e9e5a18 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -54,7 +54,7 @@ include(CheckCXXSourceCompiles) macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT) set(_INCLUDE_FILES) foreach (it ${_HEADER}) - set(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") + string(APPEND _INCLUDE_FILES "#include <${it}>\n") endforeach () if("x${ARGN}" STREQUAL "x") diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index c4dff3f..a62d1e1 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -71,11 +71,11 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) set(CMAKE_SYMBOL_EXISTS_INCLUDES) endif() foreach(FILE ${FILES}) - set(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + "#include <${FILE}>\n") endforeach() - set(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n") + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + "\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n") configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${SOURCEFILE}" @ONLY) diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 5938d6c..827905b 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -97,17 +97,17 @@ function(__check_type_size_impl type var map builtin language) set(headers) if(builtin) if(HAVE_SYS_TYPES_H) - set(headers "${headers}#include <sys/types.h>\n") + string(APPEND headers "#include <sys/types.h>\n") endif() if(HAVE_STDINT_H) - set(headers "${headers}#include <stdint.h>\n") + string(APPEND headers "#include <stdint.h>\n") endif() if(HAVE_STDDEF_H) - set(headers "${headers}#include <stddef.h>\n") + string(APPEND headers "#include <stddef.h>\n") endif() endif() foreach(h ${CMAKE_EXTRA_INCLUDE_FILES}) - set(headers "${headers}#include \"${h}\"\n") + string(APPEND headers "#include \"${h}\"\n") endforeach() # Perform the check. @@ -157,7 +157,7 @@ function(__check_type_size_impl type var map builtin language) string(REGEX MATCH "${regex_key}" key "${info}") string(REGEX REPLACE "${regex_key}" "\\1" key "${key}") if(key) - set(code "${code}\nset(${var}-${key} \"${size}\")") + string(APPEND code "\nset(${var}-${key} \"${size}\")") list(APPEND keys ${key}) endif() endif() diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake index 3cf628c..2ec75c3 100644 --- a/Modules/Compiler/ARMCC.cmake +++ b/Modules/Compiler/ARMCC.cmake @@ -20,11 +20,11 @@ set(CMAKE_AR "${CMAKE_ARMCC_AR}" CACHE FILEPATH "The ARMCC archiver" FORCE) mark_as_advanced(CMAKE_ARMCC_AR) macro(__compiler_armcc lang) - set(CMAKE_${lang}_FLAGS_INIT "") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Ospace -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-Otime -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ospace -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Otime -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake index 2e1666f..da1fc80 100644 --- a/Modules/Compiler/Absoft-Fortran.cmake +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -1,8 +1,8 @@ -set(CMAKE_Fortran_FLAGS_INIT "") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") -set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_INIT " ") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " ") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") set(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=") set(CMAKE_Fortran_MODPATH_FLAG "-p") set(CMAKE_Fortran_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/AppleClang-DetermineCompiler.cmake b/Modules/Compiler/AppleClang-DetermineCompiler.cmake index 397f95c..83817f7 100644 --- a/Modules/Compiler/AppleClang-DetermineCompiler.cmake +++ b/Modules/Compiler/AppleClang-DetermineCompiler.cmake @@ -3,5 +3,5 @@ set(_compiler_id_pp_test "defined(__clang__) && defined(__apple_build_version__) include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake") -set(_compiler_id_version_compute "${_compiler_id_version_compute} +string(APPEND _compiler_id_version_compute " # define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__apple_build_version__)") diff --git a/Modules/Compiler/Bruce-C.cmake b/Modules/Compiler/Bruce-C.cmake index 23676ec..cfabe65 100644 --- a/Modules/Compiler/Bruce-C.cmake +++ b/Modules/Compiler/Bruce-C.cmake @@ -1,7 +1,7 @@ # Bruce C Compiler ignores "-g" flag and optimization cannot be # enabled here (it is implemented only for 8086 target). -set (CMAKE_C_FLAGS_INIT "-D__CLASSIC_C__") -set (CMAKE_C_FLAGS_DEBUG_INIT "-g") -set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") -set (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") -set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_INIT " -D__CLASSIC_C__") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG") diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake index fd84848..2c83fb8 100644 --- a/Modules/Compiler/G95-Fortran.cmake +++ b/Modules/Compiler/G95-Fortran.cmake @@ -1,8 +1,8 @@ -set(CMAKE_Fortran_FLAGS_INIT "") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") -set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_INIT " ") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") set(CMAKE_Fortran_MODDIR_FLAG "-fmod=") set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") diff --git a/Modules/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake index 3072715..c30bdec 100644 --- a/Modules/Compiler/GHS-C.cmake +++ b/Modules/Compiler/GHS-C.cmake @@ -3,11 +3,11 @@ include(Compiler/GHS) set(CMAKE_C_VERBOSE_FLAG "-v") set(CMAKE_C_OUTPUT_EXTENSION ".o") -set(CMAKE_C_FLAGS_INIT "") -set(CMAKE_C_FLAGS_DEBUG_INIT "-Odebug -g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Ospace") -set(CMAKE_C_FLAGS_RELEASE_INIT "-O") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O -g") +string(APPEND CMAKE_C_FLAGS_INIT " ") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -Odebug -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -Ospace") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -O") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -O -g") set(CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT "-ldebug ${CMAKE_C_FLAGS_DEBUG_INIT}") set(CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") diff --git a/Modules/Compiler/GHS-CXX.cmake b/Modules/Compiler/GHS-CXX.cmake index a51591b..b3018a7 100644 --- a/Modules/Compiler/GHS-CXX.cmake +++ b/Modules/Compiler/GHS-CXX.cmake @@ -3,11 +3,11 @@ include(Compiler/GHS) set(CMAKE_CXX_VERBOSE_FLAG "-v") set(CMAKE_CXX_OUTPUT_EXTENSION ".o") -set(CMAKE_CXX_FLAGS_INIT "") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Odebug -g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Ospace") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O -g") +string(APPEND CMAKE_CXX_FLAGS_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -Odebug -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -Ospace") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -O") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -O -g") set(CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT "-ldebug ${CMAKE_CXX_FLAGS_DEBUG_INIT}") diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index e9c8a59..fc848ac 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -5,8 +5,8 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") # No -DNDEBUG for Fortran. -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3") # No -isystem for Fortran because it will not find .mod files. unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index c2d393d..34d4eaf 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -45,11 +45,11 @@ macro(__compiler_gnu lang) endif() # Initial configuration flags. - set(CMAKE_${lang}_FLAGS_INIT "") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462 diff --git a/Modules/Compiler/Intel-ASM.cmake b/Modules/Compiler/Intel-ASM.cmake index 74ceb0a..c2bf465 100644 --- a/Modules/Compiler/Intel-ASM.cmake +++ b/Modules/Compiler/Intel-ASM.cmake @@ -1,10 +1,9 @@ -set(CMAKE_ASM_VERBOSE_FLAG "-v") +include(Compiler/Intel) +__compiler_intel(ASM) -set(CMAKE_ASM_FLAGS_INIT "") -set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") if(UNIX) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S) diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index eb9602a..1d09bd5 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -1,10 +1,9 @@ -set(CMAKE_C_VERBOSE_FLAG "-v") +include(Compiler/Intel) +__compiler_intel(C) -set(CMAKE_C_FLAGS_INIT "") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <OBJECT> -MF <DEPFILE>") @@ -16,14 +15,14 @@ endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "${_std}=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "${_std}=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "${_std}=gnu11") endif() -if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "${_std}=c89") - set(CMAKE_C90_EXTENSION_COMPILE_OPTION "${_std}=c89") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "${_std}=gnu89") set(CMAKE_C99_STANDARD_COMPILE_OPTION "${_std}=c99") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION "${_std}=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "${_std}=gnu99") endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 369e041..3cc4503 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -1,10 +1,9 @@ -set(CMAKE_CXX_VERBOSE_FLAG "-v") +include(Compiler/Intel) +__compiler_intel(CXX) -set(CMAKE_CXX_FLAGS_INIT "") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <OBJECT> -MF <DEPFILE>") diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake index 671d284..ef7aa3a 100644 --- a/Modules/Compiler/Intel-Fortran.cmake +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -1,10 +1,7 @@ -set(CMAKE_Fortran_FLAGS_INIT "") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") -set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +include(Compiler/Intel) +__compiler_intel(Fortran) + set(CMAKE_Fortran_MODDIR_FLAG "-module ") -set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake new file mode 100644 index 0000000..8c3942c --- /dev/null +++ b/Modules/Compiler/Intel.cmake @@ -0,0 +1,36 @@ + +#============================================================================= +# Copyright 2002-2016 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_INTEL) + return() +endif() +set(__COMPILER_INTEL 1) + +if(CMAKE_HOST_WIN32) + # MSVC-like + macro(__compiler_intel lang) + endmacro() +else() + # GNU-like + macro(__compiler_intel lang) + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") + endmacro() +endif() diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index da88c01..85d6e7e 100644 --- a/Modules/Compiler/PGI-C.cmake +++ b/Modules/Compiler/PGI-C.cmake @@ -1,4 +1,4 @@ include(Compiler/PGI) __compiler_pgi(C) -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake index 97c9555..896e298 100644 --- a/Modules/Compiler/PGI-CXX.cmake +++ b/Modules/Compiler/PGI-CXX.cmake @@ -1,4 +1,4 @@ include(Compiler/PGI) __compiler_pgi(CXX) -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index 2866254..3765079 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -4,7 +4,7 @@ __compiler_pgi(Fortran) set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform") -set(CMAKE_Fortran_FLAGS_INIT "${CMAKE_Fortran_FLAGS_INIT} -Mpreprocess -Kieee") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "${CMAKE_Fortran_FLAGS_DEBUG_INIT} -Mbounds") +string(APPEND CMAKE_Fortran_FLAGS_INIT " -Mpreprocess -Kieee") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -Mbounds") set(CMAKE_Fortran_MODDIR_FLAG "-module ") diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake index 797945f..51069c2 100644 --- a/Modules/Compiler/PGI.cmake +++ b/Modules/Compiler/PGI.cmake @@ -23,11 +23,11 @@ macro(__compiler_pgi lang) set(CMAKE_${lang}_VERBOSE_FLAG "-v") # Initial configuration flags. - set(CMAKE_${lang}_FLAGS_INIT "") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O2 -s") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-fast -O3 -Mipa=fast") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -gopt") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -s") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O3 -Mipa=fast") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -gopt") # Preprocessing and assembly rules. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/PathScale-C.cmake b/Modules/Compiler/PathScale-C.cmake index 9db54af..94c7d08 100644 --- a/Modules/Compiler/PathScale-C.cmake +++ b/Modules/Compiler/PathScale-C.cmake @@ -1,4 +1,4 @@ include(Compiler/PathScale) __compiler_pathscale(C) -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") diff --git a/Modules/Compiler/PathScale-CXX.cmake b/Modules/Compiler/PathScale-CXX.cmake index 4dd7660..276b81b 100644 --- a/Modules/Compiler/PathScale-CXX.cmake +++ b/Modules/Compiler/PathScale-CXX.cmake @@ -1,4 +1,4 @@ include(Compiler/PathScale) __compiler_pathscale(CXX) -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") diff --git a/Modules/Compiler/PathScale.cmake b/Modules/Compiler/PathScale.cmake index 107f779..09ee2ba 100644 --- a/Modules/Compiler/PathScale.cmake +++ b/Modules/Compiler/PathScale.cmake @@ -23,9 +23,9 @@ macro(__compiler_pathscale lang) set(CMAKE_${lang}_VERBOSE_FLAG "-v") # Initial configuration flags. - set(CMAKE_${lang}_FLAGS_INIT "") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g -O2") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g -O2") endmacro() diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake index 2fa8b99..0d67400 100644 --- a/Modules/Compiler/SunPro-ASM.cmake +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -8,11 +8,11 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG "-R") set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG "-h") -set(CMAKE_ASM_FLAGS_INIT "") -set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_INIT " ") +string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") # Initialize ASM link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index c452983..503684a 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -7,11 +7,11 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h") -set(CMAKE_C_FLAGS_INIT "") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_INIT " ") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index b4a5591..ce01cdd 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -7,11 +7,11 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h") -set(CMAKE_CXX_FLAGS_INIT "") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index 610e191..a0e07d4 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -10,11 +10,11 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-h") set(CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG "-R") -set(CMAKE_Fortran_FLAGS_INIT "") -set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") -set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") -set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_INIT " ") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") set(CMAKE_Fortran_MODDIR_FLAG "-moddir=") set(CMAKE_Fortran_MODPATH_FLAG "-M") diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake index f7937ac..fbd2841 100644 --- a/Modules/Compiler/TinyCC-C.cmake +++ b/Modules/Compiler/TinyCC-C.cmake @@ -1,8 +1,8 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # no optimization in tcc: -set (CMAKE_C_FLAGS_INIT "") -set (CMAKE_C_FLAGS_DEBUG_INIT "-g") -set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") -set (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") -set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_INIT " ") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG") diff --git a/Modules/Compiler/XL-ASM.cmake b/Modules/Compiler/XL-ASM.cmake index 212179e..9177b39 100644 --- a/Modules/Compiler/XL-ASM.cmake +++ b/Modules/Compiler/XL-ASM.cmake @@ -2,11 +2,11 @@ set(CMAKE_ASM_VERBOSE_FLAG "-V") # -qthreaded = Ensures that all optimizations will be thread-safe # -qhalt=e = Halt on error messages (rather than just severe errors) -set(CMAKE_ASM_FLAGS_INIT "-qthreaded -qhalt=e -qsourcetype=assembler") +string(APPEND CMAKE_ASM_FLAGS_INIT " -qthreaded -qhalt=e -qsourcetype=assembler") -set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") -set(CMAKE_ASM_FLAGS_RELEASE_INIT "-O -DNDEBUG") -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -O -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -O -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG") set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 97dd017..f976c99 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -1,8 +1,8 @@ include(Compiler/XL) __compiler_xl(C) -set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe # -qhalt=e = Halt on error messages (rather than just severe errors) -set(CMAKE_C_FLAGS_INIT "-qthreaded -qhalt=e") +string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded -qhalt=e") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 41372c1..545d657 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -1,11 +1,11 @@ include(Compiler/XL) __compiler_xl(CXX) -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe # -qhalt=e = Halt on error messages (rather than just severe errors) -set(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e") +string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded -qhalt=e") set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> -+ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index ae9df4e..6bab6f6 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -10,7 +10,7 @@ set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") # -qthreaded = Ensures that all optimizations will be thread-safe # -qhalt=e = Halt on error messages (rather than just severe errors) -set(CMAKE_Fortran_FLAGS_INIT "-qthreaded -qhalt=e") +string(APPEND CMAKE_Fortran_FLAGS_INIT " -qthreaded -qhalt=e") # xlf: 1501-214 (W) command option E reserved for future use - ignored set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index bf4f554..1f2b145 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -29,10 +29,10 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_VERBOSE_FLAG "-V") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Dart.cmake b/Modules/Dart.cmake index db487d8..90298d6 100644 --- a/Modules/Dart.cmake +++ b/Modules/Dart.cmake @@ -119,7 +119,7 @@ if(BUILD_TESTING) # add testing targets set(DART_EXPERIMENTAL_NAME Experimental) if(DART_EXPERIMENTAL_USE_PROJECT_NAME) - set(DART_EXPERIMENTAL_NAME "${DART_EXPERIMENTAL_NAME}${PROJECT_NAME}") + string(APPEND DART_EXPERIMENTAL_NAME "${PROJECT_NAME}") endif() endif () diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index de475e4..f5ac959 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -247,7 +247,7 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va set(plugins_path ".") endif() if(plugins_dir) - set(plugins_path "${plugins_path}/${plugins_dir}") + string(APPEND plugins_path "/${plugins_dir}") endif() endif() @@ -263,7 +263,7 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va get_filename_component(plugin_group "${plugin_path}" NAME) set(${plugin_group_var} "${plugin_group}") endif() - set(plugins_path "${plugins_path}/${plugin_group}") + string(APPEND plugins_path "/${plugin_group}") if(${copy}) file(MAKE_DIRECTORY "${plugins_path}") diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index a3f460d..a0bffe7 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -473,10 +473,10 @@ function(ExternalData_expand_arguments target outArgsVar) if("x${piece}" MATCHES "^x${data_regex}$") # Replace this DATA{}-piece with a file path. _ExternalData_arg("${target}" "${piece}" "${CMAKE_MATCH_1}" file) - set(outArg "${outArg}${file}") + string(APPEND outArg "${file}") else() # No replacement needed for this piece. - set(outArg "${outArg}${piece}") + string(APPEND outArg "${piece}") endif() endforeach() else() @@ -696,12 +696,12 @@ macro(_ExternalData_arg_associated) get_filename_component(reldir "${reldata}" PATH) endif() if(reldir) - set(reldir "${reldir}/") + string(APPEND reldir "/") endif() _ExternalData_exact_regex(reldir_regex "${reldir}") if(recurse_option) set(glob GLOB_RECURSE) - set(reldir_regex "${reldir_regex}(.+/)?") + string(APPEND reldir_regex "(.+/)?") else() set(glob GLOB) endif() @@ -717,7 +717,7 @@ macro(_ExternalData_arg_associated) set(all "") set(sep "") foreach(regex ${associated_regex}) - set(all "${all}${sep}${reldir_regex}${regex}") + string(APPEND all "${sep}${reldir_regex}${regex}") set(sep "|") endforeach() _ExternalData_arg_find_files(${glob} "${reldir}" "${all}") @@ -971,15 +971,16 @@ function(_ExternalData_download_object name hash algo var_obj) set(url "${lhs}${algo}${rhs}") endif() endif() - message(STATUS "Fetching \"${url}\"") + string(REGEX REPLACE "((https?|ftp)://)([^@]+@)?(.*)" "\\1\\4" secured_url "${url}") + message(STATUS "Fetching \"${secured_url}\"") if(url MATCHES "^ExternalDataCustomScript://([A-Za-z_][A-Za-z0-9_]*)/(.*)$") _ExternalData_custom_fetch("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}" "${tmp}" err errMsg) else() _ExternalData_download_file("${url}" "${tmp}" err errMsg) endif() - set(tried "${tried}\n ${url}") + string(APPEND tried "\n ${url}") if(err) - set(tried "${tried} (${errMsg})") + string(APPEND tried " (${errMsg})") else() # Verify downloaded object. _ExternalData_compute_hash(dl_hash "${algo}" "${tmp}") @@ -987,7 +988,7 @@ function(_ExternalData_download_object name hash algo var_obj) set(found 1) break() else() - set(tried "${tried} (wrong hash ${algo}=${dl_hash})") + string(APPEND tried " (wrong hash ${algo}=${dl_hash})") if("$ENV{ExternalData_DEBUG_DOWNLOAD}" MATCHES ".") file(RENAME "${tmp}" "${store}/${algo}/${dl_hash}") endif() diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 5b73cd8..91d74e0 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -114,48 +114,56 @@ endif() set(retry_number 5) +message(STATUS "Downloading... + dst='@LOCAL@' + timeout='@TIMEOUT_MSG@'" +) + foreach(i RANGE ${retry_number}) sleep_before_download(${i}) - message(STATUS "downloading... - src='@REMOTE@' - dst='@LOCAL@' - timeout='@TIMEOUT_MSG@'") - - @TLS_VERIFY_CODE@ - @TLS_CAINFO_CODE@ - - file( - DOWNLOAD - "@REMOTE@" "@LOCAL@" - @SHOW_PROGRESS@ - @TIMEOUT_ARGS@ - STATUS status - LOG log - ) - - list(GET status 0 status_code) - list(GET status 1 status_string) - - if(status_code EQUAL 0) - check_file_hash(has_hash hash_is_good) - if(has_hash AND NOT hash_is_good) - message(STATUS "Hash mismatch, removing...") - file(REMOVE "@LOCAL@") + foreach(url @REMOTE@) + message(STATUS "Using src='${url}'") + + @TLS_VERIFY_CODE@ + @TLS_CAINFO_CODE@ + + file( + DOWNLOAD + "${url}" "@LOCAL@" + @SHOW_PROGRESS@ + @TIMEOUT_ARGS@ + STATUS status + LOG log + ) + + list(GET status 0 status_code) + list(GET status 1 status_string) + + if(status_code EQUAL 0) + check_file_hash(has_hash hash_is_good) + if(has_hash AND NOT hash_is_good) + message(STATUS "Hash mismatch, removing...") + file(REMOVE "@LOCAL@") + else() + message(STATUS "Downloading... done") + return() + endif() else() - message(STATUS "Downloading... done") - return() + string(APPEND logFailedURLs "error: downloading '${url}' failed + status_code: ${status_code} + status_string: ${status_string} + log: + --- LOG BEGIN --- + ${log} + --- LOG END --- + " + ) endif() - else() - message("error: downloading '@REMOTE@' failed - status_code: ${status_code} - status_string: ${status_string} - log: - --- LOG BEGIN --- - ${log} - --- LOG END ---" - ) - endif() + endforeach() endforeach() -message(FATAL_ERROR "Downloading failed") +message(FATAL_ERROR "Each download failed! + ${logFailedURLs} + " +) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 2ff18fc..44bf957 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -69,8 +69,8 @@ Create custom targets to build projects in external trees URL of mercurial repo ``HG_TAG <tag>`` Mercurial branch name, commit id or tag - ``URL /.../src.tgz`` - Full path or URL of source + ``URL /.../src.tgz [/.../src.tgz]...`` + Full path or URL(s) of source. Multiple URLs are allowed as mirrors. ``URL_HASH ALGO=value`` Hash of file at URL ``URL_MD5 md5`` @@ -993,6 +993,7 @@ endif() # message(STATUS \"extracting... [analysis]\") file(GLOB contents \"\${ut_dir}/*\") +list(REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\") list(LENGTH contents n) if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\") set(contents \"\${ut_dir}\") @@ -1117,8 +1118,8 @@ function(_ep_command_line_to_initial_cache var args force) set(line "${CMAKE_MATCH_1}") if(setArg) # This is required to build up lists in variables, or complete an entry - set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") - set(script_initial_cache "${script_initial_cache}\n${setArg}") + string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND script_initial_cache "\n${setArg}") set(accumulator "") set(setArg "") endif() @@ -1132,13 +1133,13 @@ function(_ep_command_line_to_initial_cache var args force) endif() else() # Assume this is a list to append to the last var - set(accumulator "${accumulator};${line}") + string(APPEND accumulator ";${line}") endif() endforeach() # Catch the final line of the args if(setArg) - set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") - set(script_initial_cache "${script_initial_cache}\n${setArg}") + string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND script_initial_cache "\n${setArg}") endif() set(${var} ${script_initial_cache} PARENT_SCOPE) endfunction() @@ -1332,16 +1333,16 @@ endif() foreach(arg IN LISTS command) if("x${arg}" STREQUAL "xCOMMAND") if(NOT "x${cmd}" STREQUAL "x") - set(code "${code}set(command \"${cmd}\")${code_execute_process}") + string(APPEND code "set(command \"${cmd}\")${code_execute_process}") endif() set(cmd "") set(sep "") else() - set(cmd "${cmd}${sep}${arg}") + string(APPEND cmd "${sep}${arg}") set(sep ";") endif() endforeach() - set(code "${code}set(command \"${cmd}\")${code_execute_process}") + string(APPEND code "set(command \"${cmd}\")${code_execute_process}") file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}") set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake) endif() @@ -1667,7 +1668,7 @@ function(_ep_add_download_command name) get_property(fname TARGET ${name} PROPERTY _EP_DOWNLOAD_NAME) # TODO: Perhaps file:// should be copied to download dir before extraction. - string(REGEX REPLACE "^file://" "" url "${url}") + string(REGEX REPLACE "file://" "" url "${url}") set(depends) set(comment) @@ -1861,6 +1862,19 @@ function(_ep_add_download_command name) @ONLY ) list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt) + + list(LENGTH url url_list_length) + if(NOT "${url_list_length}" STREQUAL "1") + foreach(entry ${url}) + if(NOT "${entry}" MATCHES "^[a-z]+://") + message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)") + endif() + endforeach() + if("x${fname}" STREQUAL "x") + list(GET url 0 fname) + endif() + endif() + if(IS_DIRECTORY "${url}") get_filename_component(abs_dir "${url}" ABSOLUTE) set(comment "Performing download step (DIR copy) for '${name}'") @@ -1871,16 +1885,19 @@ function(_ep_add_download_command name) if("${url}" MATCHES "^[a-z]+://") # TODO: Should download and extraction be different steps? if("x${fname}" STREQUAL "x") - string(REGEX MATCH "[^/\\?]*$" fname "${url}") + set(fname "${url}") endif() - if(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") - string(REGEX MATCH "([^/\\?]+(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip))/.*$" match_result "${url}") + if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]]) set(fname "${CMAKE_MATCH_1}") - endif() - if (no_extract) - get_filename_component(fname "${url}" NAME) - elseif(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") - message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}") + elseif(no_extract) + get_filename_component(fname "${fname}" NAME) + else() + # Fall back to a default file name. The actual file name does not + # matter because it is used only internally and our extraction tool + # inspects the file content directly. If it turns out the wrong URL + # was given that will be revealed during the build which is an easier + # place for users to diagnose than an error here anyway. + set(fname "archive.tar") endif() string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index dc31086..764a5f7 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -411,23 +411,23 @@ function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) if(includeThisOne) - set(_currentFeatureText "${_currentFeatureText}\n * ${_currentFeature}") + string(APPEND _currentFeatureText "\n * ${_currentFeature}") get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION) if(_info) - set(_currentFeatureText "${_currentFeatureText} (required version ${_info})") + string(APPEND _currentFeatureText " (required version ${_info})") endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_DESCRIPTION) if(_info) - set(_currentFeatureText "${_currentFeatureText} , ${_info}") + string(APPEND _currentFeatureText " , ${_info}") endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL) if(_info) - set(_currentFeatureText "${_currentFeatureText} , <${_info}>") + string(APPEND _currentFeatureText " , <${_info}>") endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_PURPOSE) foreach(_purpose ${_info}) - set(_currentFeatureText "${_currentFeatureText}\n ${_purpose}") + string(APPEND _currentFeatureText "\n ${_purpose}") endforeach() endif() @@ -527,7 +527,7 @@ function(FEATURE_SUMMARY) set(_tmp) _FS_GET_FEATURE_SUMMARY( ${part} _tmp ${_FS_INCLUDE_QUIET_PACKAGES}) if(_tmp) - set(_fullText "${_fullText}\n-- ${title_${part}}\n${_tmp}\n") + string(APPEND _fullText "\n-- ${title_${part}}\n${_tmp}\n") if("${part}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") set(requiredPackagesNotFound TRUE) endif() diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 69293f5..6b1c7bd 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -23,7 +23,8 @@ # BISON_TARGET(<Name> <YaccInput> <CodeOutput> # [COMPILE_FLAGS <flags>] # [DEFINES_FILE <file>] -# [VERBOSE <file>] +# [VERBOSE [<file>]] +# [REPORT_FILE <file>] # ) # # which will create a custom rule to generate a parser. ``<YaccInput>`` is @@ -39,9 +40,14 @@ # ``DEFINES_FILE <file>`` # Specify a non-default header ``<file>`` to be generated by ``bison``. # -# ``VERBOSE <file>`` -# Tell ``bison`` to write verbose descriptions of the grammar and -# parser to the given ``<file>``. +# ``VERBOSE [<file>]`` +# Tell ``bison`` to write a report file of the grammar and parser. +# If ``<file>`` is given, it specifies path the report file is copied to. +# ``[<file>]`` is left for backward compatibility of this module. +# Use ``VERBOSE REPORT_FILE <file>``. +# +# ``REPORT_FILE <file>`` +# Specify a non-default report ``<file>``, if generated. # # The macro defines the following variables: # @@ -58,7 +64,7 @@ # The header file generated by bison # # ``BISON_<Name>_OUTPUTS`` -# The sources files generated by bison +# All files generated by bison including the source, the header and the report # # ``BISON_<Name>_COMPILE_FLAGS`` # Options used in the ``bison`` command line @@ -120,35 +126,65 @@ if(BISON_EXECUTABLE) endif() # internal macro - macro(BISON_TARGET_option_verbose Name BisonOutput filename) - list(APPEND BISON_TARGET_cmdopt "--verbose") - get_filename_component(BISON_TARGET_output_path "${BisonOutput}" PATH) - get_filename_component(BISON_TARGET_output_name "${BisonOutput}" NAME_WE) - add_custom_command(OUTPUT ${filename} - COMMAND ${CMAKE_COMMAND} -E copy - "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output" - "${filename}" - VERBATIM - DEPENDS - "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output" - COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}" - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - set(BISON_${Name}_VERBOSE_FILE ${filename}) - list(APPEND BISON_TARGET_extraoutputs - "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output") - endmacro() - - # internal macro + # sets BISON_TARGET_cmdopt macro(BISON_TARGET_option_extraopts Options) + set(BISON_TARGET_cmdopt "") set(BISON_TARGET_extraopts "${Options}") separate_arguments(BISON_TARGET_extraopts) list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts}) endmacro() # internal macro - macro(BISON_TARGET_option_defines Header) - set(BISON_TARGET_output_header "${Header}") - list(APPEND BISON_TARGET_cmdopt --defines=${BISON_TARGET_output_header}) + # sets BISON_TARGET_output_header and BISON_TARGET_cmdopt + macro(BISON_TARGET_option_defines BisonOutput Header) + if("${Header}" STREQUAL "") + # default header path generated by bison (see option -d) + string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}") + string(REPLACE "c" "h" _fileext ${_fileext}) + string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}" + BISON_TARGET_output_header "${BisonOutput}") + list(APPEND BISON_TARGET_cmdopt "-d") + else() + set(BISON_TARGET_output_header "${Header}") + list(APPEND BISON_TARGET_cmdopt "--defines=${BISON_TARGET_output_header}") + endif() + endmacro() + + # internal macro + # sets BISON_TARGET_verbose_file and BISON_TARGET_cmdopt + macro(BISON_TARGET_option_report_file BisonOutput ReportFile) + if("${ReportFile}" STREQUAL "") + get_filename_component(BISON_TARGET_output_path "${BisonOutput}" PATH) + get_filename_component(BISON_TARGET_output_name "${BisonOutput}" NAME_WE) + set(BISON_TARGET_verbose_file + "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output") + else() + set(BISON_TARGET_verbose_file "${ReportFile}") + list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}") + endif() + endmacro() + + # internal macro + # adds a custom command and sets + # BISON_TARGET_cmdopt, BISON_TARGET_verbose_file, BISON_TARGET_extraoutputs + macro(BISON_TARGET_option_verbose Name BisonOutput filename) + list(APPEND BISON_TARGET_cmdopt "--verbose") + list(APPEND BISON_TARGET_extraoutputs + "${BISON_TARGET_verbose_file}") + if (NOT "${filename}" STREQUAL "") + add_custom_command(OUTPUT ${filename} + COMMAND ${CMAKE_COMMAND} -E copy + "${BISON_TARGET_verbose_file}" + "${filename}" + VERBATIM + DEPENDS + "${BISON_TARGET_verbose_file}" + COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + set(BISON_${Name}_VERBOSE_FILE ${filename}) + list(APPEND BISON_TARGET_extraoutputs + "${filename}") + endif() endmacro() #============================================================ @@ -156,18 +192,20 @@ if(BISON_EXECUTABLE) #============================================================ # macro(BISON_TARGET Name BisonInput BisonOutput) - set(BISON_TARGET_output_header "") - set(BISON_TARGET_cmdopt "") set(BISON_TARGET_outputs "${BisonOutput}") + set(BISON_TARGET_extraoutputs "") # Parsing parameters - set(BISON_TARGET_PARAM_OPTIONS) + set(BISON_TARGET_PARAM_OPTIONS + ) set(BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS - VERBOSE COMPILE_FLAGS DEFINES_FILE + REPORT_FILE + ) + set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS + VERBOSE ) - set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS) cmake_parse_arguments( BISON_TARGET_ARG "${BISON_TARGET_PARAM_OPTIONS}" @@ -178,29 +216,30 @@ if(BISON_EXECUTABLE) if(NOT "${BISON_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "") message(SEND_ERROR "Usage") + elseif("${BISON_TARGET_ARG_VERBOSE}" MATCHES ";") + # [VERBOSE [<file>] hack: <file> is non-multi value by usage + message(SEND_ERROR "Usage") else() + + BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}") + BISON_TARGET_option_defines("${BisonOutput}" "${BISON_TARGET_ARG_DEFINES_FILE}") + BISON_TARGET_option_report_file("${BisonOutput}" "${BISON_TARGET_ARG_REPORT_FILE}") if(NOT "${BISON_TARGET_ARG_VERBOSE}" STREQUAL "") BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${BISON_TARGET_ARG_VERBOSE}") - endif() - if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") - BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}") - endif() - if(NOT "${BISON_TARGET_ARG_DEFINES_FILE}" STREQUAL "") - BISON_TARGET_option_defines("${BISON_TARGET_ARG_DEFINES_FILE}") + else() + # [VERBOSE [<file>]] is used with no argument or is not used + set(BISON_TARGET_args "${ARGN}") + list(FIND BISON_TARGET_args "VERBOSE" BISON_TARGET_args_indexof_verbose) + if(${BISON_TARGET_args_indexof_verbose} GREATER -1) + # VERBOSE is used without <file> + BISON_TARGET_option_verbose(${Name} ${BisonOutput} "") + endif() endif() - if("${BISON_TARGET_output_header}" STREQUAL "") - # Header's name generated by bison (see option -d) - list(APPEND BISON_TARGET_cmdopt "-d") - string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}") - string(REPLACE "c" "h" _fileext ${_fileext}) - string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}" - BISON_TARGET_output_header "${BisonOutput}") - endif() list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}") add_custom_command(OUTPUT ${BISON_TARGET_outputs} - ${BISON_TARGET_extraoutputs} + ${BISON_TARGET_verbose_file} COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput} VERBATIM DEPENDS ${BisonInput} @@ -210,7 +249,7 @@ if(BISON_EXECUTABLE) # define target variables set(BISON_${Name}_DEFINED TRUE) set(BISON_${Name}_INPUT ${BisonInput}) - set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs}) + set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs} ${BISON_TARGET_extraoutputs}) set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt}) set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}") set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}") diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 6af42dd..b670025 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -37,7 +37,7 @@ find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include) if (NOT BZIP2_LIBRARIES) find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib) - find_library(BZIP2_LIBRARY_DEBUG NAMES bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib) + find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) SELECT_LIBRARY_CONFIGURATIONS(BZIP2) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 67d71d0..1f03841 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -209,6 +209,7 @@ # Copyright 2007 Mike Jackson # Copyright 2008 Andreas Pakulat <apaku@gmx.de> # Copyright 2008-2012 Philip Lowman <philip@yhbt.com> +# Copyright 2016 Alex Turbov <i.zaufi@gmail.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -442,24 +443,26 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) endif() elseif (GHSMULTI) set(_boost_COMPILER "-ghs") - elseif (MSVC14) - set(_boost_COMPILER "-vc140") - elseif (MSVC12) - set(_boost_COMPILER "-vc120") - elseif (MSVC11) - set(_boost_COMPILER "-vc110") - elseif (MSVC10) - set(_boost_COMPILER "-vc100") - elseif (MSVC90) - set(_boost_COMPILER "-vc90") - elseif (MSVC80) - set(_boost_COMPILER "-vc80") - elseif (MSVC71) - set(_boost_COMPILER "-vc71") - elseif (MSVC70) # Good luck! - set(_boost_COMPILER "-vc7") # yes, this is correct - elseif (MSVC60) # Good luck! - set(_boost_COMPILER "-vc6") # yes, this is correct + elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) + set(_boost_COMPILER "-vc140") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) + set(_boost_COMPILER "-vc120") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) + set(_boost_COMPILER "-vc110") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) + set(_boost_COMPILER "-vc100") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) + set(_boost_COMPILER "-vc90") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) + set(_boost_COMPILER "-vc80") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10) + set(_boost_COMPILER "-vc71") + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck! + set(_boost_COMPILER "-vc7") # yes, this is correct + else() # MSVC60 Good luck! + set(_boost_COMPILER "-vc6") # yes, this is correct + endif() elseif (BORLAND) set(_boost_COMPILER "-bcb") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") @@ -805,6 +808,10 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp") set(_Boost_WAVE_HEADERS "boost/wave.hpp") set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp") + if(WIN32) + set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") + set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") + endif() string(TOUPPER ${component} uppercomponent) set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE) @@ -862,6 +869,37 @@ function(_Boost_MISSING_DEPENDENCIES componentvar extravar) endfunction() # +# Update library search directory hint variable with paths used by prebuilt boost binaries. +# +# Prebuilt windows binaries (https://sourceforge.net/projects/boost/files/boost-binaries/) +# have library directories named using MSVC compiler version and architecture. +# This function would append corresponding directories if MSVC is a current compiler, +# so having `BOOST_ROOT` would be enough to specify to find everything. +# +macro(_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_arch_suffix 64) + else() + set(_arch_suffix 32) + endif() + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-14.0) + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-12.0) + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-11.0) + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-10.0) + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-9.0) + elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) + list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-8.0) + endif() + endif() +endmacro() + +# # End functions/macros # #------------------------------------------------------------------------------- @@ -1143,8 +1181,8 @@ if(Boost_INCLUDE_DIR) math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") + string(APPEND Boost_ERROR_REASON + "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "version.hpp reveals boost " @@ -1166,16 +1204,16 @@ if(Boost_INCLUDE_DIR) endif() if(NOT Boost_FOUND) # State that we found a version of Boost that is too new or too old. - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") + string(APPEND Boost_ERROR_REASON + "\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") if (Boost_FIND_VERSION_PATCH) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") + string(APPEND Boost_ERROR_REASON + ".${Boost_FIND_VERSION_PATCH}") endif () if (NOT Boost_FIND_VERSION_EXACT) - set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)") + string(APPEND Boost_ERROR_REASON " (or newer)") endif () - set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") + string(APPEND Boost_ERROR_REASON ".") endif () else() # Caller will accept any Boost version. @@ -1183,8 +1221,8 @@ if(Boost_INCLUDE_DIR) endif() else() set(Boost_FOUND 0) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") + string(APPEND Boost_ERROR_REASON + "Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") endif() # ------------------------------------------------------------------------ @@ -1261,17 +1299,18 @@ endif() # g using debug versions of the standard and runtime # support libraries if(WIN32 AND Boost_USE_DEBUG_RUNTIME) - if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" + OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") - set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") + string(APPEND _boost_DEBUG_ABI_TAG "g") endif() endif() # y using special debug build of python if(Boost_USE_DEBUG_PYTHON) - set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") + string(APPEND _boost_DEBUG_ABI_TAG "y") endif() # d using a debug version of your code -set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") +string(APPEND _boost_DEBUG_ABI_TAG "d") # p using the STLport standard library rather than the # default one supplied with your compiler if(Boost_USE_STLPORT) @@ -1319,8 +1358,10 @@ foreach(c DEBUG RELEASE) if(BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib) + _Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} BOOST_ROOT) elseif(_ENV_BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib) + _Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} _ENV_BOOST_ROOT) endif() list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} @@ -1599,26 +1640,26 @@ if(Boost_FOUND) set(Boost_FOUND 0) # We were unable to find some libraries, so generate a sensible # error message that lists the libraries we were unable to find. - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}\nCould not find the following") + string(APPEND Boost_ERROR_REASON + "\nCould not find the following") if(Boost_USE_STATIC_LIBS) - set(Boost_ERROR_REASON "${Boost_ERROR_REASON} static") + string(APPEND Boost_ERROR_REASON " static") endif() - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON} Boost libraries:\n") + string(APPEND Boost_ERROR_REASON + " Boost libraries:\n") foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON} ${Boost_NAMESPACE}_${COMPONENT}\n") + string(APPEND Boost_ERROR_REASON + " ${Boost_NAMESPACE}_${COMPONENT}\n") endforeach() list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + string(APPEND Boost_ERROR_REASON + "No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") else () - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + string(APPEND Boost_ERROR_REASON + "Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") endif () endif () @@ -1697,13 +1738,6 @@ if(Boost_FOUND) IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${Boost_${UPPERCOMPONENT}_LIBRARY}") endif() - if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") - set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(Boost::${COMPONENT} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" - IMPORTED_LOCATION_DEBUG "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") - endif() if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}") set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) @@ -1711,6 +1745,13 @@ if(Boost_FOUND) IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" IMPORTED_LOCATION_RELEASE "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}") endif() + if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") + set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(Boost::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") + endif() if(_Boost_${UPPERCOMPONENT}_DEPENDENCIES) unset(_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES) foreach(dep ${_Boost_${UPPERCOMPONENT}_DEPENDENCIES}) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 48bb554..d7c9d8a 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -188,10 +188,8 @@ # files. # # -# # CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target # nvcc_flags object_files) -# # -- Generates the link object required by separable compilation from the given # object files. This is called automatically for CUDA_ADD_EXECUTABLE and # CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS @@ -201,6 +199,24 @@ # specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function # instead of a macro. # +# CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) +# -- Selects GPU arch flags for nvcc based on target_CUDA_architectures +# target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) +# - "Auto" detects local machine GPU compute arch at runtime. +# - "Common" and "All" cover common and entire subsets of architectures +# ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX +# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal +# NUM: Any number. Only those pairs are currently accepted by NVCC though: +# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 +# Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} +# Additionally, sets ${out_variable}_readable to the resulting numeric list +# Example: +# CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) +# LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) +# +# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA +# Note that this is a function instead of a macro. +# # CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... # [STATIC | SHARED | MODULE] [OPTIONS ...] ) # -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, @@ -283,7 +299,7 @@ # implementation (alternative to: # CUDA_ADD_CUFFT_TO_TARGET macro) # CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS -# implementation (alterative to: +# implementation (alternative to: # CUDA_ADD_CUBLAS_TO_TARGET macro). # CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. # Only available for CUDA version 5.5+ @@ -563,8 +579,8 @@ macro(cuda_unset_include_and_libraries) unset(CUDA_npps_LIBRARY CACHE) unset(CUDA_nvcuvenc_LIBRARY CACHE) unset(CUDA_nvcuvid_LIBRARY CACHE) - unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) endmacro() # Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, @@ -580,31 +596,33 @@ if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL cuda_unset_include_and_libraries() endif() -if(NOT "${CUDA_SDK_ROOT_DIR}" STREQUAL "${CUDA_SDK_ROOT_DIR_INTERNAL}") - # No specific variables to catch. Use this kind of code before calling - # find_package(CUDA) to clean up any variables that may depend on this path. +# +# End of unset() +# - # unset(MY_SPECIAL_CUDA_SDK_INCLUDE_DIR CACHE) - # unset(MY_SPECIAL_CUDA_SDK_LIBRARY CACHE) -endif() +# +# Start looking for things +# # Search for the cuda distribution. -if(NOT CUDA_TOOLKIT_ROOT_DIR) - +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) # Search in the CUDA_BIN_PATH first. find_path(CUDA_TOOLKIT_ROOT_DIR NAMES nvcc nvcc.exe PATHS + ENV CUDA_TOOLKIT_ROOT ENV CUDA_PATH ENV CUDA_BIN_PATH PATH_SUFFIXES bin bin64 DOC "Toolkit location." NO_DEFAULT_PATH ) + # Now search default paths find_path(CUDA_TOOLKIT_ROOT_DIR NAMES nvcc nvcc.exe - PATHS /usr/local/bin + PATHS /opt/cuda/bin + /usr/local/bin /usr/local/cuda/bin DOC "Toolkit location." ) @@ -613,7 +631,9 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR) string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) # We need to force this back into the cache. set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) endif() + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) if(CUDA_FIND_REQUIRED) message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") @@ -623,8 +643,45 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR) endif () endif () +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + find_host_program( ${ARGN} ) + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + # CUDA_NVCC_EXECUTABLE -find_program(CUDA_NVCC_EXECUTABLE +cuda_find_host_program(CUDA_NVCC_EXECUTABLE NAMES nvcc PATHS "${CUDA_TOOLKIT_ROOT_DIR}" ENV CUDA_PATH @@ -633,7 +690,7 @@ find_program(CUDA_NVCC_EXECUTABLE NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. -find_program(CUDA_NVCC_EXECUTABLE nvcc) +cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) mark_as_advanced(CUDA_NVCC_EXECUTABLE) if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) @@ -649,33 +706,14 @@ else() string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") endif() + # Always set this convenience variable set(CUDA_VERSION_STRING "${CUDA_VERSION}") -# Support for arm cross compilation with CUDA 5.5 -if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf" CACHE PATH "Toolkit target location.") -# Support for aarch64 cross compilation with CUDA 7.0 -elseif(CUDA_VERSION VERSION_GREATER "6.5" AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux" CACHE PATH "Toolkit target location.") -else() - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}" CACHE PATH "Toolkit target location.") -endif() -mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) - -# Target CPU architecture -if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm") - set(_cuda_target_cpu_arch_initial "ARM") -else() - set(_cuda_target_cpu_arch_initial "") -endif() -set(CUDA_TARGET_CPU_ARCH ${_cuda_target_cpu_arch_initial} CACHE STRING "Specify the name of the class of CPU architecture for which the input files must be compiled.") -mark_as_advanced(CUDA_TARGET_CPU_ARCH) - # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit - PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}" + PATHS ${CUDA_TOOLKIT_TARGET_DIR} ENV CUDA_PATH ENV CUDA_INC_PATH PATH_SUFFIXES include @@ -705,19 +743,21 @@ macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} - PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}" + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" ENV CUDA_PATH ENV CUDA_LIB_PATH PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" DOC ${_doc} NO_DEFAULT_PATH ) - # Search default search paths, after we search our own set of paths. - find_library(${_var} - NAMES ${_names} - PATHS "/usr/lib/nvidia-current" - DOC ${_doc} - ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() endmacro() macro(cuda_find_library_local_first _var _names _doc) @@ -738,15 +778,20 @@ if(CUDA_VERSION VERSION_EQUAL "3.0") CUDA_CUDARTEMU_LIBRARY ) endif() -if(NOT CUDA_VERSION VERSION_LESS "5.5") + +if(CUDA_USE_STATIC_CUDA_RUNTIME AND NOT CUDA_VERSION VERSION_LESS "5.5") cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") mark_as_advanced(CUDA_cudart_static_LIBRARY) endif() + + if(CUDA_cudart_static_LIBRARY) # Set whether to use the static cuda runtime. option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) else() option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" OFF) + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) endif() if(CUDA_USE_STATIC_CUDA_RUNTIME) @@ -772,12 +817,12 @@ if(CUDA_USE_STATIC_CUDA_RUNTIME) else() unset(CMAKE_THREAD_PREFER_PTHREAD) endif() - if (NOT APPLE) - # Here is librt that has things such as, clock_gettime, shm_open, and shm_unlink. - find_library(CUDA_rt_LIBRARY rt) - if (NOT CUDA_rt_LIBRARY) - message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") - endif() + endif() + if (UNIX AND NOT APPLE AND CUDA_VERSION VERSION_LESS "7.0") + # Before CUDA 7.0, there was librt that has things such as, clock_gettime, shm_open, and shm_unlink. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") endif() endif() endif() @@ -955,12 +1000,13 @@ set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + find_package_handle_standard_args(CUDA REQUIRED_VARS CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS - CUDA_CUDART_LIBRARY + ${CUDA_CUDART_LIBRARY_VAR} VERSION_VAR CUDA_VERSION ) @@ -986,6 +1032,7 @@ endmacro() cuda_find_helper_file(parse_cubin cmake) cuda_find_helper_file(make2cmake cmake) cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_CURRENT_LIST_DIR}/FindCUDA/select_compute_arch.cmake") ############################################################################## # Separate the OPTIONS out from the sources @@ -1278,13 +1325,13 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") endif() - set(_cuda_host_flags "${_cuda_host_flags}\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") endif() # Note that if we ever want CUDA_NVCC_FLAGS_<CONFIG> to be string (instead of a list # like it is currently), we can remove the quotes around the # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_<CONFIG> variable. - set(_cuda_nvcc_flags_config "${_cuda_nvcc_flags_config}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") endforeach() # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index 802f93a..7b5389e 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -100,7 +100,7 @@ list(REMOVE_DUPLICATES dependency_list) list(SORT dependency_list) foreach(file ${dependency_list}) - set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n") + string(APPEND cuda_nvcc_depend " \"${file}\"\n") endforeach() file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n") diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 12b83e0..ff1f515 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -95,7 +95,7 @@ string(TOUPPER "${build_configuration}" build_configuration) #message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}") foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}}) # Extra quotes are added around each flag to help nvcc parse out flags with spaces. - set(nvcc_host_compiler_flags "${nvcc_host_compiler_flags},\"${flag}\"") + string(APPEND nvcc_host_compiler_flags ",\"${flag}\"") endforeach() if (nvcc_host_compiler_flags) set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags}) diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake new file mode 100644 index 0000000..d516831 --- /dev/null +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -0,0 +1,195 @@ +# Synopsis: +# CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) +# -- Selects GPU arch flags for nvcc based on target_CUDA_architectures +# target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) +# - "Auto" detects local machine GPU compute arch at runtime. +# - "Common" and "All" cover common and entire subsets of architectures +# ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX +# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal +# NUM: Any number. Only those pairs are currently accepted by NVCC though: +# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 +# Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} +# Additionally, sets ${out_variable}_readable to the resulting numeric list +# Example: +# CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) +# LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) +# +# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA +# + +# This list will be used for CUDA_ARCH_NAME = All option +set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell") + +# This list will be used for CUDA_ARCH_NAME = Common option (enabled by default) +set(CUDA_COMMON_GPU_ARCHITECTURES "3.0" "3.5" "5.0") + +if (CUDA_VERSION VERSION_GREATER "6.5") + list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra") + list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2") +endif () + +if (CUDA_VERSION VERSION_GREATER "7.5") + list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Pascal") + list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1" "6.1+PTX") +else() + list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX") +endif () + + + +################################################################################################ +# A function for automatic detection of GPUs installed (if autodetection is enabled) +# Usage: +# CUDA_DETECT_INSTALLED_GPUS(OUT_VARIABLE) +# +function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) + if(NOT CUDA_GPU_DETECT_OUTPUT) + set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) + + file(WRITE ${cufile} "" + "#include <cstdio>\n" + "int main()\n" + "{\n" + " int count = 0;\n" + " if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;\n" + " if (count == 0) return -1;\n" + " for (int device = 0; device < count; ++device)\n" + " {\n" + " cudaDeviceProp prop;\n" + " if (cudaSuccess == cudaGetDeviceProperties(&prop, device))\n" + " std::printf(\"%d.%d \", prop.major, prop.minor);\n" + " }\n" + " return 0;\n" + "}\n") + + execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" + RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(nvcc_res EQUAL 0) + string(REPLACE "2.1" "2.1(2.0)" nvcc_out "${nvcc_out}") + set(CUDA_GPU_DETECT_OUTPUT ${nvcc_out} CACHE INTERNAL "Returned GPU architetures from detect_gpus tool" FORCE) + endif() + endif() + + if(NOT CUDA_GPU_DETECT_OUTPUT) + message(STATUS "Automatic GPU detection failed. Building for common architectures.") + set(${OUT_VARIABLE} ${CUDA_COMMON_GPU_ARCHITECTURES} PARENT_SCOPE) + else() + set(${OUT_VARIABLE} ${CUDA_GPU_DETECT_OUTPUT} PARENT_SCOPE) + endif() +endfunction() + + +################################################################################################ +# Function for selecting GPU arch flags for nvcc based on CUDA architectures from parameter list +# Usage: +# SELECT_NVCC_ARCH_FLAGS(out_variable [list of CUDA compute archs]) +function(CUDA_SELECT_NVCC_ARCH_FLAGS out_variable) + set(CUDA_ARCH_LIST "${ARGN}") + + if("X${CUDA_ARCH_LIST}" STREQUAL "X" ) + set(CUDA_ARCH_LIST "Auto") + endif() + + set(cuda_arch_bin) + set(cuda_arch_ptx) + + if("${CUDA_ARCH_LIST}" STREQUAL "All") + set(CUDA_ARCH_LIST ${CUDA_KNOWN_GPU_ARCHITECTURES}) + elseif("${CUDA_ARCH_LIST}" STREQUAL "Common") + set(CUDA_ARCH_LIST ${CUDA_COMMON_GPU_ARCHITECTURES}) + elseif("${CUDA_ARCH_LIST}" STREQUAL "Auto") + CUDA_DETECT_INSTALLED_GPUS(CUDA_ARCH_LIST) + message(STATUS "Autodetected CUDA architecture(s): ${cuda_arch_bin}") + endif() + + # Now process the list and look for names + string(REGEX REPLACE "[ \t]+" ";" CUDA_ARCH_LIST "${CUDA_ARCH_LIST}") + list(REMOVE_DUPLICATES CUDA_ARCH_LIST) + foreach(arch_name ${CUDA_ARCH_LIST}) + set(arch_bin) + set(add_ptx FALSE) + # Check to see if we are compiling PTX + if(arch_name MATCHES "(.*)\\+PTX$") + set(add_ptx TRUE) + set(arch_name ${CMAKE_MATCH_1}) + endif() + if(arch_name MATCHES "([0-9]\\.[0-9])$") + set(arch_bin ${CMAKE_MATCH_1}) + set(arch_ptx ${arch_bin}) + else() + # Look for it in our list of known architectures + if(${arch_name} STREQUAL "Fermi") + set(arch_bin 2.0 "2.1(2.0)") + elseif(${arch_name} STREQUAL "Kepler+Tegra") + set(arch_bin 3.2) + elseif(${arch_name} STREQUAL "Kepler+Tesla") + set(arch_bin 3.7) + elseif(${arch_name} STREQUAL "Kepler") + set(arch_bin 3.0 3.5) + set(arch_ptx 3.5) + elseif(${arch_name} STREQUAL "Maxwell+Tegra") + set(arch_bin 5.3) + elseif(${arch_name} STREQUAL "Maxwell") + set(arch_bin 5.0 5.2) + set(arch_ptx 5.2) + elseif(${arch_name} STREQUAL "Pascal") + set(arch_bin 6.0 6.1) + set(arch_ptx 6.1) + else() + message(SEND_ERROR "Unknown CUDA Architecture Name ${arch_name} in CUDA_SELECT_NVCC_ARCH_FLAGS") + endif() + endif() + if(NOT arch_bin) + message(SEND_ERROR "arch_bin wasn't set for some reason") + endif() + list(APPEND cuda_arch_bin ${arch_bin}) + if(add_ptx) + if (NOT arch_ptx) + set(arch_ptx ${arch_bin}) + endif() + list(APPEND cuda_arch_ptx ${arch_ptx}) + endif() + endforeach() + + # remove dots and convert to lists + string(REGEX REPLACE "\\." "" cuda_arch_bin "${cuda_arch_bin}") + string(REGEX REPLACE "\\." "" cuda_arch_ptx "${cuda_arch_ptx}") + string(REGEX MATCHALL "[0-9()]+" cuda_arch_bin "${cuda_arch_bin}") + string(REGEX MATCHALL "[0-9]+" cuda_arch_ptx "${cuda_arch_ptx}") + + if(cuda_arch_bin) + list(REMOVE_DUPLICATES cuda_arch_bin) + endif() + if(cuda_arch_ptx) + list(REMOVE_DUPLICATES cuda_arch_ptx) + endif() + + set(nvcc_flags "") + set(nvcc_archs_readable "") + + # Tell NVCC to add binaries for the specified GPUs + foreach(arch ${cuda_arch_bin}) + if(arch MATCHES "([0-9]+)\\(([0-9]+)\\)") + # User explicitly specified PTX for the concrete BIN + list(APPEND nvcc_flags -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}) + list(APPEND nvcc_archs_readable sm_${CMAKE_MATCH_1}) + else() + # User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN + list(APPEND nvcc_flags -gencode arch=compute_${arch},code=sm_${arch}) + list(APPEND nvcc_archs_readable sm_${arch}) + endif() + endforeach() + + # Tell NVCC to add PTX intermediate code for the specified architectures + foreach(arch ${cuda_arch_ptx}) + list(APPEND nvcc_flags -gencode arch=compute_${arch},code=compute_${arch}) + list(APPEND nvcc_archs_readable compute_${arch}) + endforeach() + + string(REPLACE ";" " " nvcc_archs_readable "${nvcc_archs_readable}") + set(${out_variable} ${nvcc_flags} PARENT_SCOPE) + set(${out_variable}_readable ${nvcc_archs_readable} PARENT_SCOPE) +endfunction() diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 51eb7c5..6f70455 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -55,7 +55,7 @@ if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$") set(CUPS_VERSION_PART "${CMAKE_MATCH_1}") if(CUPS_VERSION_STRING) - set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}") + string(APPEND CUPS_VERSION_STRING ".${CUPS_VERSION_PART}") else() set(CUPS_VERSION_STRING "${CUPS_VERSION_PART}") endif() diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 653094c..70fc35b 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -41,7 +41,7 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$") set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}") if(EXPAT_VERSION_STRING) - set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}") + string(APPEND EXPAT_VERSION_STRING ".${EXPAT_VERSION_PART}") else() set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}") endif() diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 7d46d15..35dc17d 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -51,9 +51,8 @@ # wants explicit full paths and this trickery doesn't work too well. # I'm going to attempt to cut out the middleman and hope # everything still works. -find_path( - FREETYPE_INCLUDE_DIR_ft2build - ft2build.h + +set(FREETYPE_FIND_ARGS HINTS ENV FREETYPE_DIR PATHS @@ -64,6 +63,12 @@ find_path( ENV GTKMM_BASEPATH [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] +) + +find_path( + FREETYPE_INCLUDE_DIR_ft2build + ft2build.h + ${FREETYPE_FIND_ARGS} PATH_SUFFIXES include/freetype2 include @@ -75,40 +80,37 @@ find_path( NAMES freetype/config/ftheader.h config/ftheader.h - HINTS - ENV FREETYPE_DIR - PATHS - /usr/X11R6 - /usr/local/X11R6 - /usr/local/X11 - /usr/freeware - ENV GTKMM_BASEPATH - [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + ${FREETYPE_FIND_ARGS} PATH_SUFFIXES include/freetype2 include freetype2 ) -find_library(FREETYPE_LIBRARY - NAMES - freetype - libfreetype - freetype219 - HINTS - ENV FREETYPE_DIR - PATHS - /usr/X11R6 - /usr/local/X11R6 - /usr/local/X11 - /usr/freeware - ENV GTKMM_BASEPATH - [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] - PATH_SUFFIXES - lib -) +if(NOT FREETYPE_LIBRARY) + find_library(FREETYPE_LIBRARY_RELEASE + NAMES + freetype + libfreetype + freetype219 + ${FREETYPE_FIND_ARGS} + PATH_SUFFIXES + lib + ) + find_library(FREETYPE_LIBRARY_DEBUG + NAMES + freetyped + libfreetyped + freetype219d + ${FREETYPE_FIND_ARGS} + PATH_SUFFIXES + lib + ) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(FREETYPE) +endif() + +unset(FREETYPE_FIND_ARGS) # set the user variables if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) @@ -133,7 +135,7 @@ if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$") set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}") if(FREETYPE_VERSION_STRING) - set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}") + string(APPEND FREETYPE_VERSION_STRING ".${FREETYPE_VERSION_PART}") else() set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}") endif() @@ -158,7 +160,6 @@ find_package_handle_standard_args( ) mark_as_advanced( - FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build ) diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 7bbb8cf..6fbe9e9 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -2,12 +2,18 @@ # FindGIF # ------- # +# This finds the GIF library (giflib) # +# The module defines the following variables: # -# This module searches giflib and defines GIF_LIBRARIES - libraries to -# link to in order to use GIF GIF_FOUND, if false, do not try to link -# GIF_INCLUDE_DIR, where to find the headers GIF_VERSION, reports either -# version 4 or 3 (for everything before version 4) +# ``GIF_FOUND`` +# True if giflib was found +# ``GIF_LIBRARIES`` +# Libraries to link to in order to use giflib +# ``GIF_INCLUDE_DIR`` +# where to find the headers +# ``GIF_VERSION`` +# 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6 # # The minimum required version of giflib can be specified using the # standard syntax, e.g. find_package(GIF 4) @@ -29,7 +35,7 @@ # License text for the above reference.) # Created by Eric Wing. -# Modifications by Alexander Neundorf +# Modifications by Alexander Neundorf, Ben Campbell find_path(GIF_INCLUDE_DIR gif_lib.h HINTS @@ -61,22 +67,40 @@ set(GIF_LIBRARIES ${GIF_LIBRARY}) # to be always " Version 2.0, " in versions 3.x of giflib. # In version 4 the member UserData was added to GifFileType, so we check for this # one. -# http://giflib.sourcearchive.com/documentation/4.1.4/files.html +# Versions after 4.1.6 define GIFLIB_MAJOR, GIFLIB_MINOR, and GIFLIB_RELEASE +# see http://giflib.sourceforge.net/gif_lib.html#compatibility if(GIF_INCLUDE_DIR) include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake) CMAKE_PUSH_CHECK_STATE() set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY}) - set(GIF_VERSION 3) set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}") - CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData ) - if(GIF_GifFileType_UserData) - set(GIF_VERSION 4) + + # Check for the specific version defines (>=4.1.6 only) + file(STRINGS ${GIF_INCLUDE_DIR}/gif_lib.h _GIF_DEFS REGEX "^[ \t]*#define[ \t]+GIFLIB_(MAJOR|MINOR|RELEASE)") + if(_GIF_DEFS) + # yay - got exact version info + string(REGEX REPLACE ".*GIFLIB_MAJOR ([0-9]+).*" "\\1" _GIF_MAJ "${_GIF_DEFS}") + string(REGEX REPLACE ".*GIFLIB_MINOR ([0-9]+).*" "\\1" _GIF_MIN "${_GIF_DEFS}") + string(REGEX REPLACE ".*GIFLIB_RELEASE ([0-9]+).*" "\\1" _GIF_REL "${_GIF_DEFS}") + set(GIF_VERSION "${_GIF_MAJ}.${_GIF_MIN}.${_GIF_REL}") + else() + # use UserData field to sniff version instead + CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData ) + if(GIF_GifFileType_UserData) + set(GIF_VERSION 4) + else() + set(GIF_VERSION 3) + endif() endif() + + unset(_GIF_MAJ) + unset(_GIF_MIN) + unset(_GIF_REL) + unset(_GIF_DEFS) CMAKE_POP_CHECK_STATE() endif() - # handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index f42182f..7413289 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -35,20 +35,45 @@ # License text for the above reference.) find_path(GLEW_INCLUDE_DIR GL/glew.h) -find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64) -set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) -set(GLEW_LIBRARIES ${GLEW_LIBRARY}) +if(NOT GLEW_LIBRARY) + find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64) + find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64) + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(GLEW) +endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(GLEW REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY) -if(GLEW_FOUND AND NOT TARGET GLEW::GLEW) - add_library(GLEW::GLEW UNKNOWN IMPORTED) - set_target_properties(GLEW::GLEW PROPERTIES - IMPORTED_LOCATION "${GLEW_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") +if(GLEW_FOUND) + set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) + + if(NOT GLEW_LIBRARIES) + set(GLEW_LIBRARIES ${GLEW_LIBRARY}) + endif() + + if (NOT TARGET GLEW::GLEW) + add_library(GLEW::GLEW UNKNOWN IMPORTED) + set_target_properties(GLEW::GLEW PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + + if(GLEW_LIBRARY_RELEASE) + set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_LIBRARY_RELEASE}") + endif() + + if(GLEW_LIBRARY_DEBUG) + set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_LIBRARY_DEBUG}") + endif() + + if(NOT GLEW_LIBRARY_RELEASE AND NOT GLEW_LIBRARY_DEBUG) + set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_LOCATION "${GLEW_LIBRARY}") + endif() + endif() endif() -mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY) +mark_as_advanced(GLEW_INCLUDE_DIR) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 50e1892..a898386 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -332,7 +332,7 @@ macro( _HDF5_parse_compile_line set( RE " -D([^ ]*)") string( REGEX MATCHALL "${RE}" definition_flags "${${compile_line_var}}" ) foreach( DEF IN LISTS definition_flags ) - string( REGEX REPLACE "${RE}" "\\1" DEF "${DEF}" ) + string( STRIP "${DEF}" DEF ) list( APPEND ${definitions} ${DEF} ) endforeach() diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake new file mode 100644 index 0000000..ade39b8 --- /dev/null +++ b/Modules/FindICU.cmake @@ -0,0 +1,359 @@ +#.rst: +# FindICU +# ------- +# +# Find the International Components for Unicode (ICU) libraries and +# programs. +# +# This module supports multiple components. +# Components can include any of: ``data``, ``i18n``, ``io``, ``le``, +# ``lx``, ``test``, ``tu`` and ``uc``. +# +# Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named +# ``in``; any of the names may be used, and the appropriate +# platform-specific library name will be automatically selected. +# +# This module reports information about the ICU installation in +# several variables. General variables:: +# +# ICU_VERSION - ICU release version +# ICU_FOUND - true if the main programs and libraries were found +# ICU_LIBRARIES - component libraries to be linked +# ICU_INCLUDE_DIRS - the directories containing the ICU headers +# +# Imported targets:: +# +# ICU::<C> +# +# Where ``<C>`` is the name of an ICU component, for example +# ``ICU::i18n``. +# +# ICU programs are reported in:: +# +# ICU_GENCNVAL_EXECUTABLE - path to gencnval executable +# ICU_ICUINFO_EXECUTABLE - path to icuinfo executable +# ICU_GENBRK_EXECUTABLE - path to genbrk executable +# ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable +# ICU_GENRB_EXECUTABLE - path to genrb executable +# ICU_GENDICT_EXECUTABLE - path to gendict executable +# ICU_DERB_EXECUTABLE - path to derb executable +# ICU_PKGDATA_EXECUTABLE - path to pkgdata executable +# ICU_UCONV_EXECUTABLE - path to uconv executable +# ICU_GENCFU_EXECUTABLE - path to gencfu executable +# ICU_MAKECONV_EXECUTABLE - path to makeconv executable +# ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable +# ICU_GENCCODE_EXECUTABLE - path to genccode executable +# ICU_GENSPREP_EXECUTABLE - path to gensprep executable +# ICU_ICUPKG_EXECUTABLE - path to icupkg executable +# ICU_GENCMN_EXECUTABLE - path to gencmn executable +# +# ICU component libraries are reported in:: +# +# ICU_<C>_FOUND - ON if component was found +# ICU_<C>_LIBRARIES - libraries for component +# +# Note that ``<C>`` is the uppercased name of the component. +# +# This module reads hints about search results from:: +# +# ICU_ROOT - the root of the ICU installation +# +# The environment variable ``ICU_ROOT`` may also be used; the +# ICU_ROOT variable takes precedence. +# +# The following cache variables may also be set:: +# +# ICU_<P>_EXECUTABLE - the path to executable <P> +# ICU_INCLUDE_DIR - the directory containing the ICU headers +# ICU_<C>_LIBRARY - the library for component <C> +# +# .. note:: +# +# In most cases none of the above variables will require setting, +# unless multiple ICU versions are available and a specific version +# is required. +# +# Other variables one may set to control this module are:: +# +# ICU_DEBUG - Set to ON to enable debug output from FindICU. + +# Written by Roger Leigh <rleigh@codelibre.net> + +#============================================================================= +# Copyright 2014-2016 University of Dundee +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(icu_programs + gencnval + icuinfo + genbrk + icu-config + genrb + gendict + derb + pkgdata + uconv + gencfu + makeconv + gennorm2 + genccode + gensprep + icupkg + gencmn) + +# The ICU checks are contained in a function due to the large number +# of temporary variables needed. +function(_ICU_FIND) + # Set up search paths, taking compiler into account. Search ICU_ROOT, + # with ICU_ROOT in the environment as a fallback if unset. + if(ICU_ROOT) + list(APPEND icu_roots "${ICU_ROOT}") + else() + if(NOT "$ENV{ICU_ROOT}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{ICU_ROOT}" NATIVE_PATH) + list(APPEND icu_roots "${NATIVE_PATH}") + set(ICU_ROOT "${NATIVE_PATH}" + CACHE PATH "Location of the ICU installation" FORCE) + endif() + endif() + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # 64-bit binary directory + set(_bin64 "bin64") + # 64-bit library directory + set(_lib64 "lib64") + endif() + + # Generic 64-bit and 32-bit directories + list(APPEND icu_binary_suffixes "${_bin64}" "bin") + list(APPEND icu_library_suffixes "${_lib64}" "lib") + + # Find all ICU programs + foreach(program ${icu_programs}) + string(TOUPPER "${program}" program_upcase) + set(cache_var "ICU_${program_upcase}_EXECUTABLE") + set(program_var "ICU_${program_upcase}_EXECUTABLE") + find_program("${cache_var}" "${program}" + HINTS ${icu_roots} + PATH_SUFFIXES ${icu_binary_suffixes} + DOC "ICU ${program} executable") + mark_as_advanced(cache_var) + set("${program_var}" "${${cache_var}}" PARENT_SCOPE) + endforeach() + + # Find include directory + find_path(ICU_INCLUDE_DIR + NAMES "unicode/utypes.h" + HINTS ${icu_roots} + PATH_SUFFIXES ${icu_include_suffixes} + DOC "ICU include directory") + set(ICU_INCLUDE_DIR "${ICU_INCLUDE_DIR}" PARENT_SCOPE) + + # Get version + if(ICU_INCLUDE_DIR AND EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h") + file(STRINGS "${ICU_INCLUDE_DIR}/unicode/uvernum.h" icu_header_str + REGEX "^#define[\t ]+U_ICU_VERSION[\t ]+\".*\".*") + + string(REGEX REPLACE "^#define[\t ]+U_ICU_VERSION[\t ]+\"([^ \\n]*)\".*" + "\\1" icu_version_string "${icu_header_str}") + set(ICU_VERSION "${icu_version_string}" PARENT_SCOPE) + unset(icu_header_str) + unset(icu_version_string) + endif() + + # Find all ICU libraries + set(ICU_REQUIRED_LIBS_FOUND ON) + foreach(component ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${component}" component_upcase) + set(component_cache "ICU_${component_upcase}_LIBRARY") + set(component_cache_release "${component_cache}_RELEASE") + set(component_cache_debug "${component_cache}_DEBUG") + set(component_found "${component_upcase}_FOUND") + set(component_libnames "icu${component}") + set(component_debug_libnames "icu${component}d") + + # Special case deliberate library naming mismatches between Unix + # and Windows builds + unset(component_libnames) + unset(component_debug_libnames) + list(APPEND component_libnames "icu${component}") + list(APPEND component_debug_libnames "icu${component}d") + if(component STREQUAL "data") + list(APPEND component_libnames "icudt") + # Note there is no debug variant at present + list(APPEND component_debug_libnames "icudtd") + endif() + if(component STREQUAL "dt") + list(APPEND component_libnames "icudata") + # Note there is no debug variant at present + list(APPEND component_debug_libnames "icudatad") + endif() + if(component STREQUAL "i18n") + list(APPEND component_libnames "icuin") + list(APPEND component_debug_libnames "icuind") + endif() + if(component STREQUAL "in") + list(APPEND component_libnames "icui18n") + list(APPEND component_debug_libnames "icui18nd") + endif() + + find_library("${component_cache_release}" ${component_libnames} + HINTS ${icu_roots} + PATH_SUFFIXES ${icu_library_suffixes} + DOC "ICU ${component} library (release)") + find_library("${component_cache_debug}" ${component_debug_libnames} + HINTS ${icu_roots} + PATH_SUFFIXES ${icu_library_suffixes} + DOC "ICU ${component} library (debug)") + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(ICU_${component_upcase}) + mark_as_advanced("${component_cache_release}" "${component_cache_debug}") + if(${component_cache}) + set("${component_found}" ON) + list(APPEND ICU_LIBRARY "${${component_cache}}") + endif() + mark_as_advanced("${component_found}") + set("${component_cache}" "${${component_cache}}" PARENT_SCOPE) + set("${component_found}" "${${component_found}}" PARENT_SCOPE) + if(${component_found}) + if (ICU_FIND_REQUIRED_${component}) + list(APPEND ICU_LIBS_FOUND "${component} (required)") + else() + list(APPEND ICU_LIBS_FOUND "${component} (optional)") + endif() + else() + if (ICU_FIND_REQUIRED_${component}) + set(ICU_REQUIRED_LIBS_FOUND OFF) + list(APPEND ICU_LIBS_NOTFOUND "${component} (required)") + else() + list(APPEND ICU_LIBS_NOTFOUND "${component} (optional)") + endif() + endif() + endforeach() + set(_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND}" PARENT_SCOPE) + set(ICU_LIBRARY "${ICU_LIBRARY}" PARENT_SCOPE) + + if(NOT ICU_FIND_QUIETLY) + if(ICU_LIBS_FOUND) + message(STATUS "Found the following ICU libraries:") + foreach(found ${ICU_LIBS_FOUND}) + message(STATUS " ${found}") + endforeach() + endif() + if(ICU_LIBS_NOTFOUND) + message(STATUS "The following ICU libraries were not found:") + foreach(notfound ${ICU_LIBS_NOTFOUND}) + message(STATUS " ${notfound}") + endforeach() + endif() + endif() + + if(ICU_DEBUG) + message(STATUS "--------FindICU.cmake search debug--------") + message(STATUS "ICU binary path search order: ${icu_roots}") + message(STATUS "ICU include path search order: ${icu_roots}") + message(STATUS "ICU library path search order: ${icu_roots}") + message(STATUS "----------------") + endif() +endfunction() + +_ICU_FIND() + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICU + FOUND_VAR ICU_FOUND + REQUIRED_VARS ICU_INCLUDE_DIR + ICU_LIBRARY + _ICU_REQUIRED_LIBS_FOUND + VERSION_VAR ICU_VERSION + FAIL_MESSAGE "Failed to find all ICU components") + +unset(_ICU_REQUIRED_LIBS_FOUND) + +if(ICU_FOUND) + set(ICU_INCLUDE_DIRS "${ICU_INCLUDE_DIR}") + set(ICU_LIBRARIES "${ICU_LIBRARY}") + foreach(_ICU_component ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${_ICU_component}" _ICU_component_upcase) + set(_ICU_component_cache "ICU_${_ICU_component_upcase}_LIBRARY") + set(_ICU_component_cache_release "ICU_${_ICU_component_upcase}_LIBRARY_RELEASE") + set(_ICU_component_cache_debug "ICU_${_ICU_component_upcase}_LIBRARY_DEBUG") + set(_ICU_component_lib "ICU_${_ICU_component_upcase}_LIBRARIES") + set(_ICU_component_found "${_ICU_component_upcase}_FOUND") + set(_ICU_imported_target "ICU::${_ICU_component}") + if(${_ICU_component_found}) + set("${_ICU_component_lib}" "${${_ICU_component_cache}}") + if(NOT TARGET ${_ICU_imported_target}) + add_library(${_ICU_imported_target} UNKNOWN IMPORTED) + if(ICU_INCLUDE_DIR) + set_target_properties(${_ICU_imported_target} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIR}") + endif() + if(EXISTS "${${_ICU_component_cache}}") + set_target_properties(${_ICU_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${${_ICU_component_cache}}") + endif() + if(EXISTS "${${_ICU_component_cache_release}}") + set_property(TARGET ${_ICU_imported_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${_ICU_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "${${_ICU_component_cache_release}}") + endif() + if(EXISTS "${${_ICU_component_cache_debug}}") + set_property(TARGET ${_ICU_imported_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${_ICU_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${${_ICU_component_cache_debug}}") + endif() + endif() + endif() + unset(_ICU_component_upcase) + unset(_ICU_component_cache) + unset(_ICU_component_lib) + unset(_ICU_component_found) + unset(_ICU_imported_target) + endforeach() +endif() + +if(ICU_DEBUG) + message(STATUS "--------FindICU.cmake results debug--------") + message(STATUS "ICU found: ${ICU_FOUND}") + message(STATUS "ICU_VERSION number: ${ICU_VERSION}") + message(STATUS "ICU_ROOT directory: ${ICU_ROOT}") + message(STATUS "ICU_INCLUDE_DIR directory: ${ICU_INCLUDE_DIR}") + message(STATUS "ICU_LIBRARIES: ${ICU_LIBRARIES}") + + foreach(program IN LISTS icu_programs) + string(TOUPPER "${program}" program_upcase) + set(program_lib "ICU_${program_upcase}_EXECUTABLE") + message(STATUS "${program} program: ${${program_lib}}") + unset(program_upcase) + unset(program_lib) + endforeach() + + foreach(component IN LISTS ICU_FIND_COMPONENTS) + string(TOUPPER "${component}" component_upcase) + set(component_lib "ICU_${component_upcase}_LIBRARIES") + set(component_found "${component_upcase}_FOUND") + message(STATUS "${component} library found: ${${component_found}}") + message(STATUS "${component} library: ${${component_lib}}") + unset(component_upcase) + unset(component_lib) + unset(component_found) + endforeach() + message(STATUS "----------------") +endif() + +unset(icu_programs) diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index 3fa6cab..8f548cd 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -141,6 +141,8 @@ function(_Ice_FIND) set(ice_versions 3 3.6 + 3.6.2 + 3.6.1 3.6.0 3.5 3.5.1 @@ -360,12 +362,20 @@ function(_Ice_FIND) foreach(component ${Ice_FIND_COMPONENTS}) string(TOUPPER "${component}" component_upcase) set(component_cache "Ice_${component_upcase}_LIBRARY") + set(component_cache_release "${component_cache}_RELEASE") + set(component_cache_debug "${component_cache}_DEBUG") set(component_found "${component_upcase}_FOUND") - find_library("${component_cache}" "${component}" + find_library("${component_cache_release}" "${component}" HINTS ${ice_roots} PATH_SUFFIXES ${ice_library_suffixes} - DOC "Ice ${component} library") - mark_as_advanced("${component_cache}") + DOC "Ice ${component} library (release)") + find_library("${component_cache_debug}" "${component}d" + HINTS ${ice_roots} + PATH_SUFFIXES ${ice_library_suffixes} + DOC "Ice ${component} library (debug)") + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(Ice_${component_upcase}) + mark_as_advanced("${component_cache_release}" "${component_cache_debug}") if(${component_cache}) set("${component_found}" ON) list(APPEND Ice_LIBRARY "${${component_cache}}") @@ -438,6 +448,8 @@ if(Ice_FOUND) foreach(_Ice_component ${Ice_FIND_COMPONENTS}) string(TOUPPER "${_Ice_component}" _Ice_component_upcase) set(_Ice_component_cache "Ice_${_Ice_component_upcase}_LIBRARY") + set(_Ice_component_cache_release "Ice_${_Ice_component_upcase}_LIBRARY_RELEASE") + set(_Ice_component_cache_debug "Ice_${_Ice_component_upcase}_LIBRARY_DEBUG") set(_Ice_component_lib "Ice_${_Ice_component_upcase}_LIBRARIES") set(_Ice_component_found "${_Ice_component_upcase}_FOUND") set(_Ice_imported_target "Ice::${_Ice_component}") @@ -445,9 +457,29 @@ if(Ice_FOUND) set("${_Ice_component_lib}" "${${_Ice_component_cache}}") if(NOT TARGET ${_Ice_imported_target}) add_library(${_Ice_imported_target} UNKNOWN IMPORTED) - set_target_properties(${_Ice_imported_target} PROPERTIES - IMPORTED_LOCATION "${${_Ice_component_cache}}" - INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIR}") + if() + set_target_properties(${_Ice_imported_target} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIR}") + endif() + if(EXISTS "${${_Ice_component_cache}}") + set_target_properties(${_Ice_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${${_Ice_component_cache}}") + endif() + if(EXISTS "${${_Ice_component_cache_debug}}") + set_property(TARGET ${_Ice_imported_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${_Ice_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${${_Ice_component_cache_debug}}") + endif() + if(EXISTS "${${_Ice_component_cache_release}}") + set_property(TARGET ${_Ice_imported_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${_Ice_imported_target} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "${${_Ice_component_cache_release}}") + endif() endif() endif() unset(_Ice_component_upcase) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 3ceab39..658d6ca 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -312,8 +312,11 @@ else() endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY - JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY + JAVA_JVM_LIBRARY + JAVA_INCLUDE_PATH + JAVA_INCLUDE_PATH2 + JAVA_AWT_INCLUDE_PATH) mark_as_advanced( JAVA_AWT_LIBRARY diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index c643d9b..424ae30 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -8,6 +8,7 @@ # include files and libraries are. The caller may set variable JAVA_HOME # to specify a Java installation prefix explicitly. # +# See also the :module:`FindJNI` module to find Java development tools. # # Specify one or more of the following components as you call this find module. See example below. # @@ -54,8 +55,6 @@ # :: # # Java_FOUND - TRUE if all components are found. -# Java_INCLUDE_DIRS - Full paths to all include dirs. -# Java_LIBRARIES - Full paths to all libraries. # Java_<component>_FOUND - TRUE if <component> is found. # # diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index 4e00a92..f105f3d 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -49,34 +49,37 @@ unset(_lua_include_subdirs) unset(_lua_library_names) +unset(_lua_append_versions) # this is a function only to have all the variables inside go away automatically -function(set_lua_version_vars) +function(_lua_set_version_vars) set(LUA_VERSIONS5 5.3 5.2 5.1 5.0) if (Lua_FIND_VERSION_EXACT) if (Lua_FIND_VERSION_COUNT GREATER 1) - set(lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}) + set(_lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}) endif () elseif (Lua_FIND_VERSION) # once there is a different major version supported this should become a loop if (NOT Lua_FIND_VERSION_MAJOR GREATER 5) if (Lua_FIND_VERSION_COUNT EQUAL 1) - set(lua_append_versions ${LUA_VERSIONS5}) + set(_lua_append_versions ${LUA_VERSIONS5}) else () foreach (subver IN LISTS LUA_VERSIONS5) if (NOT subver VERSION_LESS ${Lua_FIND_VERSION}) - list(APPEND lua_append_versions ${subver}) + list(APPEND _lua_append_versions ${subver}) endif () endforeach () endif () endif () else () # once there is a different major version supported this should become a loop - set(lua_append_versions ${LUA_VERSIONS5}) + set(_lua_append_versions ${LUA_VERSIONS5}) endif () - foreach (ver IN LISTS lua_append_versions) + list(APPEND _lua_include_subdirs "include/lua" "include") + + foreach (ver IN LISTS _lua_append_versions) string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}") list(APPEND _lua_include_subdirs include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2} @@ -93,23 +96,72 @@ function(set_lua_version_vars) set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE) set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE) -endfunction(set_lua_version_vars) + set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE) +endfunction(_lua_set_version_vars) -set_lua_version_vars() +function(_lua_check_header_version _hdr_file) + # At least 5.[012] have different ways to express the version + # so all of them need to be tested. Lua 5.2 defines LUA_VERSION + # and LUA_RELEASE as joined by the C preprocessor, so avoid those. + file(STRINGS "${_hdr_file}" lua_version_strings + REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*") -find_path(LUA_INCLUDE_DIR lua.h - HINTS - ENV LUA_DIR - PATH_SUFFIXES ${_lua_include_subdirs} include/lua include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -) + string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};") + if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$") + string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};") + string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};") + set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}") + else () + string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};") + if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$") + string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};") + endif () + string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}") + endif () + foreach (ver IN LISTS _lua_append_versions) + if (ver STREQUAL "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + set(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR} PARENT_SCOPE) + set(LUA_VERSION_MINOR ${LUA_VERSION_MINOR} PARENT_SCOPE) + set(LUA_VERSION_PATCH ${LUA_VERSION_PATCH} PARENT_SCOPE) + set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE) + return() + endif () + endforeach () +endfunction(_lua_check_header_version) + +_lua_set_version_vars() + +if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") + _lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h") +endif () + +if (NOT LUA_VERSION_STRING) + foreach (subdir IN LISTS _lua_include_subdirs) + unset(LUA_INCLUDE_PREFIX CACHE) + find_path(LUA_INCLUDE_PREFIX ${subdir}/lua.h + HINTS + ENV LUA_DIR + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + if (LUA_INCLUDE_PREFIX) + _lua_check_header_version("${LUA_INCLUDE_PREFIX}/${subdir}/lua.h") + if (LUA_VERSION_STRING) + set(LUA_INCLUDE_DIR "${LUA_INCLUDE_PREFIX}/${subdir}") + break() + endif () + endif () + endforeach () +endif () unset(_lua_include_subdirs) +unset(_lua_append_versions) find_library(LUA_LIBRARY NAMES ${_lua_library_names} lua @@ -137,31 +189,6 @@ if (LUA_LIBRARY) endif () endif () -if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") - # At least 5.[012] have different ways to express the version - # so all of them need to be tested. Lua 5.2 defines LUA_VERSION - # and LUA_RELEASE as joined by the C preprocessor, so avoid those. - file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_strings - REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*") - - string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};") - if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$") - string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};") - string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};") - set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}") - else () - string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};") - if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$") - string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};") - endif () - string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}") - endif () - - unset(lua_version_strings) -endif() - include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index fbc6795..4f78623 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -327,7 +327,7 @@ function (interrogate_mpi_compiler lang try_libs) foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) if (MPI_COMPILE_FLAGS_WORK) - set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") + string(APPEND MPI_COMPILE_FLAGS_WORK " ${FLAG}") else() set(MPI_COMPILE_FLAGS_WORK ${FLAG}) endif() @@ -376,7 +376,7 @@ function (interrogate_mpi_compiler lang try_libs) set(MPI_LINK_FLAGS_WORK) foreach(FLAG ${MPI_ALL_LINK_FLAGS}) if (MPI_LINK_FLAGS_WORK) - set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") + string(APPEND MPI_LINK_FLAGS_WORK " ${FLAG}") else() set(MPI_LINK_FLAGS_WORK ${FLAG}) endif() @@ -398,8 +398,8 @@ function (interrogate_mpi_compiler lang try_libs) # in the showme list that can only be found in the implicit # link directories of the compiler. if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES) - set(MPI_LINK_PATH - "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}") + string(APPEND MPI_LINK_PATH + ";${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}") endif () # Determine full path names for all of the libraries that one needs diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 4d3ed84..feda315 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -4,7 +4,16 @@ # # Try to find OpenCL # -# Once done this will define:: +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if +# OpenCL has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables:: # # OpenCL_FOUND - True if OpenCL was found # OpenCL_INCLUDE_DIRS - include directories for OpenCL @@ -20,7 +29,7 @@ # #============================================================================= -# Copyright 2014 Matthaeus G. Chajdas +# Copyright 2014-2016 Matthaeus G. Chajdas # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -134,3 +143,10 @@ find_package_handle_standard_args( mark_as_advanced( OpenCL_INCLUDE_DIR OpenCL_LIBRARY) + +if(OpenCL_FOUND AND NOT TARGET OpenCL::OpenCL) + add_library(OpenCL::OpenCL UNKNOWN IMPORTED) + set_target_properties(OpenCL::OpenCL PROPERTIES + IMPORTED_LOCATION "${OpenCL_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OpenCL_INCLUDE_DIRS}") +endif() diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index ee4bdd6..a788832 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -12,17 +12,27 @@ # # The following variables are set: # -# :: +# ``OpenMP_C_FLAGS`` +# Flags to add to the C compiler for OpenMP support. +# ``OpenMP_CXX_FLAGS`` +# Flags to add to the CXX compiler for OpenMP support. +# ``OpenMP_Fortran_FLAGS`` +# Flags to add to the Fortran compiler for OpenMP support. +# ``OPENMP_FOUND`` +# True if openmp is detected. # -# OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support -# OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support -# OpenMP_Fortran_FLAGS - flags to add to the Fortran compiler for OpenMP support -# OPENMP_FOUND - true if openmp is detected +# The following internal variables are set, if detected: # +# ``OpenMP_C_SPEC_DATE`` +# Specification date of OpenMP version of C compiler. +# ``OpenMP_CXX_SPEC_DATE`` +# Specification date of OpenMP version of CXX compiler. +# ``OpenMP_Fortran_SPEC_DATE`` +# Specification date of OpenMP version of Fortran compiler. # -# -# Supported compilers can be found at -# http://openmp.org/wp/openmp-compilers/ +# The specification dates are formatted as integers of the form +# ``CCYYMM`` where these represent the decimal digits of the century, +# year, and month. #============================================================================= # Copyright 2009 Kitware, Inc. @@ -122,6 +132,75 @@ set(OpenMP_Fortran_TEST_SOURCE " ) +set(OpenMP_C_CXX_CHECK_VERSION_SOURCE +" +#include <stdio.h> +#include <omp.h> +const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M', + 'P', '-', 'd', 'a', 't', 'e', '[', + ('0' + ((_OPENMP/100000)%10)), + ('0' + ((_OPENMP/10000)%10)), + ('0' + ((_OPENMP/1000)%10)), + ('0' + ((_OPENMP/100)%10)), + ('0' + ((_OPENMP/10)%10)), + ('0' + ((_OPENMP/1)%10)), + ']', '\\0' }; +int main(int argc, char *argv[]) +{ + printf(\"%s\\n\", ompver_str); + return 0; +} +") + +set(OpenMP_Fortran_CHECK_VERSION_SOURCE +" + program omp_ver + use omp_lib + integer, parameter :: zero = ichar('0') + integer, parameter :: ompv = openmp_version + character, dimension(24), parameter :: ompver_str =& + (/ 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M', 'P', '-',& + 'd', 'a', 't', 'e', '[',& + char(zero + mod(ompv/100000, 10)),& + char(zero + mod(ompv/10000, 10)),& + char(zero + mod(ompv/1000, 10)),& + char(zero + mod(ompv/100, 10)),& + char(zero + mod(ompv/10, 10)),& + char(zero + mod(ompv/1, 10)), ']' /) + print *, ompver_str + end program omp_ver +") + +function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) + set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP) + if("${LANG}" STREQUAL "C") + set(SRC_FILE ${WORK_DIR}/ompver.c) + file(WRITE ${SRC_FILE} "${OpenMP_C_CXX_CHECK_VERSION_SOURCE}") + elseif("${LANG}" STREQUAL "CXX") + set(SRC_FILE ${WORK_DIR}/ompver.cpp) + file(WRITE ${SRC_FILE} "${OpenMP_C_CXX_CHECK_VERSION_SOURCE}") + else() # ("${LANG}" STREQUAL "Fortran") + set(SRC_FILE ${WORK_DIR}/ompver.f90) + file(WRITE ${SRC_FILE} "${OpenMP_Fortran_CHECK_VERSION_SOURCE}") + endif() + + set(BIN_FILE ${WORK_DIR}/ompver_${LANG}.bin) + try_compile(OpenMP_TRY_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${SRC_FILE} + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" + COPY_FILE ${BIN_FILE}) + + if(${OpenMP_TRY_COMPILE_RESULT}) + file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") + set(regex_spec_date ".*INFO:OpenMP-date\\[0*([^]]*)\\].*") + if("${specstr}" MATCHES "${regex_spec_date}") + set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE) + endif() + endif() + + unset(OpenMP_TRY_COMPILE_RESULT CACHE) +endfunction() + + # check c compiler if(CMAKE_C_COMPILER_LOADED) # if these are set then do not try to find them again, @@ -153,6 +232,12 @@ if(CMAKE_C_COMPILER_LOADED) list(APPEND _OPENMP_REQUIRED_VARS OpenMP_C_FLAGS) unset(OpenMP_C_FLAG_CANDIDATES) + + if (NOT OpenMP_C_SPEC_DATE) + _OPENMP_GET_SPEC_DATE("C" OpenMP_C_SPEC_DATE_INTERNAL) + set(OpenMP_C_SPEC_DATE "${OpenMP_C_SPEC_DATE_INTERNAL}" CACHE + INTERNAL "C compiler's OpenMP specification date") + endif() endif() # check cxx compiler @@ -189,7 +274,12 @@ if(CMAKE_CXX_COMPILER_LOADED) list(APPEND _OPENMP_REQUIRED_VARS OpenMP_CXX_FLAGS) unset(OpenMP_CXX_FLAG_CANDIDATES) - unset(OpenMP_CXX_TEST_SOURCE) + + if (NOT OpenMP_CXX_SPEC_DATE) + _OPENMP_GET_SPEC_DATE("CXX" OpenMP_CXX_SPEC_DATE_INTERNAL) + set(OpenMP_CXX_SPEC_DATE "${OpenMP_CXX_SPEC_DATE_INTERNAL}" CACHE + INTERNAL "C++ compiler's OpenMP specification date") + endif() endif() # check Fortran compiler @@ -223,7 +313,12 @@ if(CMAKE_Fortran_COMPILER_LOADED) list(APPEND _OPENMP_REQUIRED_VARS OpenMP_Fortran_FLAGS) unset(OpenMP_Fortran_FLAG_CANDIDATES) - unset(OpenMP_Fortran_TEST_SOURCE) + + if (NOT OpenMP_Fortran_SPEC_DATE) + _OPENMP_GET_SPEC_DATE("Fortran" OpenMP_Fortran_SPEC_DATE_INTERNAL) + set(OpenMP_Fortran_SPEC_DATE "${OpenMP_Fortran_SPEC_DATE_INTERNAL}" CACHE + INTERNAL "Fortran compiler's OpenMP specification date") + endif() endif() set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) @@ -240,3 +335,9 @@ if(_OPENMP_REQUIRED_VARS) else() message(SEND_ERROR "FindOpenMP requires C or CXX language to be enabled") endif() + +unset(OpenMP_C_TEST_SOURCE) +unset(OpenMP_CXX_TEST_SOURCE) +unset(OpenMP_Fortran_TEST_SOURCE) +unset(OpenMP_C_CXX_CHECK_VERSION_SOURCE) +unset(OpenMP_Fortran_CHECK_VERSION_SOURCE) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 8dbaf11..6393f2e 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -328,11 +328,11 @@ function(from_hex HEX DEC) set(${DEC} ${_res} PARENT_SCOPE) endfunction() -if (OPENSSL_INCLUDE_DIR) - if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") - file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str - REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") +if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") + file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str + REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") + if(openssl_version_str) # The version number is encoded as 0xMNNFFPPS: major minor fix patch status # The status gives if this is a developer or prerelease and is ignored here. # Major, minor, and fix directly translate into the version numbers shown in diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index 25fff8c..7eab161 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -58,8 +58,8 @@ mark_as_advanced( if(APPLE) # this is a hack for now - set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -Wl,-flat_namespace") + string(APPEND CMAKE_SHARED_MODULE_CREATE_C_FLAGS + " -Wl,-flat_namespace") foreach(symbol __efree __emalloc @@ -82,8 +82,8 @@ if(APPLE) _zend_wrong_param_count _zval_used_for_init ) - set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS},-U,${symbol}") + string(APPEND CMAKE_SHARED_MODULE_CREATE_C_FLAGS + ",-U,${symbol}") endforeach() endif() diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index fe2dbea..96590cb 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -169,10 +169,10 @@ macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) foreach(currentConfigIndex RANGE ${configsCount}) list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - set(configsText "${configsText} ${filename} (version ${version})\n") + string(APPEND configsText " ${filename} (version ${version})\n") endforeach() if (${_NAME}_NOT_FOUND_MESSAGE) - set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") + string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") endif() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") @@ -253,9 +253,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) if(NOT ${_CURRENT_VAR}) set(FPHSA_FOUND_${_NAME} FALSE) - set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") + string(APPEND MISSING_VARS " ${_CURRENT_VAR}") else() - set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") + string(APPEND DETAILS "[${${_CURRENT_VAR}}]") endif() endforeach() if(FPHSA_FOUND_${_NAME}) @@ -277,24 +277,24 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) if(NOT DEFINED FOUND_COMPONENTS_MSG) set(FOUND_COMPONENTS_MSG "found components: ") endif() - set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") + string(APPEND FOUND_COMPONENTS_MSG " ${comp}") else() if(NOT DEFINED MISSING_COMPONENTS_MSG) set(MISSING_COMPONENTS_MSG "missing components: ") endif() - set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") + string(APPEND MISSING_COMPONENTS_MSG " ${comp}") if(${_NAME}_FIND_REQUIRED_${comp}) set(${_NAME}_FOUND FALSE) - set(MISSING_VARS "${MISSING_VARS} ${comp}") + string(APPEND MISSING_VARS " ${comp}") endif() endif() endforeach() set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") + string(APPEND DETAILS "[c${COMPONENT_MSG}]") endif() # version handling: @@ -368,7 +368,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) endif () if(VERSION_OK) - set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + string(APPEND DETAILS "[v${VERSION}(${${_NAME}_FIND_VERSION})]") else() set(${_NAME}_FOUND FALSE) endif() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index b79e9df..b6156dd 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -200,7 +200,7 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat set(_find_opts "NO_CMAKE_PATH") endif() if(_no_cmake_environment_path) - set(_find_opts "${_find_opts} NO_CMAKE_ENVIRONMENT_PATH") + string(APPEND _find_opts " NO_CMAKE_ENVIRONMENT_PATH") endif() foreach (flag IN LISTS ${_prefix}_LDFLAGS) @@ -316,9 +316,13 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") endif() else() - # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties + get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS) + if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) + list(APPEND _lib_dirs "lib32/pkgconfig") + endif() get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) - if(uselib64) + if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND _lib_dirs "lib64/pkgconfig") endif() endif() diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index d05d3da..32a3f0a 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -186,7 +186,7 @@ set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) if(PostgreSQL_FOUND) set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} ) set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} ) - set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) + set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY}) endif() mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY ) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 2807bb9..8a2e4e7 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -148,6 +148,10 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) foreach(FIL ${ARGN}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) + get_filename_component(FIL_DIR ${FIL} DIRECTORY) + if(FIL_DIR) + set(FIL_WE "${FIL_DIR}/${FIL_WE}") + endif() list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") @@ -205,6 +209,10 @@ function(PROTOBUF_GENERATE_PYTHON SRCS) foreach(FIL ${ARGN}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) + get_filename_component(FIL_DIR ${FIL} DIRECTORY) + if(FIL_DIR) + set(FIL_WE "${FIL_DIR}/${FIL_WE}") + endif() list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py") add_custom_command( diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index d167a13..bf41ea1 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -764,7 +764,7 @@ if (QT_QMAKE_EXECUTABLE AND ############################################# cmake_push_check_state() # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") + string(APPEND CMAKE_REQUIRED_INCLUDES ";${QT_INCLUDE_DIR}") set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY}) # Check for Window system symbols (note: only one should end up being set) CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 494d358..b378c34 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -123,7 +123,7 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) # To get multiple single variables to work, I must separate them with a "\;" # I could go back and modify the FindSDL.cmake module, but that's kind of painful. # The solution would be to try something like: - # set(SDL_TRY_COMPILE_LIBRARY_LIST "${SDL_TRY_COMPILE_LIBRARY_LIST}\;${CMAKE_THREAD_LIBS_INIT}") + # string(APPEND SDL_TRY_COMPILE_LIBRARY_LIST "\;${CMAKE_THREAD_LIBS_INIT}") # Instead, it was suggested on the mailing list to write a temporary CMakeLists.txt # with a temporary test project and invoke that with TRY_COMPILE. # See message thread "Figuring out dependencies for a library in order to build" @@ -173,7 +173,7 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) # would fix the problem. set(TMP_TRY_LIBS) foreach(lib ${SDL_SOUND_LIBRARY} ${SDL_LIBRARY}) - set(TMP_TRY_LIBS "${TMP_TRY_LIBS} \"${lib}\"") + string(APPEND TMP_TRY_LIBS " \"${lib}\"") endforeach() # message("TMP_TRY_LIBS ${TMP_TRY_LIBS}") diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake new file mode 100644 index 0000000..b335f5f --- /dev/null +++ b/Modules/FindVulkan.cmake @@ -0,0 +1,85 @@ +#.rst: +# FindVulkan +# ---------- +# +# Try to find Vulkan +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if +# Vulkan has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables:: +# +# Vulkan_FOUND - True if Vulkan was found +# Vulkan_INCLUDE_DIRS - include directories for Vulkan +# Vulkan_LIBRARIES - link against this library to use Vulkan +# +# The module will also define two cache variables:: +# +# Vulkan_INCLUDE_DIR - the Vulkan include directory +# Vulkan_LIBRARY - the path to the Vulkan library +# + +#============================================================================= +# Copyright 2016 Matthaeus G. Chajdas +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(WIN32) + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + PATHS + "$ENV{VULKAN_SDK}/Include" + ) + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + PATHS + "$ENV{VULKAN_SDK}/Bin") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + PATHS + "$ENV{VULKAN_SDK}/Bin32") + endif() +else() + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + PATHS + "$ENV{VULKAN_SDK}/include") + find_library(Vulkan_LIBRARY + NAMES vulkan + PATHS + "$ENV{VULKAN_SDK}/lib") +endif() + +set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) +set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vulkan + DEFAULT_MSG + Vulkan_LIBRARY Vulkan_INCLUDE_DIR) + +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY) + +if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) + add_library(Vulkan::Vulkan UNKNOWN IMPORTED) + set_target_properties(Vulkan::Vulkan PROPERTIES + IMPORTED_LOCATION "${Vulkan_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") +endif() diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index a57f450..f4dc5ae 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -96,7 +96,7 @@ endif() unset(ZLIB_NAMES) unset(ZLIB_NAMES_DEBUG) -mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) +mark_as_advanced(ZLIB_INCLUDE_DIR) if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$") @@ -110,7 +110,7 @@ if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") set(ZLIB_VERSION_TWEAK "") if( "${ZLIB_H}" MATCHES "ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)") set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") - set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}") + string(APPEND ZLIB_VERSION_STRING ".${ZLIB_VERSION_TWEAK}") endif() set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 8c07e6c..2974b9e 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -854,7 +854,7 @@ else() if(_retv EQUAL 0) file(TO_CMAKE_PATH ${_native_path} _native_path) DBG_MSG_V("Path ${_path} converted to ${_native_path}") - set(_tmp_path "${_tmp_path} ${_native_path}") + string(APPEND _tmp_path " ${_native_path}") endif() endforeach() DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}") diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 6e441c3..e405257 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -650,7 +650,7 @@ else() # do we need additionial wx GL stuff like GLCanvas ? if(WXWINDOWS_USE_GL) - set(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS_LIBS} --gl-libs" ) + string(APPEND WX_CONFIG_ARGS_LIBS " --gl-libs" ) endif() ##message("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===") diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index c12dd4c..ae01541 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -270,7 +270,7 @@ function(FortranCInterface_HEADER file) set(_desc_MODULE_ "/* Mangling for Fortran module symbols with underscores. */") foreach(macro GLOBAL GLOBAL_ MODULE MODULE_) if(FortranCInterface_${macro}_MACRO) - set(HEADER_CONTENT "${HEADER_CONTENT} + string(APPEND HEADER_CONTENT " ${_desc_${macro}} #define ${MACRO_NAMESPACE}${macro}${FortranCInterface_${macro}_MACRO} ") @@ -279,7 +279,7 @@ ${_desc_${macro}} # Generate symbol mangling definitions. if(SYMBOLS) - set(HEADER_CONTENT "${HEADER_CONTENT} + string(APPEND HEADER_CONTENT " /*--------------------------------------------------------------------------*/ /* Mangle some symbols automatically. */ ") @@ -300,7 +300,7 @@ ${_desc_${macro}} set(form "") endif() if(FortranCInterface_MODULE${form}_MACRO) - set(HEADER_CONTENT "${HEADER_CONTENT}#define ${SYMBOL_NAMESPACE}${module}_${function} ${MACRO_NAMESPACE}MODULE${form}(${m_lower},${f_lower}, ${m_upper},${f_upper})\n") + string(APPEND HEADER_CONTENT "#define ${SYMBOL_NAMESPACE}${module}_${function} ${MACRO_NAMESPACE}MODULE${form}(${m_lower},${f_lower}, ${m_upper},${f_upper})\n") else() message(AUTHOR_WARNING "No FortranCInterface mangling known for ${f}") endif() @@ -314,7 +314,7 @@ ${_desc_${macro}} string(TOUPPER "${f}" f_upper) string(TOLOWER "${f}" f_lower) if(FortranCInterface_GLOBAL${form}_MACRO) - set(HEADER_CONTENT "${HEADER_CONTENT}#define ${SYMBOL_NAMESPACE}${f} ${MACRO_NAMESPACE}GLOBAL${form}(${f_lower}, ${f_upper})\n") + string(APPEND HEADER_CONTENT "#define ${SYMBOL_NAMESPACE}${f} ${MACRO_NAMESPACE}GLOBAL${form}(${f_lower}, ${f_upper})\n") else() message(AUTHOR_WARNING "No FortranCInterface mangling known for ${f}") endif() diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 6389d30..735a0d7 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -20,6 +20,7 @@ # [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>] # [DEFINE_NO_DEPRECATED] # [PREFIX_NAME <prefix_name>] +# [CUSTOM_CONTENT_FROM_VARIABLE <variable>] # ) # # @@ -60,8 +61,10 @@ # The CMake fragment will generate a file in the # ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the # macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``, -# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. The -# resulting file should be installed with other headers in the library. +# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. +# They will be followed by content taken from the variable specified by +# the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any. +# The resulting file should be installed with other headers in the library. # # The ``BASE_NAME`` argument can be used to override the file name and the # names used for the macros: @@ -78,7 +81,7 @@ # ``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED`` # etc. # -# The ``BASE_NAME`` may be overridden by specifiying other options in the +# The ``BASE_NAME`` may be overridden by specifying other options in the # function. For example: # # .. code-block:: cmake @@ -288,7 +291,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(options DEFINE_NO_DEPRECATED) set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE - NO_DEPRECATED_MACRO_NAME) + NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE) set(multiValueArgs) cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" @@ -361,6 +364,14 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) endif() string(MAKE_C_IDENTIFIER ${EXPORT_IMPORT_CONDITION} EXPORT_IMPORT_CONDITION) + if(_GEH_CUSTOM_CONTENT_FROM_VARIABLE) + if(DEFINED "${_GEH_CUSTOM_CONTENT_FROM_VARIABLE}") + set(CUSTOM_CONTENT "${${_GEH_CUSTOM_CONTENT_FROM_VARIABLE}}") + else() + set(CUSTOM_CONTENT "") + endif() + endif() + configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) endmacro() @@ -404,6 +415,6 @@ function(add_compiler_export_flags) if(ARGC GREATER 0) set(${ARGV0} "${EXTRA_FLAGS}" PARENT_SCOPE) else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) + string(APPEND CMAKE_CXX_FLAGS " ${EXTRA_FLAGS}" PARENT_SCOPE) endif() endfunction() diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index aa5bf28..322cbd3 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -747,7 +747,11 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(gp_regex_fallback "") set(gp_regex_cmp_count 1) # objdump generates copious output so we create a grep filter to pre-filter results - find_program(gp_grep_cmd grep) + if(WIN32) + find_program(gp_grep_cmd findstr) + else() + find_program(gp_grep_cmd grep) + endif() if(gp_grep_cmd) set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "^[[:blank:]]*DLL Name: ") endif() @@ -792,7 +796,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(old_ld_env "$ENV{LD_LIBRARY_PATH}") set(new_ld_env "${exepath}") foreach(dir ${dirs}) - set(new_ld_env "${new_ld_env}:${dir}") + string(APPEND new_ld_env ":${dir}") endforeach() set(ENV{LD_LIBRARY_PATH} "${new_ld_env}:$ENV{LD_LIBRARY_PATH}") endif() diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake index 77b7afe..0ef4c3e 100644 --- a/Modules/MatlabTestsRedirect.cmake +++ b/Modules/MatlabTestsRedirect.cmake @@ -46,7 +46,7 @@ get_filename_component(unittest_file_to_run_name "${unittest_file_to_run}" NAME_ set(concat_string '${unittest_file_directory}') foreach(s IN LISTS additional_paths) if(NOT "${s}" STREQUAL "") - set(concat_string "${concat_string}, '${s}'") + string(APPEND concat_string ", '${s}'") endif() endforeach() diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 92a3142..c66a89b 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -157,13 +157,6 @@ Var AR_RegFlags !define MUI_HEADERIMAGE !define MUI_ABORTWARNING -;-------------------------------- -; path functions - -!verbose 3 -!include "WinMessages.NSH" -!verbose 4 - ;---------------------------------------- ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" ;---------------------------------------- diff --git a/Modules/Platform/AIX-Clang-C.cmake b/Modules/Platform/AIX-Clang-C.cmake new file mode 100644 index 0000000..0e8a1c0 --- /dev/null +++ b/Modules/Platform/AIX-Clang-C.cmake @@ -0,0 +1 @@ +include(Platform/AIX-GNU-C) diff --git a/Modules/Platform/AIX-Clang-CXX.cmake b/Modules/Platform/AIX-Clang-CXX.cmake new file mode 100644 index 0000000..6b9110e --- /dev/null +++ b/Modules/Platform/AIX-Clang-CXX.cmake @@ -0,0 +1 @@ +include(Platform/AIX-GNU-CXX) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index d6f5331..df97ab1 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -21,9 +21,9 @@ set(__AIX_COMPILER_GNU 1) # # By default, runtime linking is enabled. All shared objects specified on the command line # will be listed, even if there are no symbols referenced, in the output file. -set (CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-brtl") -set (CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,-brtl") -set (CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-brtl") +string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl") +string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl") +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl") macro(__aix_compiler_gnu lang) diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 5470441..3be095e 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -21,9 +21,9 @@ set(__AIX_COMPILER_XL 1) # # By default, runtime linking is enabled. All shared objects specified on the command line # will be listed, even if there are no symbols referenced, in the output file. -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-brtl") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,-brtl") -set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-brtl") +string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl") +string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl") +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl") macro(__aix_compiler_xl lang) diff --git a/Modules/Platform/ARTOS-GNU-C.cmake b/Modules/Platform/ARTOS-GNU-C.cmake index 967d0e7..fe8d782 100644 --- a/Modules/Platform/ARTOS-GNU-C.cmake +++ b/Modules/Platform/ARTOS-GNU-C.cmake @@ -1,9 +1,9 @@ # Define ARTOS to select proper behaviour and tell preprocessor to accept C++ style comments. -set(CMAKE_C_FLAGS_INIT "-DARTOS -Xp -+") +string(APPEND CMAKE_C_FLAGS_INIT " -DARTOS -Xp -+") # ac doesn't support -g properly and doesn't support the normal gcc optimization options. Just use the defaults set by ac. -set(CMAKE_C_FLAGS_DEBUG_INIT "") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-DNDEBUG") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") # Most projects expect the stdio functions to be available. set(CMAKE_C_STANDARD_LIBRARIES_INIT "stdio.a") diff --git a/Modules/Platform/BlueGeneQ-base.cmake b/Modules/Platform/BlueGeneQ-base.cmake index 9372166..dc066b7 100644 --- a/Modules/Platform/BlueGeneQ-base.cmake +++ b/Modules/Platform/BlueGeneQ-base.cmake @@ -110,7 +110,7 @@ macro(__BlueGeneQ_common_setup compiler_id lang) # to do the same thing as the MPI compilers, which add these flags. set(BGQ_SYSTEM_INCLUDES "") foreach(dir ${CMAKE_SYSTEM_INCLUDE_PATH}) - set(BGQ_SYSTEM_INCLUDES "${BGQ_SYSTEM_INCLUDES} -I${dir}") + string(APPEND BGQ_SYSTEM_INCLUDES " -I${dir}") endforeach() set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Platform/Windows-CXX.cmake b/Modules/Platform/CYGWIN-Determine-CXX.cmake index bf37f79..bf37f79 100644 --- a/Modules/Platform/Windows-CXX.cmake +++ b/Modules/Platform/CYGWIN-Determine-CXX.cmake diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 1a46c10..5090c08 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -19,7 +19,7 @@ endif() set(__CYGWIN_COMPILER_GNU 1) # TODO: Is -Wl,--enable-auto-import now always default? -set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--enable-auto-import") +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,--enable-auto-import") set(CMAKE_CREATE_WIN32_EXE "-mwindows") set(CMAKE_GNULD_IMAGE_VERSION diff --git a/Modules/Platform/Darwin-CXX.cmake b/Modules/Platform/Darwin-Determine-CXX.cmake index bf37f79..bf37f79 100644 --- a/Modules/Platform/Darwin-CXX.cmake +++ b/Modules/Platform/Darwin-Determine-CXX.cmake diff --git a/Modules/Platform/Generic-ADSP-C.cmake b/Modules/Platform/Generic-ADSP-C.cmake index 4b9ed9d..de1cee2 100644 --- a/Modules/Platform/Generic-ADSP-C.cmake +++ b/Modules/Platform/Generic-ADSP-C.cmake @@ -4,10 +4,10 @@ include(Platform/Generic-ADSP-Common) set(CMAKE_C_OUTPUT_EXTENSION ".doj") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "") -set(CMAKE_C_FLAGS_RELEASE_INIT "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " ") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " ") set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_C_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_C_LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Platform/Generic-ADSP-CXX.cmake b/Modules/Platform/Generic-ADSP-CXX.cmake index 9673aef..0cde8f2 100644 --- a/Modules/Platform/Generic-ADSP-CXX.cmake +++ b/Modules/Platform/Generic-ADSP-CXX.cmake @@ -2,10 +2,10 @@ include(Platform/Generic-ADSP-Common) set(CMAKE_CXX_OUTPUT_EXTENSION ".doj") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " ") set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_CXX_LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake index a1ca812..bbefe19 100644 --- a/Modules/Platform/Generic-SDCC-C.cmake +++ b/Modules/Platform/Generic-SDCC-C.cmake @@ -30,7 +30,7 @@ set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) # CMAKE_C_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_INIT should be set in a CMAKE_SYSTEM_PROCESSOR file if(NOT DEFINED CMAKE_C_FLAGS_INIT) - set(CMAKE_C_FLAGS_INIT "-mmcs51 --model-small") + string(APPEND CMAKE_C_FLAGS_INIT " -mmcs51 --model-small") endif() if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT) diff --git a/Modules/Platform/HP-UX-HP-CXX.cmake b/Modules/Platform/HP-UX-HP-CXX.cmake index 6d90191..d37d2b0 100644 --- a/Modules/Platform/HP-UX-HP-CXX.cmake +++ b/Modules/Platform/HP-UX-HP-CXX.cmake @@ -8,7 +8,7 @@ set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "rm -f `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.o" ) -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "+O3 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "+O2 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " +O3 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " +O2 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g") diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake index 3935c31..398d6fb 100644 --- a/Modules/Platform/HP-UX-HP.cmake +++ b/Modules/Platform/HP-UX-HP.cmake @@ -27,7 +27,7 @@ macro(__hpux_compiler_hp lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h") - set(CMAKE_${lang}_FLAGS_INIT "") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") set(CMAKE_${lang}_LINK_FLAGS "-Wl,+s,+nodefaultrpath") endmacro() diff --git a/Modules/Platform/Linux-CXX.cmake b/Modules/Platform/Linux-Determine-CXX.cmake index b594dae..b594dae 100644 --- a/Modules/Platform/Linux-CXX.cmake +++ b/Modules/Platform/Linux-Determine-CXX.cmake diff --git a/Modules/Platform/Linux-Intel-Fortran.cmake b/Modules/Platform/Linux-Intel-Fortran.cmake index 0c9523c..d8e94d0 100644 --- a/Modules/Platform/Linux-Intel-Fortran.cmake +++ b/Modules/Platform/Linux-Intel-Fortran.cmake @@ -1,4 +1,4 @@ include(Platform/Linux-Intel) __linux_compiler_intel(Fortran) -set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -nofor_main") +string(APPEND CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS " -nofor_main") set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index e40a74f..1f8c1b4 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -50,8 +50,9 @@ set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_ include(Platform/UnixPaths) -# Debian has lib64 paths only for compatibility so they should not be +# Debian has lib32 and lib64 paths only for compatibility so they should not be # searched. if(NOT CMAKE_CROSSCOMPILING AND EXISTS "/etc/debian_version") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) endif() diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 7ac6c7e..6466a0a 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -18,6 +18,7 @@ endif() set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) # OpenBSD has no multilib +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) # OpenBSD policy requires that shared libraries be installed without diff --git a/Modules/Platform/SCO_SV.cmake b/Modules/Platform/SCO_SV.cmake index ddd9600..1cb4b38 100644 --- a/Modules/Platform/SCO_SV.cmake +++ b/Modules/Platform/SCO_SV.cmake @@ -1,2 +1,3 @@ set(CMAKE_DL_LIBS "") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h,") include(Platform/UnixPaths) diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 20ee1d1..d6c3d41 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -93,5 +93,6 @@ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES /usr/include ) -# Enable use of lib64 search path variants by default. +# Enable use of lib32 and lib64 search path variants by default. +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) diff --git a/Modules/Platform/CYGWIN-CXX.cmake b/Modules/Platform/Windows-Determine-CXX.cmake index bf37f79..bf37f79 100644 --- a/Modules/Platform/CYGWIN-CXX.cmake +++ b/Modules/Platform/Windows-Determine-CXX.cmake diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 102e3a6..43ae2a3 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -64,15 +64,11 @@ set(CMAKE_CREATE_CONSOLE_EXE "${_tC}" ) set (CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") -set (CMAKE_EXE_LINKER_FLAGS_INIT "${_tM} -lS:1048576 -lSc:4098 -lH:1048576 -lHc:8192 ") -set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "-v") -set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-v") -set (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT}) +foreach(t EXE SHARED MODULE) + string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_tM} -lS:1048576 -lSc:4098 -lH:1048576 -lHc:8192 ") + string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " -v") + string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " -v") +endforeach() # The Borland link tool does not support multiple concurrent # invocations within a single working directory. @@ -132,10 +128,10 @@ macro(__embarcadero_language lang) ) # Initial configuration flags. - set(CMAKE_${lang}_FLAGS_INIT "${_tM}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-Od -v") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O1 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-Od") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Od") set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib") endmacro() diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake index 1b93db8..3981a09 100644 --- a/Modules/Platform/Windows-Intel-Fortran.cmake +++ b/Modules/Platform/Windows-Intel-Fortran.cmake @@ -4,8 +4,8 @@ set(_COMPILE_Fortran " /fpp") set(CMAKE_Fortran_MODDIR_FLAG "-module:") set(CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib") __windows_compiler_intel(Fortran) -set (CMAKE_Fortran_FLAGS_INIT "/W1 /nologo /fpp /libs:dll /threads") -set (CMAKE_Fortran_FLAGS_DEBUG_INIT "/Od /debug:full /dbglibs") -set (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O1 /DNDEBUG") -set (CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2 /DNDEBUG") -set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /debug:full /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1 /nologo /fpp /libs:dll /threads") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full /dbglibs") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " /O1 /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " /O2 /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " /O2 /debug:full /DNDEBUG") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 6c254ed..723c69e 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -166,10 +166,12 @@ if(WINCE) endforeach() set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") - set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") + foreach(t EXE SHARED MODULE) + string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") + endforeach() if (MSVC_VERSION LESS 1600) - set(CMAKE_C_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT} corelibc.lib") + string(APPEND CMAKE_C_STANDARD_LIBRARIES_INIT " corelibc.lib") endif () elseif(WINDOWS_PHONE OR WINDOWS_STORE) set(_PLATFORM_DEFINES "/DWIN32") @@ -235,9 +237,6 @@ elseif(MSVC_CXX_ARCHITECTURE_ID) elseif(MSVC_Fortran_ARCHITECTURE_ID) set(_MACHINE_ARCH_FLAG "/machine:${MSVC_Fortran_ARCHITECTURE_ID}") endif() -set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} ${_MACHINE_ARCH_FLAG}") -set(CMAKE_STATIC_LINKER_FLAGS_INIT "${CMAKE_STATIC_LINKER_FLAGS_INIT} ${_MACHINE_ARCH_FLAG}") -unset(_MACHINE_ARCH_FLAG) # add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype # on versions that support it @@ -250,30 +249,22 @@ if(NOT WINDOWS_PHONE AND NOT WINDOWS_STORE) endif() endif() -if (CMAKE_COMPILER_SUPPORTS_PDBTYPE) - set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") -else () - set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") -endif () -# for release and minsize release default to no incremental linking -set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT "/INCREMENTAL:NO") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:NO") - -# copy the EXE_LINKER flags to SHARED and MODULE linker flags -# shared linker flags -set (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) -# module linker flags -set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) +foreach(t EXE SHARED MODULE) + string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}") + if (CMAKE_COMPILER_SUPPORTS_PDBTYPE) + string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " /debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") + string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " /debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") + else () + string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " /debug ${MSVC_INCREMENTAL_YES_FLAG}") + string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " /debug ${MSVC_INCREMENTAL_YES_FLAG}") + endif () + # for release and minsize release default to no incremental linking + string(APPEND CMAKE_${t}_LINKER_FLAGS_MINSIZEREL_INIT " /INCREMENTAL:NO") + string(APPEND CMAKE_${t}_LINKER_FLAGS_RELEASE_INIT " /INCREMENTAL:NO") +endforeach() + +string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}") +unset(_MACHINE_ARCH_FLAG) macro(__windows_compiler_msvc lang) if(NOT MSVC_VERSION LESS 1400) @@ -298,20 +289,23 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") - if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") - # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects - # that include MS's own headers. CMake itself is affected project too. - set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD -O2 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD -gline-tables-only -O2 -fno-inline -DNDEBUG") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang - else() - set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /DNDEBUG") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /DNDEBUG") + if("x${lang}" STREQUAL "xC" OR + "x${lang}" STREQUAL "xCXX") + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") + # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects + # that include MS's own headers. CMake itself is affected project too. + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD -O2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD -gline-tables-only -O2 -fno-inline -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang + else() + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD /O2 /Ob2 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD /Zi /O2 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG") + endif() endif() set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) set(CMAKE_NINJA_DEPTYPE_${lang} msvc) @@ -320,7 +314,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_RC_COMPILER_INIT rc) endif() if(NOT CMAKE_RC_FLAGS_INIT) - set(CMAKE_RC_FLAGS_INIT "${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}") + string(APPEND CMAKE_RC_FLAGS_INIT " ${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}") endif() enable_language(RC) diff --git a/Modules/Platform/Windows-OpenWatcom-C.cmake b/Modules/Platform/Windows-OpenWatcom-C.cmake new file mode 100644 index 0000000..ce9bc45 --- /dev/null +++ b/Modules/Platform/Windows-OpenWatcom-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom) diff --git a/Modules/Platform/Windows-OpenWatcom-CXX.cmake b/Modules/Platform/Windows-OpenWatcom-CXX.cmake new file mode 100644 index 0000000..ce9bc45 --- /dev/null +++ b/Modules/Platform/Windows-OpenWatcom-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-OpenWatcom.cmake index 3bc5444..7419fe4 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-OpenWatcom.cmake @@ -1,3 +1,23 @@ + +#============================================================================= +# Copyright 2002-2016 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__WINDOWS_OPENWATCOM) + return() +endif() +set(__WINDOWS_OPENWATCOM 1) + set(CMAKE_LIBRARY_PATH_FLAG "libpath ") set(CMAKE_LINK_LIBRARY_FLAG "library ") set(CMAKE_LINK_LIBRARY_FILE_FLAG "library") @@ -12,14 +32,14 @@ else() set(CMAKE_LIB_QUIET "-q") endif() -set(CMAKE_EXE_LINKER_FLAGS_INIT) +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ") set(CMAKE_CREATE_WIN32_EXE "system nt_win" ) set(CMAKE_CREATE_CONSOLE_EXE "system nt" ) -set(CMAKE_SHARED_LINKER_FLAGS_INIT "system nt_dll") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "system nt_dll") +string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system nt_dll") +string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system nt_dll") foreach(type SHARED MODULE EXE) - set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map") - set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map") + string(APPEND CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT " debug all opt map") + string(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT " debug all opt map") endforeach() set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list @@ -32,13 +52,13 @@ set(CMAKE_BUILD_TYPE_INIT Debug) # single/multi-threaded /-bm # static/DLL run-time libraries /-br # default is setup for multi-threaded + DLL run-time libraries -set (CMAKE_C_FLAGS_INIT "-bt=nt -w3 -dWIN32 -br -bm") -set (CMAKE_CXX_FLAGS_INIT "-bt=nt -xs -w3 -dWIN32 -br -bm") +string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -w3 -dWIN32 -br -bm") +string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -w3 -dWIN32 -br -bm") foreach(lang C CXX) - set (CMAKE_${lang}_FLAGS_DEBUG_INIT "-d2") - set (CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-s -os -d0 -dNDEBUG") - set (CMAKE_${lang}_FLAGS_RELEASE_INIT "-s -ot -d0 -dNDEBUG") - set (CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-s -ot -d1 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -d2") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -s -os -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -s -ot -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -s -ot -d1 -dNDEBUG") endforeach() foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) diff --git a/Modules/Platform/Windows-Watcom-C.cmake b/Modules/Platform/Windows-Watcom-C.cmake new file mode 100644 index 0000000..44a008b --- /dev/null +++ b/Modules/Platform/Windows-Watcom-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom-C) diff --git a/Modules/Platform/Windows-Watcom-CXX.cmake b/Modules/Platform/Windows-Watcom-CXX.cmake new file mode 100644 index 0000000..63d109b --- /dev/null +++ b/Modules/Platform/Windows-Watcom-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom-CXX) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 3b0a6cc..4b066b74 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -441,14 +441,14 @@ macro(QT4_CREATE_TRANSLATION _qm_files) set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro) set(_pro_srcs) foreach(_pro_src ${_my_sources}) - set(_pro_srcs "${_pro_srcs} \\\n \"${_pro_src}\"") + string(APPEND _pro_srcs " \\\n \"${_pro_src}\"") endforeach() set(_pro_includes) get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES) list(REMOVE_DUPLICATES _inc_DIRS) foreach(_pro_include ${_inc_DIRS}) get_filename_component(_abs_include "${_pro_include}" ABSOLUTE) - set(_pro_includes "${_pro_includes} \\\n \"${_abs_include}\"") + string(APPEND _pro_includes " \\\n \"${_abs_include}\"") endforeach() file(WRITE ${_ts_pro} "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n") endif() diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 7b3416e..f4b5e52 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -217,6 +217,19 @@ # This command installs the TARGET_NAME files to the given DESTINATION. # It should be called in the same scope as add_jar() or it will fail. # +# Target Properties: +# +# :: +# +# The install_jar() function sets the INSTALL_DESTINATION target property +# on jars so installed. This property holds the DESTINATION as described +# above, and is used by install_jar_exports(). You can get this property +# with the +# get_property(TARGET <target_name> PROPERTY INSTALL_DESTINATION) +# command. +# +# +# # :: # # install_jni_symlink(target_name destination) @@ -228,6 +241,24 @@ # # :: # +# install_jar_exports(TARGETS jar1 [jar2 ...] +# FILE export_filename +# DESTINATION destination [COMPONENT component]) +# +# This command installs a target export file export_filename for the named jar +# targets to the given DESTINATION. Its function is similar to that of +# install(EXPORTS). +# +# :: +# +# export_jars(TARGETS jar1 [jar2 ...] +# FILE export_filename) +# +# This command writes a target export file export_filename for the named jar +# targets. Its function is similar to that of export(). +# +# :: +# # create_javadoc(<VAR> # PACKAGES pkg1 [pkg2 ...] # [SOURCEPATH <sourcepath>] @@ -396,7 +427,29 @@ function (__java_copy_file src dest comment) COMMENT ${comment}) endfunction () +function(__java_lcat VAR) + foreach(_line ${ARGN}) + set(${VAR} "${${VAR}}${_line}\n") + endforeach() + + set(${VAR} "${${VAR}}" PARENT_SCOPE) +endfunction() + +function(__java_export_jar VAR TARGET PATH) + get_target_property(_jarpath ${TARGET} JAR_FILE) + get_filename_component(_jarname ${_jarpath} NAME) + __java_lcat(${VAR} + "# Create imported target ${TARGET}" + "add_custom_target(${TARGET})" + "set_target_properties(${TARGET} PROPERTIES" + " JAR_FILE \"${PATH}/${_jarname}\")" + "" + ) + set(${VAR} "${${VAR}}" PARENT_SCOPE) +endfunction() + # define helper scripts +set(_JAVA_EXPORT_TARGETS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/javaTargets.cmake.in) set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake) set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) @@ -435,6 +488,8 @@ function(add_jar _TARGET_NAME) if (NOT DEFINED _add_jar_OUTPUT_DIR) set(_add_jar_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + else() + get_filename_component(_add_jar_OUTPUT_DIR ${_add_jar_OUTPUT_DIR} ABSOLUTE) endif() if (_add_jar_ENTRY_POINT) @@ -467,7 +522,7 @@ function(add_jar _TARGET_NAME) endif() foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH}) - set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") endforeach() set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${_add_jar_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") @@ -539,7 +594,7 @@ function(add_jar _TARGET_NAME) if (TARGET ${_JAVA_INCLUDE_JAR}) get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE) if (_JAVA_JAR_PATH) - set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}") list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH}) list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR}) list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR}) @@ -547,18 +602,13 @@ function(add_jar _TARGET_NAME) message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar") endif () else () - set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}") list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}") list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}") list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}") endif () endforeach() - # create an empty java_class_filelist - if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist) - file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") - endif() - if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS) set (_JAVA_SOURCES_FILELISTS) @@ -598,6 +648,11 @@ function(add_jar _TARGET_NAME) DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + else () + # create an empty java_class_filelist + if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist) + file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") + endif() endif () # create the jar file @@ -716,6 +771,13 @@ function(INSTALL_JAR _TARGET_NAME) PROPERTY INSTALL_FILES ) + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + INSTALL_DESTINATION + ${_DESTINATION} + ) if (__FILES) install( @@ -1288,3 +1350,94 @@ function (create_javah) set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) endif() endfunction() + +function(export_jars) + # Parse and validate arguments + cmake_parse_arguments(_export_jars + "" + "FILE" + "TARGETS" + ${ARGN} + ) + if (NOT _export_jars_FILE) + message(SEND_ERROR "export_jars: FILE must be specified.") + endif() + if (NOT _export_jars_TARGETS) + message(SEND_ERROR "export_jars: TARGETS must be specified.") + endif() + + # Set content of generated exports file + string(REPLACE ";" " " __targets__ "${_export_jars_TARGETS}") + set(__targetdefs__ "") + foreach(_target ${_export_jars_TARGETS}) + get_target_property(_jarpath ${_target} JAR_FILE) + get_filename_component(_jarpath ${_jarpath} PATH) + __java_export_jar(__targetdefs__ ${_target} "${_jarpath}") + endforeach() + + # Generate exports file + configure_file( + ${_JAVA_EXPORT_TARGETS_SCRIPT} + ${_export_jars_FILE} + @ONLY + ) +endfunction() + +function(install_jar_exports) + # Parse and validate arguments + cmake_parse_arguments(_install_jar_exports + "" + "FILE;DESTINATION;COMPONENT" + "TARGETS" + ${ARGN} + ) + if (NOT _install_jar_exports_FILE) + message(SEND_ERROR "install_jar_exports: FILE must be specified.") + endif() + if (NOT _install_jar_exports_DESTINATION) + message(SEND_ERROR "install_jar_exports: DESTINATION must be specified.") + endif() + if (NOT _install_jar_exports_TARGETS) + message(SEND_ERROR "install_jar_exports: TARGETS must be specified.") + endif() + + if (_install_jar_exports_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jar_exports_COMPONENT}) + endif() + + # Determine relative path from installed export file to install prefix + if(IS_ABSOLUTE ${_install_jar_exports_DESTINATION}) + file(RELATIVE_PATH _relpath + ${_install_jar_exports_DESTINATION} + ${CMAKE_INSTALL_PREFIX} + ) + else() + file(RELATIVE_PATH _relpath + ${CMAKE_INSTALL_PREFIX}/${_install_jar_exports_DESTINATION} + ${CMAKE_INSTALL_PREFIX} + ) + endif() + + # Set up unique location for generated exports file + string(SHA256 _hash "${_install_jar_exports_DESTINATION}") + set(_tmpdir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/JavaExports/${_hash}) + + # Set content of generated exports file + string(REPLACE ";" " " __targets__ "${_install_jar_exports_TARGETS}") + set(__targetdefs__ "set(_prefix \${CMAKE_CURRENT_LIST_DIR}/${_relpath})\n\n") + foreach(_target ${_install_jar_exports_TARGETS}) + get_target_property(_dir ${_target} INSTALL_DESTINATION) + __java_export_jar(__targetdefs__ ${_target} "\${_prefix}/${_dir}") + endforeach() + __java_lcat(__targetdefs__ "\nunset(_prefix)") + + # Generate and install exports file + configure_file( + ${_JAVA_EXPORT_TARGETS_SCRIPT} + ${_tmpdir}/${_install_jar_exports_FILE} + @ONLY + ) + install(FILES ${_tmpdir}/${_install_jar_exports_FILE} + DESTINATION ${_install_jar_exports_DESTINATION} + ${_COMPONENT}) +endfunction() diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index d757f65..2631ca1 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -163,15 +163,15 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) "${swig_outdir}/${swig_source_file_name_we}") # add the language into the name of the file (i.e. TCL_wrap) # this allows for the same .i file to be wrapped into different languages - set(swig_generated_file_fullname - "${swig_generated_file_fullname}${SWIG_MODULE_${name}_LANGUAGE}_wrap") + string(APPEND swig_generated_file_fullname + "${SWIG_MODULE_${name}_LANGUAGE}_wrap") if(swig_source_file_cplusplus) - set(swig_generated_file_fullname - "${swig_generated_file_fullname}.${SWIG_CXX_EXTENSION}") + string(APPEND swig_generated_file_fullname + ".${SWIG_CXX_EXTENSION}") else() - set(swig_generated_file_fullname - "${swig_generated_file_fullname}.c") + string(APPEND swig_generated_file_fullname + ".c") endif() #message("Full path to source file: ${swig_source_file_fullname}") diff --git a/Modules/Use_wxWindows.cmake b/Modules/Use_wxWindows.cmake index d3025ac..597b4ec 100644 --- a/Modules/Use_wxWindows.cmake +++ b/Modules/Use_wxWindows.cmake @@ -68,7 +68,7 @@ if(WXWINDOWS_FOUND) link_libraries(${WXWINDOWS_LIBRARIES}) endif() if (CMAKE_WXWINDOWS_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_WXWINDOWS_CXX_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_WXWINDOWS_CXX_FLAGS}") endif() if(WXWINDOWS_DEFINITIONS) add_definitions(${WXWINDOWS_DEFINITIONS}) diff --git a/Modules/UsewxWidgets.cmake b/Modules/UsewxWidgets.cmake index b3633a6..4d16482 100644 --- a/Modules/UsewxWidgets.cmake +++ b/Modules/UsewxWidgets.cmake @@ -90,7 +90,7 @@ if (wxWidgets_FOUND) if (wxWidgets_CXX_FLAGS) # Flags are expected to be a string here, not a list. string(REPLACE ";" " " wxWidgets_CXX_FLAGS_str "${wxWidgets_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS_str}") + string(APPEND CMAKE_CXX_FLAGS " ${wxWidgets_CXX_FLAGS_str}") MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS_str}") unset(wxWidgets_CXX_FLAGS_str) endif() diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 2669a84..4b829e5 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -282,9 +282,9 @@ function(write_compiler_detection_header set(_min_version 3.1.0) # Version which introduced this function if (_WCD_VERSION VERSION_LESS _min_version) set(err "VERSION compatibility for write_compiler_detection_header is set to ${_WCD_VERSION}, which is too low.") - set(err "${err} It must be set to at least ${_min_version}. ") - set(err "${err} Either set the VERSION parameter to the write_compiler_detection_header function, or update") - set(err "${err} your minimum required CMake version with the cmake_minimum_required command.") + string(APPEND err " It must be set to at least ${_min_version}. ") + string(APPEND err " Either set the VERSION parameter to the write_compiler_detection_header function, or update") + string(APPEND err " your minimum required CMake version with the cmake_minimum_required command.") message(FATAL_ERROR "${err}") endif() @@ -349,11 +349,11 @@ function(write_compiler_detection_header ") if (_WCD_PROLOG) - set(file_content "${file_content}\n${_WCD_PROLOG}\n") + string(APPEND file_content "\n${_WCD_PROLOG}\n") endif() if (_need_hex_conversion) - set(file_content "${file_content} + string(APPEND file_content " #define ${prefix_arg}_DEC(X) (X) #define ${prefix_arg}_HEX(X) ( \\ ((X)>>28 & 0xF) * 10000000 + \\ @@ -406,24 +406,24 @@ function(write_compiler_detection_header endforeach() if(_lang STREQUAL CXX) - set(file_content "${file_content}\n#ifdef __cplusplus\n") + string(APPEND file_content "\n#ifdef __cplusplus\n") else() - set(file_content "${file_content}\n#ifndef __cplusplus\n") + string(APPEND file_content "\n#ifndef __cplusplus\n") endif() compiler_id_detection(ID_CONTENT ${_lang} PREFIX ${prefix_arg}_ ID_DEFINE ) - set(file_content "${file_content}${ID_CONTENT}\n") + string(APPEND file_content "${ID_CONTENT}\n") set(pp_if "if") foreach(compiler ${target_compilers}) - set(file_content "${file_content}\n# ${pp_if} ${prefix_arg}_COMPILER_IS_${compiler}\n") + string(APPEND file_content "\n# ${pp_if} ${prefix_arg}_COMPILER_IS_${compiler}\n") if(_WCD_OUTPUT_FILES_VAR) set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}_${_lang}.h") - set(file_content "${file_content}\n# include \"${compile_file_name}\"\n") + string(APPEND file_content "\n# include \"${compile_file_name}\"\n") endif() if(_WCD_OUTPUT_FILES_VAR) @@ -466,7 +466,7 @@ function(write_compiler_detection_header endforeach() endforeach() if(pp_if STREQUAL "elif") - set(file_content "${file_content} + string(APPEND file_content " # else # error Unsupported compiler # endif\n") @@ -477,7 +477,7 @@ function(write_compiler_detection_header set(def_name ${prefix_arg}_${feature_PP}) if (feature STREQUAL c_restrict) set(def_value "${prefix_arg}_RESTRICT") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} restrict # else @@ -487,7 +487,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_constexpr) set(def_value "${prefix_arg}_CONSTEXPR") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} constexpr # else @@ -497,7 +497,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_final) set(def_value "${prefix_arg}_FINAL") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} final # else @@ -507,7 +507,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_override) set(def_value "${prefix_arg}_OVERRIDE") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} override # else @@ -521,11 +521,11 @@ function(write_compiler_detection_header set(static_assert_struct "template<bool> struct ${prefix_arg}StaticAssert;\ntemplate<> struct ${prefix_arg}StaticAssert<true>{};\n") set(def_standard "# define ${def_value} static_assert(X, #X)\n# define ${def_value_msg} static_assert(X, MSG)") set(def_alternative "${static_assert_struct}# define ${def_value} sizeof(${prefix_arg}StaticAssert<X>)\n# define ${def_value_msg} sizeof(${prefix_arg}StaticAssert<X>)") - set(file_content "${file_content}# if ${def_name}\n${def_standard}\n# else\n${def_alternative}\n# endif\n\n") + string(APPEND file_content "# if ${def_name}\n${def_standard}\n# else\n${def_alternative}\n# endif\n\n") endif() if (feature STREQUAL cxx_alignas) set(def_value "${prefix_arg}_ALIGNAS(X)") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} alignas(X) # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang @@ -539,7 +539,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_alignof) set(def_value "${prefix_arg}_ALIGNOF(X)") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} alignof(X) # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang @@ -551,7 +551,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_deleted_functions) set(def_value "${prefix_arg}_DELETED_FUNCTION") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} = delete # else @@ -561,7 +561,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_extern_templates) set(def_value "${prefix_arg}_EXTERN_TEMPLATE") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} extern # else @@ -571,7 +571,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_noexcept) set(def_value "${prefix_arg}_NOEXCEPT") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} noexcept # define ${def_value}_EXPR(X) noexcept(X) @@ -583,7 +583,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_nullptr) set(def_value "${prefix_arg}_NULLPTR") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} nullptr # else @@ -593,7 +593,7 @@ function(write_compiler_detection_header endif() if (feature STREQUAL cxx_thread_local) set(def_value "${prefix_arg}_THREAD_LOCAL") - set(file_content "${file_content} + string(APPEND file_content " # if ${def_name} # define ${def_value} thread_local # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang @@ -608,7 +608,7 @@ function(write_compiler_detection_header if (feature STREQUAL cxx_attribute_deprecated) set(def_name ${prefix_arg}_${feature_PP}) set(def_value "${prefix_arg}_DEPRECATED") - set(file_content "${file_content} + string(APPEND file_content " # ifndef ${def_value} # if ${def_name} # define ${def_value} [[deprecated]] @@ -628,7 +628,7 @@ function(write_compiler_detection_header endif() endforeach() - set(file_content "${file_content}#endif\n") + string(APPEND file_content "#endif\n") endforeach() @@ -637,7 +637,7 @@ function(write_compiler_detection_header foreach(_lang ${_langs}) if(compiler_file_content_${compiler}_${_lang}) set(CMAKE_CONFIGURABLE_FILE_CONTENT "${compiler_file_content_}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CMAKE_CONFIGURABLE_FILE_CONTENT}${compiler_file_content_${compiler}_${_lang}}") + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "${compiler_file_content_${compiler}_${_lang}}") set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}_${_lang}.h") set(full_path "${main_file_dir}/${compile_file_name}") @@ -653,9 +653,9 @@ function(write_compiler_detection_header endif() if (_WCD_EPILOG) - set(file_content "${file_content}\n${_WCD_EPILOG}\n") + string(APPEND file_content "\n${_WCD_EPILOG}\n") endif() - set(file_content "${file_content}\n#endif") + string(APPEND file_content "\n#endif") set(CMAKE_CONFIGURABLE_FILE_CONTENT ${file_content}) configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 7cfbcbd..9dd75bf 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -38,5 +38,5 @@ # define @NO_DEPRECATED_MACRO_NAME@ # endif #endif - +@CUSTOM_CONTENT@ #endif diff --git a/Modules/javaTargets.cmake.in b/Modules/javaTargets.cmake.in new file mode 100644 index 0000000..c5f9c78 --- /dev/null +++ b/Modules/javaTargets.cmake.in @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 2.8) +cmake_policy(PUSH) +cmake_policy(VERSION 2.8) + +#---------------------------------------------------------------- +# Generated CMake Java target import file. +#---------------------------------------------------------------- + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget @__targets__@) + list(APPEND _expectedTargets ${_expectedTarget}) + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + else() + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() +endforeach() +if("%${_targetsDefined}" STREQUAL "%${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR + "Some (but not all) targets in this export set were already defined.\n" + "Targets Defined: ${_targetsDefined}\n" + "Targets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + +@__targetdefs__@ +cmake_policy(POP) |