diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:33 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:33 +0900 |
commit | 48d9a397fa3cf76397824122450a1450af712716 (patch) | |
tree | 37bb17e0bcabc1da17c5606716c713de5d7d0366 /Modules | |
parent | 53666ee1cffac26c55edcbd9361dbd88a734cfa7 (diff) | |
download | cmake-48d9a397fa3cf76397824122450a1450af712716.tar.gz cmake-48d9a397fa3cf76397824122450a1450af712716.tar.bz2 cmake-48d9a397fa3cf76397824122450a1450af712716.zip |
Imported Upstream version 3.13.0upstream/3.13.0
Diffstat (limited to 'Modules')
114 files changed, 3349 insertions, 4958 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 121a8f015..613ba1a41 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -1,223 +1,246 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# BundleUtilities -# --------------- -# -# Functions to help assemble a standalone bundle application. -# -# A collection of CMake utility functions useful for dealing with .app -# bundles on the Mac and bundle-like directories on any OS. -# -# The following functions are provided by this module: -# -# :: -# -# fixup_bundle -# copy_and_fixup_bundle -# verify_app -# get_bundle_main_executable -# get_dotapp_dir -# get_bundle_and_executable -# get_bundle_all_executables -# get_item_key -# get_item_rpaths -# clear_bundle_keys -# set_bundle_key_values -# get_bundle_keys -# copy_resolved_item_into_bundle -# copy_resolved_framework_into_bundle -# fixup_bundle_item -# verify_bundle_prerequisites -# verify_bundle_symlinks -# -# Requires CMake 2.6 or greater because it uses function, break and -# PARENT_SCOPE. Also depends on GetPrerequisites.cmake. -# -# :: -# -# FIXUP_BUNDLE(<app> <libs> <dirs>) -# -# Fix up a bundle in-place and make it standalone, such that it can be -# drag-n-drop copied to another machine and run on that machine as long -# as all of the system libraries are compatible. -# -# If you pass plugins to fixup_bundle as the libs parameter, you should -# install them or copy them into the bundle before calling fixup_bundle. -# The "libs" parameter is a list of libraries that must be fixed up, but -# that cannot be determined by otool output analysis. (i.e., plugins) -# -# Gather all the keys for all the executables and libraries in a bundle, -# and then, for each key, copy each prerequisite into the bundle. Then -# fix each one up according to its own list of prerequisites. -# -# Then clear all the keys and call verify_app on the final bundle to -# ensure that it is truly standalone. -# -# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") -# -# :: -# -# COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>) -# -# Makes a copy of the bundle <src> at location <dst> and then fixes up -# the new copied bundle in-place at <dst>... -# -# :: -# -# VERIFY_APP(<app>) -# -# Verifies that an application <app> appears valid based on running -# analysis tools on it. Calls "message(FATAL_ERROR" if the application -# is not verified. -# -# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") -# -# :: -# -# GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>) -# -# The result will be the full path name of the bundle's main executable -# file or an "error:" prefixed string if it could not be determined. -# -# :: -# -# GET_DOTAPP_DIR(<exe> <dotapp_dir_var>) -# -# Returns the nearest parent dir whose name ends with ".app" given the -# full path to an executable. If there is no such parent dir, then -# simply return the dir containing the executable. -# -# The returned directory may or may not exist. -# -# :: -# -# GET_BUNDLE_AND_EXECUTABLE(<app> <bundle_var> <executable_var> <valid_var>) -# -# Takes either a ".app" directory name or the name of an executable -# nested inside a ".app" directory and returns the path to the ".app" -# directory in <bundle_var> and the path to its main executable in -# <executable_var> -# -# :: -# -# GET_BUNDLE_ALL_EXECUTABLES(<bundle> <exes_var>) -# -# Scans the given bundle recursively for all executable files and -# accumulates them into a variable. -# -# :: -# -# GET_ITEM_KEY(<item> <key_var>) -# -# Given a file (item) name, generate a key that should be unique -# considering the set of libraries that need copying or fixing up to -# make a bundle standalone. This is essentially the file name including -# extension with "." replaced by "_" -# -# This key is used as a prefix for CMake variables so that we can -# associate a set of variables with a given item based on its key. -# -# :: -# -# CLEAR_BUNDLE_KEYS(<keys_var>) -# -# Loop over the list of keys, clearing all the variables associated with -# each key. After the loop, clear the list of keys itself. -# -# Caller of get_bundle_keys should call clear_bundle_keys when done with -# list of keys. -# -# :: -# -# SET_BUNDLE_KEY_VALUES(<keys_var> <context> <item> <exepath> <dirs> -# <copyflag> [<rpaths>]) -# -# Add a key to the list (if necessary) for the given item. If added, -# also set all the variables associated with that key. -# -# :: -# -# GET_BUNDLE_KEYS(<app> <libs> <dirs> <keys_var>) -# -# Loop over all the executable and library files within the bundle (and -# given as extra <libs>) and accumulate a list of keys representing -# them. Set values associated with each key such that we can loop over -# all of them and copy prerequisite libs into the bundle and then do -# appropriate install_name_tool fixups. -# -# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") -# -# :: -# -# COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) -# -# Copy a resolved item into the bundle if necessary. Copy is not -# necessary if the resolved_item is "the same as" the -# resolved_embedded_item. -# -# :: -# -# COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) -# -# Copy a resolved framework into the bundle if necessary. Copy is not -# necessary if the resolved_item is "the same as" the -# resolved_embedded_item. -# -# By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want -# full frameworks embedded in your bundles, set -# BU_COPY_FULL_FRAMEWORK_CONTENTS to ON before calling fixup_bundle. By -# default, COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework -# dylib itself plus the framework Resources directory. -# -# :: -# -# FIXUP_BUNDLE_ITEM(<resolved_embedded_item> <exepath> <dirs>) -# -# Get the direct/non-system prerequisites of the resolved embedded item. -# For each prerequisite, change the way it is referenced to the value of -# the _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely -# changing to an "@executable_path" style reference.) -# -# This function requires that the resolved_embedded_item be "inside" the -# bundle already. In other words, if you pass plugins to fixup_bundle -# as the libs parameter, you should install them or copy them into the -# bundle before calling fixup_bundle. The "libs" parameter is a list of -# libraries that must be fixed up, but that cannot be determined by -# otool output analysis. (i.e., plugins) -# -# Also, change the id of the item being fixed up to its own -# _EMBEDDED_ITEM value. -# -# Accumulate changes in a local variable and make *one* call to -# install_name_tool at the end of the function with all the changes at -# once. -# -# If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be -# marked writable before install_name_tool tries to change them. -# -# :: -# -# VERIFY_BUNDLE_PREREQUISITES(<bundle> <result_var> <info_var>) -# -# Verifies that the sum of all prerequisites of all files inside the -# bundle are contained within the bundle or are "system" libraries, -# presumed to exist everywhere. -# -# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") -# -# :: -# -# VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>) -# -# Verifies that any symlinks found in the bundle point to other files -# that are already also in the bundle... Anything that points to an -# external file causes this function to fail the verification. +#[=======================================================================[.rst: +BundleUtilities +--------------- + +Functions to help assemble a standalone bundle application. + +A collection of CMake utility functions useful for dealing with .app +bundles on the Mac and bundle-like directories on any OS. + +The following functions are provided by this module: + +:: + + fixup_bundle + copy_and_fixup_bundle + verify_app + get_bundle_main_executable + get_dotapp_dir + get_bundle_and_executable + get_bundle_all_executables + get_item_key + get_item_rpaths + clear_bundle_keys + set_bundle_key_values + get_bundle_keys + copy_resolved_item_into_bundle + copy_resolved_framework_into_bundle + fixup_bundle_item + verify_bundle_prerequisites + verify_bundle_symlinks + +Requires CMake 2.6 or greater because it uses function, break and +PARENT_SCOPE. Also depends on GetPrerequisites.cmake. + +DO NOT USE THESE FUNCTIONS AT CONFIGURE TIME (from ``CMakeLists.txt``)! +Instead, invoke them from an :command:`install(CODE)` or +:command:`install(SCRIPT)` rule. + +:: + + FIXUP_BUNDLE(<app> <libs> <dirs>) + +Fix up a bundle in-place and make it standalone, such that it can be +drag-n-drop copied to another machine and run on that machine as long +as all of the system libraries are compatible. + +If you pass plugins to fixup_bundle as the libs parameter, you should +install them or copy them into the bundle before calling fixup_bundle. +The "libs" parameter is a list of libraries that must be fixed up, but +that cannot be determined by otool output analysis. (i.e., plugins) + +Gather all the keys for all the executables and libraries in a bundle, +and then, for each key, copy each prerequisite into the bundle. Then +fix each one up according to its own list of prerequisites. + +Then clear all the keys and call verify_app on the final bundle to +ensure that it is truly standalone. + +As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") + +:: + + COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>) + +Makes a copy of the bundle <src> at location <dst> and then fixes up +the new copied bundle in-place at <dst>... + +:: + + VERIFY_APP(<app>) + +Verifies that an application <app> appears valid based on running +analysis tools on it. Calls "message(FATAL_ERROR" if the application +is not verified. + +As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") + +:: + + GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>) + +The result will be the full path name of the bundle's main executable +file or an "error:" prefixed string if it could not be determined. + +:: + + GET_DOTAPP_DIR(<exe> <dotapp_dir_var>) + +Returns the nearest parent dir whose name ends with ".app" given the +full path to an executable. If there is no such parent dir, then +simply return the dir containing the executable. + +The returned directory may or may not exist. + +:: + + GET_BUNDLE_AND_EXECUTABLE(<app> <bundle_var> <executable_var> <valid_var>) + +Takes either a ".app" directory name or the name of an executable +nested inside a ".app" directory and returns the path to the ".app" +directory in <bundle_var> and the path to its main executable in +<executable_var> + +:: + + GET_BUNDLE_ALL_EXECUTABLES(<bundle> <exes_var>) + +Scans the given bundle recursively for all executable files and +accumulates them into a variable. + +:: + + GET_ITEM_KEY(<item> <key_var>) + +Given a file (item) name, generate a key that should be unique +considering the set of libraries that need copying or fixing up to +make a bundle standalone. This is essentially the file name including +extension with "." replaced by "_" + +This key is used as a prefix for CMake variables so that we can +associate a set of variables with a given item based on its key. + +:: + + CLEAR_BUNDLE_KEYS(<keys_var>) + +Loop over the list of keys, clearing all the variables associated with +each key. After the loop, clear the list of keys itself. + +Caller of get_bundle_keys should call clear_bundle_keys when done with +list of keys. + +:: + + SET_BUNDLE_KEY_VALUES(<keys_var> <context> <item> <exepath> <dirs> + <copyflag> [<rpaths>]) + +Add a key to the list (if necessary) for the given item. If added, +also set all the variables associated with that key. + +:: + + GET_BUNDLE_KEYS(<app> <libs> <dirs> <keys_var>) + +Loop over all the executable and library files within the bundle (and +given as extra <libs>) and accumulate a list of keys representing +them. Set values associated with each key such that we can loop over +all of them and copy prerequisite libs into the bundle and then do +appropriate install_name_tool fixups. + +As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") + +:: + + COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) + +Copy a resolved item into the bundle if necessary. Copy is not +necessary if the resolved_item is "the same as" the +resolved_embedded_item. + +:: + + COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) + +Copy a resolved framework into the bundle if necessary. Copy is not +necessary if the resolved_item is "the same as" the +resolved_embedded_item. + +By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want +full frameworks embedded in your bundles, set +BU_COPY_FULL_FRAMEWORK_CONTENTS to ON before calling fixup_bundle. By +default, COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework +dylib itself plus the framework Resources directory. + +:: + + FIXUP_BUNDLE_ITEM(<resolved_embedded_item> <exepath> <dirs>) + +Get the direct/non-system prerequisites of the resolved embedded item. +For each prerequisite, change the way it is referenced to the value of +the _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely +changing to an "@executable_path" style reference.) + +This function requires that the resolved_embedded_item be "inside" the +bundle already. In other words, if you pass plugins to fixup_bundle +as the libs parameter, you should install them or copy them into the +bundle before calling fixup_bundle. The "libs" parameter is a list of +libraries that must be fixed up, but that cannot be determined by +otool output analysis. (i.e., plugins) + +Also, change the id of the item being fixed up to its own +_EMBEDDED_ITEM value. + +Accumulate changes in a local variable and make *one* call to +install_name_tool at the end of the function with all the changes at +once. + +If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be +marked writable before install_name_tool tries to change them. + +:: + + VERIFY_BUNDLE_PREREQUISITES(<bundle> <result_var> <info_var>) + +Verifies that the sum of all prerequisites of all files inside the +bundle are contained within the bundle or are "system" libraries, +presumed to exist everywhere. + +As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") + +:: + + VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>) + +Verifies that any symlinks found in the bundle point to other files +that are already also in the bundle... Anything that points to an +external file causes this function to fail the verification. +#]=======================================================================] + +function(_warn_cmp0080) + message(AUTHOR_WARNING + "Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. " + "Run \"cmake --help-policy CMP0080\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + ) +endfunction() + +# Do not include this module at configure time! +if(DEFINED CMAKE_GENERATOR) + cmake_policy(GET CMP0080 _BundleUtilities_CMP0080) + if(_BundleUtilities_CMP0080 STREQUAL "NEW") + message(FATAL_ERROR "BundleUtilities cannot be included at configure time!") + elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD" AND NOT _CMP0080_SUPPRESS_WARNING) + _warn_cmp0080() + endif() +endif() # The functions defined in this file depend on the get_prerequisites function # (and possibly others) found in: @@ -421,7 +444,12 @@ function(get_item_rpaths item rpaths_var) execute_process( COMMAND "${otool_cmd}" -l "${item}" OUTPUT_VARIABLE load_cmds_ov + RESULT_VARIABLE otool_rv + ERROR_VARIABLE otool_ev ) + if(NOT otool_rv STREQUAL "0") + message(FATAL_ERROR "otool -l failed: ${otool_rv}\n${otool_ev}") + endif() string(REGEX REPLACE "[^\n]+cmd LC_RPATH\n[^\n]+\n[^\n]+path ([^\n]+) \\(offset[^\n]+\n" "rpath \\1\n" load_cmds_ov "${load_cmds_ov}") string(REGEX MATCHALL "rpath [^\n]+" load_cmds_ov "${load_cmds_ov}") string(REGEX REPLACE "rpath " "" load_cmds_ov "${load_cmds_ov}") diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 24048ed7e..dbc41c8c7 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -22,11 +22,9 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) if("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support if(NOT CMAKE_ASM_COMPILER_INIT) if(CMAKE_C_COMPILER) - set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "The ASM compiler") - set(CMAKE_ASM_COMPILER_ID "${CMAKE_C_COMPILER_ID}") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_C_COMPILER}) elseif(CMAKE_CXX_COMPILER) - set(CMAKE_ASM_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "The ASM compiler") - set(CMAKE_ASM_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_CXX_COMPILER}) else() # List all default C and CXX compilers set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST @@ -60,6 +58,14 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS Clang ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_Clang "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_Clang "(clang version)") + + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS AppleClang ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_AppleClang "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_AppleClang "(Apple LLVM version)") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS HP ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_HP "-V") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_HP "HP C") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 16dde65fb..5e2df26a6 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -355,6 +355,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} else() set(id_development_team "") endif() + if(DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY) + set(id_code_sign_identity + "CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";") + else() + set(id_code_sign_identity "") + endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in ${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY) unset(_ENV_MACOSX_DEPLOYMENT_TARGET) @@ -519,6 +525,9 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) ${CMAKE_${lang}_COMPILER_ID_STRINGS_PARAMETERS} REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") set(COMPILER_ID_TWICE) + # With the IAR Compiler, some strings are found twice, first time as incomplete + # list like "?<Constant "INFO:compiler[IAR]">". Remove the incomplete copies. + list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\?<Constant \\\"") # In C# binaries, some strings are found more than once. list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_ID_STRINGS) foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 3a72622e4..11f4a29b4 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -27,6 +27,7 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines set(_compilerExecutable "${CMAKE_C_COMPILER}") set(_arg1 "${CMAKE_C_COMPILER_ARG1}") endif () + separate_arguments(_arg1 NATIVE_COMMAND "${_arg1}") execute_process(COMMAND ${_compilerExecutable} ${_arg1} ${_stdver} ${_stdlib} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput @@ -66,10 +67,10 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines #message(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-") list(APPEND ${_resultDefines} "${_name}") - if(_value) - list(APPEND ${_resultDefines} "${_value}") - else() + if ("${_value}" STREQUAL "") list(APPEND ${_resultDefines} " ") + else() + list(APPEND ${_resultDefines} "${_value}") endif() endforeach() diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 1b6823cf3..830639dff 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -38,6 +38,8 @@ if(CMAKE_LINKER) endif() endif() +set(_CMAKE_TOOL_VARS "") + # if it's the MS C/CXX compiler, search for link if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" @@ -47,7 +49,7 @@ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - mark_as_advanced(CMAKE_LINKER) + list(APPEND _CMAKE_TOOL_VARS CMAKE_LINKER) # in all other cases search for ar, ranlib, etc. else() @@ -70,7 +72,7 @@ else() find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) + list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) endif() @@ -81,5 +83,15 @@ if(CMAKE_PLATFORM_HAS_INSTALLNAME) message(FATAL_ERROR "Could not find install_name_tool, please check your installation.") endif() - mark_as_advanced(CMAKE_INSTALL_NAME_TOOL) + list(APPEND _CMAKE_TOOL_VARS CMAKE_INSTALL_NAME_TOOL) endif() + +# Mark any tool cache entries as advanced. +foreach(var IN LISTS _CMAKE_TOOL_VARS) + get_property(_CMAKE_TOOL_CACHED CACHE ${var} PROPERTY TYPE) + if(_CMAKE_TOOL_CACHED) + mark_as_advanced(${var}) + endif() +endforeach() +unset(_CMAKE_TOOL_VARS) +unset(_CMAKE_TOOL_CACHED) diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index 6a89fff2a..de1a3329a 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -14,7 +14,7 @@ CMakeFindDependencyMacro It is designed to be used in a :ref:`Package Configuration File <Config File Packages>` - (``<package>Config.cmake``). ``find_dependency`` forwards the correct + (``<PackageName>Config.cmake``). ``find_dependency`` forwards the correct parameters for ``QUIET`` and ``REQUIRED`` which were passed to the original :command:`find_package` call. Any additional arguments specified are forwarded to :command:`find_package`. diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index fad2e8f69..418bafd63 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -1,6 +1,8 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST # Function to print messages of this module function(_ios_install_combined_message) @@ -57,6 +59,7 @@ endfunction() # Get architectures of given SDK (iphonesimulator/iphoneos) function(_ios_install_combined_get_valid_archs sdk resultvar) + cmake_policy(PUSH) cmake_policy(SET CMP0007 NEW) if("${resultvar}" STREQUAL "") @@ -73,6 +76,8 @@ function(_ios_install_combined_get_valid_archs sdk resultvar) _ios_install_combined_message("Architectures (${sdk}): ${printable}") set("${resultvar}" "${valid_archs}" PARENT_SCOPE) + + cmake_policy(POP) endfunction() # Final target can contain more architectures that specified by SDK. This @@ -161,8 +166,6 @@ function(_ios_install_combined_keep_archs lib archs) endfunction() function(_ios_install_combined_detect_sdks this_sdk_var corr_sdk_var) - cmake_policy(SET CMP0057 NEW) - set(this_sdk "$ENV{PLATFORM_NAME}") if("${this_sdk}" STREQUAL "") message(FATAL_ERROR "Environment variable PLATFORM_NAME is empty") @@ -305,3 +308,5 @@ function(ios_install_combined target destination) _ios_install_combined_message("Install done: ${destination}") endfunction() + +cmake_policy(POP) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 790d4084c..d5301d737 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -27,10 +27,10 @@ # ) # # ``configure_package_config_file()`` should be used instead of the plain -# :command:`configure_file()` command when creating the ``<Name>Config.cmake`` -# or ``<Name>-config.cmake`` file for installing a project or library. It helps -# making the resulting package relocatable by avoiding hardcoded paths in the -# installed ``Config.cmake`` file. +# :command:`configure_file()` command when creating the ``<PackageName>Config.cmake`` +# or ``<PackageName>-config.cmake`` file for installing a project or library. +# It helps making the resulting package relocatable by avoiding hardcoded paths +# in the installed ``Config.cmake`` file. # # In a ``FooConfig.cmake`` file there may be code like this to make the install # destinations know to the using project: @@ -101,7 +101,7 @@ # When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated # into the ``FooConfig.cmake`` file. # -# ``check_required_components(<package_name>)`` should be called at the end of +# ``check_required_components(<PackageName>)`` should be called at the end of # the ``FooConfig.cmake`` file. This macro checks whether all requested, # non-optional components have been found, and if this is not the case, sets # the ``Foo_FOUND`` variable to ``FALSE``, so that the package is considered to @@ -127,7 +127,7 @@ # COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> ) # # -# Writes a file for use as ``<package>ConfigVersion.cmake`` file to +# Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to # ``<filename>``. See the documentation of :command:`find_package()` for # details on this. # diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 935f92d96..30659ebcb 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -1,6 +1,9 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +cmake_policy(PUSH) +cmake_policy(SET CMP0053 NEW) +cmake_policy(SET CMP0054 NEW) # Function parse implicit linker options. # This is used internally by CMake and should not be included by user @@ -185,3 +188,5 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj set(${fwk_var} "${implicit_fwks}" PARENT_SCOPE) set(${log_var} "${log}" PARENT_SCOPE) endfunction() + +cmake_policy(POP) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index cdc38a6a9..f3e34233a 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -19,7 +19,7 @@ command (and the deprecated :command:`install_files`, :command:`install_programs` and :command:`install_targets` commands). For certain kinds of binary installers (including the graphical -installers on Mac OS X and Windows), CPack generates installers that +installers on macOS and Windows), CPack generates installers that allow users to select individual application components to install. See :module:`CPackComponent` module for further details. diff --git a/Modules/CPackArchive.cmake b/Modules/CPackArchive.cmake deleted file mode 100644 index 741fb1fdd..000000000 --- a/Modules/CPackArchive.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackArchive -# ------------ -# -# Archive CPack generator that supports packaging of sources and binaries in -# different formats: -# -# - 7Z - 7zip - (.7z) -# - TBZ2 (.tar.bz2) -# - TGZ (.tar.gz) -# - TXZ (.tar.xz) -# - TZ (.tar.Z) -# - ZIP (.zip) -# -# Variables specific to CPack Archive generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# .. variable:: CPACK_ARCHIVE_FILE_NAME -# CPACK_ARCHIVE_<component>_FILE_NAME -# -# Package file name without extension which is added automatically depending -# on the archive format. -# -# * Mandatory : YES -# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].<extension>`` with -# spaces replaced by '-' -# -# .. variable:: CPACK_ARCHIVE_COMPONENT_INSTALL -# -# Enable component packaging for CPackArchive -# -# * Mandatory : NO -# * Default : OFF -# -# If enabled (ON) multiple packages are generated. By default a single package -# containing files of all components is generated. diff --git a/Modules/CPackBundle.cmake b/Modules/CPackBundle.cmake deleted file mode 100644 index 8f37ef87e..000000000 --- a/Modules/CPackBundle.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackBundle -# ----------- -# -# CPack Bundle generator (Mac OS X) specific options -# -# Variables specific to CPack Bundle generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# Installers built on Mac OS X using the Bundle generator use the -# aforementioned DragNDrop (CPACK_DMG_xxx) variables, plus the following -# Bundle-specific parameters (CPACK_BUNDLE_xxx). -# -# .. variable:: CPACK_BUNDLE_NAME -# -# The name of the generated bundle. This appears in the OSX finder as the -# bundle name. Required. -# -# .. variable:: CPACK_BUNDLE_PLIST -# -# Path to an OSX plist file that will be used for the generated bundle. This -# assumes that the caller has generated or specified their own Info.plist -# file. Required. -# -# .. variable:: CPACK_BUNDLE_ICON -# -# Path to an OSX icon file that will be used as the icon for the generated -# bundle. This is the icon that appears in the OSX finder for the bundle, and -# in the OSX dock when the bundle is opened. Required. -# -# .. variable:: CPACK_BUNDLE_STARTUP_COMMAND -# -# Path to a startup script. This is a path to an executable or script that -# will be run whenever an end-user double-clicks the generated bundle in the -# OSX Finder. Optional. -# -# .. variable:: CPACK_BUNDLE_APPLE_CERT_APP -# -# The name of your Apple supplied code signing certificate for the application. -# The name usually takes the form "Developer ID Application: [Name]" or -# "3rd Party Mac Developer Application: [Name]". If this variable is not set -# the application will not be signed. -# -# .. variable:: CPACK_BUNDLE_APPLE_ENTITLEMENTS -# -# The name of the plist file that contains your apple entitlements for sandboxing -# your application. This file is required for submission to the Mac App Store. -# -# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_FILES -# -# A list of additional files that you wish to be signed. You do not need to -# list the main application folder, or the main executable. You should -# list any frameworks and plugins that are included in your app bundle. -# -# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER -# -# Additional parameter that will passed to codesign. -# Default value: "--deep -f" -# -# .. variable:: CPACK_COMMAND_CODESIGN -# -# Path to the codesign(1) command used to sign applications with an -# Apple cert. This variable can be used to override the automatically -# detected command (or specify its location if the auto-detection fails -# to find it.) - -#Bundle Generator specific code should be put here diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index 6c122e566..a0d99354d 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -14,7 +14,7 @@ # part of CPack. See CPack module for general information about CPack. # # For certain kinds of binary installers (including the graphical -# installers on Mac OS X and Windows), CPack generates installers that +# installers on macOS and Windows), CPack generates installers that # allow users to select individual application components to install. # The contents of each of the components are identified by the COMPONENT # argument of CMake's INSTALL command. These components can be @@ -283,8 +283,8 @@ # # # -# On Mac OS X, installers that download components on-the-fly can only -# be built and installed on system using Mac OS X 10.5 or later. +# On macOS, installers that download components on-the-fly can only +# be built and installed on system using macOS 10.5 or later. # # The site argument is a URL where the archives for downloadable # components will reside, e.g., diff --git a/Modules/CPackCygwin.cmake b/Modules/CPackCygwin.cmake deleted file mode 100644 index 6d203c313..000000000 --- a/Modules/CPackCygwin.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackCygwin -# ----------- -# -# Cygwin CPack generator (Cygwin). -# -# Variables specific to CPack Cygwin generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The -# following variable is specific to installers build on and/or for -# Cygwin: -# -# .. variable:: CPACK_CYGWIN_PATCH_NUMBER -# -# The Cygwin patch number. FIXME: This documentation is incomplete. -# -# .. variable:: CPACK_CYGWIN_PATCH_FILE -# -# The Cygwin patch file. FIXME: This documentation is incomplete. -# -# .. variable:: CPACK_CYGWIN_BUILD_SCRIPT -# -# The Cygwin build script. FIXME: This documentation is incomplete. diff --git a/Modules/CPackDMG.cmake b/Modules/CPackDMG.cmake deleted file mode 100644 index bda600fd4..000000000 --- a/Modules/CPackDMG.cmake +++ /dev/null @@ -1,105 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackDMG -# -------- -# -# DragNDrop CPack generator (Mac OS X). -# -# Variables specific to CPack DragNDrop generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variables are specific to the DragNDrop installers built -# on Mac OS X: -# -# .. variable:: CPACK_DMG_VOLUME_NAME -# -# The volume name of the generated disk image. Defaults to -# CPACK_PACKAGE_FILE_NAME. -# -# .. variable:: CPACK_DMG_FORMAT -# -# The disk image format. Common values are UDRO (UDIF read-only), UDZO (UDIF -# zlib-compressed) or UDBZ (UDIF bzip2-compressed). Refer to hdiutil(1) for -# more information on other available formats. Defaults to UDZO. -# -# .. variable:: CPACK_DMG_DS_STORE -# -# Path to a custom DS_Store file. This .DS_Store file e.g. can be used to -# specify the Finder window position/geometry and layout (such as hidden -# toolbars, placement of the icons etc.). This file has to be generated by -# the Finder (either manually or through AppleScript) using a normal folder -# from which the .DS_Store file can then be extracted. -# -# .. variable:: CPACK_DMG_DS_STORE_SETUP_SCRIPT -# -# Path to a custom AppleScript file. This AppleScript is used to generate -# a .DS_Store file which specifies the Finder window position/geometry and -# layout (such as hidden toolbars, placement of the icons etc.). -# By specifying a custom AppleScript there is no need to use -# CPACK_DMG_DS_STORE, as the .DS_Store that is generated by the AppleScript -# will be packaged. -# -# .. variable:: CPACK_DMG_BACKGROUND_IMAGE -# -# Path to an image file to be used as the background. This file will be -# copied to .background/background.<ext>, where ext is the original image file -# extension. The background image is installed into the image before -# CPACK_DMG_DS_STORE_SETUP_SCRIPT is executed or CPACK_DMG_DS_STORE is -# installed. By default no background image is set. -# -# .. variable:: CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK -# -# Default behaviour is to include a symlink to ``/Applications`` in the DMG. -# Set this option to ``ON`` to avoid adding the symlink. -# -# .. variable:: CPACK_DMG_SLA_DIR -# -# Directory where license and menu files for different languages are stored. -# Setting this causes CPack to look for a ``<language>.menu.txt`` and -# ``<language>.license.txt`` file for every language defined in -# ``CPACK_DMG_SLA_LANGUAGES``. If both this variable and -# ``CPACK_RESOURCE_FILE_LICENSE`` are set, CPack will only look for the menu -# files and use the same license file for all languages. -# -# .. variable:: CPACK_DMG_SLA_LANGUAGES -# -# Languages for which a license agreement is provided when mounting the -# generated DMG. A menu file consists of 9 lines of text. The first line is -# is the name of the language itself, uppercase, in English (e.g. German). -# The other lines are translations of the following strings: -# -# - Agree -# - Disagree -# - Print -# - Save... -# - You agree to the terms of the License Agreement when you click the -# "Agree" button. -# - Software License Agreement -# - This text cannot be saved. The disk may be full or locked, or the file -# may be locked. -# - Unable to print. Make sure you have selected a printer. -# -# For every language in this list, CPack will try to find files -# ``<language>.menu.txt`` and ``<language>.license.txt`` in the directory -# specified by the :variable:`CPACK_DMG_SLA_DIR` variable. -# -# .. variable:: CPACK_COMMAND_HDIUTIL -# -# Path to the hdiutil(1) command used to operate on disk image files on Mac -# 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.) -# -# .. variable:: CPACK_COMMAND_SETFILE -# -# Path to the SetFile(1) command used to set extended attributes on files and -# directories on Mac 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.) -# -# .. variable:: CPACK_COMMAND_REZ -# -# Path to the Rez(1) command used to compile resources on Mac 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.) diff --git a/Modules/CPackFreeBSD.cmake b/Modules/CPackFreeBSD.cmake deleted file mode 100644 index b681d4fbf..000000000 --- a/Modules/CPackFreeBSD.cmake +++ /dev/null @@ -1,248 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -CPackFreeBSD ------------- - -The built in (binary) CPack FreeBSD (pkg) generator (Unix only) - -Variables specific to CPack FreeBSD (pkg) generator -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -CPackFreeBSD may be used to create pkg(8) packages -- these may be used -on FreeBSD, DragonflyBSD, NetBSD, OpenBSD, but also on Linux or OSX, -depending on the installed package-management tools -- using :module:`CPack`. - -CPackFreeBSD is a :module:`CPack` generator and uses the ``CPACK_XXX`` -variables used by :module:`CPack`. It tries to re-use packaging information -that may already be specified for Debian packages for the :module:`CPackDeb` -generator. it also tries to re-use RPM packaging information when Debian -does not specify. - -CPackFreeBSD generator should work on any host with libpkg installed. The -packages it produces are specific to the host architecture and ABI. - -CPackFreeBSD sets package-metadata through :code:`CPACK_FREEBSD_XXX` variables. -CPackFreeBSD, unlike CPackDeb, does not specially support componentized -packages; a single package is created from all the software artifacts -created through CMake. - -All of the variables can be set specifically for FreeBSD packaging in -the CPackConfig file or in CMakeLists.txt, but most of them have defaults -that use general settings (e.g. CMAKE_PROJECT_NAME) or Debian-specific -variables when those make sense (e.g. the homepage of an upstream project -is usually unchanged by the flavor of packaging). When there is no Debian -information to fall back on, but the RPM packaging has it, fall back to -the RPM information (e.g. package license). - -.. variable:: CPACK_FREEBSD_PACKAGE_NAME - - Sets the package name (in the package manifest, but also affects the - output filename). - - * Mandatory: YES - * Default: - - - :variable:`CPACK_PACKAGE_NAME` (this is always set by CPack itself, - based on CMAKE_PROJECT_NAME). - -.. variable:: CPACK_FREEBSD_PACKAGE_COMMENT - - Sets the package comment. This is the short description displayed by - pkg(8) in standard "pkg info" output. - - * Mandatory: YES - * Default: - - - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` (this is always set - by CPack itself, if nothing else sets it explicitly). - - :variable:`PROJECT_DESCRIPTION` (this can be set with the DESCRIPTION - parameter for :command:`project`). - -.. variable:: CPACK_FREEBSD_PACKAGE_DESCRIPTION - - Sets the package description. This is the long description of the package, - given by "pkg info" with a specific package as argument. - - * Mandatory: YES - * Default: - - - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already - for Debian packaging, so we may as well re-use it). - -.. variable:: CPACK_FREEBSD_PACKAGE_WWW - - The URL of the web site for this package, preferably (when applicable) the - site from which the original source can be obtained and any additional - upstream documentation or information may be found. - - * Mandatory: YES - * Default: - - - :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set, - :variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already - for Debian packaging, so we may as well re-use it). - -.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE - - The license, or licenses, which apply to this software package. This must - be one or more license-identifiers that pkg recognizes as acceptable license - identifiers (e.g. "GPLv2"). - - * Mandatory: YES - * Default: - - - :variable:`CPACK_RPM_PACKAGE_LICENSE` - -.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE_LOGIC - - This variable is only of importance if there is more than one license. - The default is "single", which is only applicable to a single license. - Other acceptable values are determined by pkg -- those are "dual" or "multi" -- - meaning choice (OR) or simultaneous (AND) application of the licenses. - - * Mandatory: NO - * Default: single - -.. variable:: CPACK_FREEBSD_PACKAGE_MAINTAINER - - The FreeBSD maintainer (e.g. kde@freebsd.org) of this package. - - * Mandatory: YES - * Default: none - -.. variable:: CPACK_FREEBSD_PACKAGE_ORIGIN - - The origin (ports label) of this package; for packages built by CPack - outside of the ports system this is of less importance. The default - puts the package somewhere under misc/, as a stopgap. - - * Mandatory: YES - * Default: misc/<package name> - -.. variable:: CPACK_FREEBSD_PACKAGE_CATEGORIES - - The ports categories where this package lives (if it were to be built - from ports). If none is set a single category is determined based on - the package origin. - - * Mandatory: YES - * Default: derived from ORIGIN - -.. variable:: CPACK_FREEBSD_PACKAGE_DEPS - - A list of package origins that should be added as package dependencies. - These are in the form <category>/<packagename>, e.g. x11/libkonq. - No version information needs to be provided (this is not included - in the manifest). - - * Mandatory: NO - * Default: empty -#]=======================================================================] - - - -if(CMAKE_BINARY_DIR) - message(FATAL_ERROR "CPackFreeBSD.cmake may only be used by CPack internally.") -endif() - -if(NOT UNIX) - message(FATAL_ERROR "CPackFreeBSD.cmake may only be used under UNIX.") -endif() - - -### -# -# These bits are copied from the Debian packaging file; slightly modified. -# They are used for filling in FreeBSD-packaging variables that can take -# on values from elsewhere -- e.g. the package description may as well be -# copied from Debian. -# -function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME) - set(FALLBACK_VAR_NAMES ${ARGN}) - - set(VALUE "${${OUTPUT_VAR_NAME}}") - if(VALUE) - return() - endif() - - foreach(variable_name IN LISTS FALLBACK_VAR_NAMES) - if(${variable_name}) - set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE) - set(VALUE "${${variable_name}}") - break() - endif() - endforeach() - if(NOT VALUE) - message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.") - endif() -endfunction() - -function(check_required_var VAR_NAME) - if(NOT ${VAR_NAME}) - message(FATAL_ERROR "Variable ${VAR_NAME} is not set.") - endif() -endfunction() - -set(_cpack_freebsd_fallback_origin "misc/bogus") - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_NAME" - "CPACK_PACKAGE_NAME" - "CMAKE_PROJECT_NAME" - ) - -set(_cpack_freebsd_fallback_www "http://example.com/?pkg=${CPACK_FREEBSD_PACKAGE_NAME}") - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_COMMENT" - "CPACK_PACKAGE_DESCRIPTION_SUMMARY" - ) - -# TODO: maybe read the PACKAGE_DESCRIPTION file for the longer -# FreeBSD pkg-descr? -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION" - "CPACK_DEBIAN_PACKAGE_DESCRIPTION" - "CPACK_PACKAGE_DESCRIPTION_SUMMARY" - "PACKAGE_DESCRIPTION" - ) - -# There's really only one homepage for a project, so -# re-use the Debian setting if it's there. -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW" - "CMAKE_PROJECT_HOMEPAGE_URL" - "CPACK_DEBIAN_PACKAGE_HOMEPAGE" - "_cpack_freebsd_fallback_www" - ) - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_VERSION" - "CMAKE_PROJECT_VERSION" - "${CMAKE_PROJECT_NAME}_VERSION" - "PROJECT_VERSION" - "CPACK_PACKAGE_VERSION" - "CPACK_PACKAGE_VERSION" - ) - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_MAINTAINER" - "CPACK_PACKAGE_CONTACT" - ) - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_LICENSE" - "CPACK_RPM_PACKAGE_LICENSE" - ) - -_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_ORIGIN" - "_cpack_freebsd_fallback_origin" - ) - -if(NOT CPACK_FREEBSD_PACKAGE_CATEGORIES) - string(REGEX REPLACE "/.*" "" CPACK_FREEBSD_PACKAGE_CATEGORIES ${CPACK_FREEBSD_PACKAGE_ORIGIN}) -endif() - -check_required_var("CPACK_FREEBSD_PACKAGE_NAME") -check_required_var("CPACK_FREEBSD_PACKAGE_ORIGIN") -check_required_var("CPACK_FREEBSD_PACKAGE_VERSION") -check_required_var("CPACK_FREEBSD_PACKAGE_MAINTAINER") -check_required_var("CPACK_FREEBSD_PACKAGE_COMMENT") -check_required_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION") -check_required_var("CPACK_FREEBSD_PACKAGE_WWW") -check_required_var("CPACK_FREEBSD_PACKAGE_LICENSE") diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 9d733dcd4..141e84254 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -1,677 +1,331 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CPackIFW -# -------- -# -# .. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html -# -# This module looks for the location of the command line utilities supplied -# with the Qt Installer Framework (QtIFW_). -# -# The module also defines several commands to control the behavior of the -# CPack ``IFW`` generator. -# -# -# Overview -# ^^^^^^^^ -# -# CPack ``IFW`` generator helps you to create online and offline -# binary cross-platform installers with a graphical user interface. -# -# CPack IFW generator prepares project installation and generates configuration -# and meta information for QtIFW_ tools. -# -# The QtIFW_ provides a set of tools and utilities to create -# installers for the supported desktop Qt platforms: Linux, Microsoft Windows, -# and Mac OS X. -# -# You should also install QtIFW_ to use CPack ``IFW`` generator. -# -# Hints -# ^^^^^ -# -# Generally, the CPack ``IFW`` generator automatically finds QtIFW_ tools, -# but if you don't use a default path for installation of the QtIFW_ tools, -# the path may be specified in either a CMake or an environment variable: -# -# .. variable:: CPACK_IFW_ROOT -# -# An CMake variable which specifies the location of the QtIFW_ tool suite. -# -# The variable will be cached in the ``CPackConfig.cmake`` file and used at -# CPack runtime. -# -# .. variable:: QTIFWDIR -# -# An environment variable which specifies the location of the QtIFW_ tool -# suite. -# -# .. note:: -# The specified path should not contain "bin" at the end -# (for example: "D:\\DevTools\\QtIFW2.0.5"). -# -# The :variable:`CPACK_IFW_ROOT` variable has a higher priority and overrides -# the value of the :variable:`QTIFWDIR` variable. -# -# Internationalization -# ^^^^^^^^^^^^^^^^^^^^ -# -# Some variables and command arguments support internationalization via -# CMake script. This is an optional feature. -# -# Installers created by QtIFW_ tools have built-in support for -# internationalization and many phrases are localized to many languages, -# but this does not apply to the description of the your components and groups -# that will be distributed. -# -# Localization of the description of your components and groups is useful for -# users of your installers. -# -# A localized variable or argument can contain a single default value, and a -# set of pairs the name of the locale and the localized value. -# -# For example: -# -# .. code-block:: cmake -# -# set(LOCALIZABLE_VARIABLE "Default value" -# en "English value" -# en_US "American value" -# en_GB "Great Britain value" -# ) -# -# Variables -# ^^^^^^^^^ -# -# You can use the following variables to change behavior of CPack ``IFW`` -# generator. -# -# Debug -# """""" -# -# .. variable:: CPACK_IFW_VERBOSE -# -# Set to ``ON`` to enable addition debug output. -# By default is ``OFF``. -# -# Package -# """"""" -# -# .. variable:: CPACK_IFW_PACKAGE_TITLE -# -# Name of the installer as displayed on the title bar. -# By default used :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`. -# -# .. variable:: CPACK_IFW_PACKAGE_PUBLISHER -# -# Publisher of the software (as shown in the Windows Control Panel). -# By default used :variable:`CPACK_PACKAGE_VENDOR`. -# -# .. variable:: CPACK_IFW_PRODUCT_URL -# -# URL to a page that contains product information on your web site. -# -# .. variable:: CPACK_IFW_PACKAGE_ICON -# -# Filename for a custom installer icon. The actual file is '.icns' (Mac OS X), -# '.ico' (Windows). No functionality on Unix. -# -# .. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON -# -# Filename for a custom window icon in PNG format for the Installer -# application. -# -# .. variable:: CPACK_IFW_PACKAGE_LOGO -# -# Filename for a logo is used as QWizard::LogoPixmap. -# -# .. variable:: CPACK_IFW_PACKAGE_WATERMARK -# -# Filename for a watermark is used as QWizard::WatermarkPixmap. -# -# .. variable:: CPACK_IFW_PACKAGE_BANNER -# -# Filename for a banner is used as QWizard::BannerPixmap. -# -# .. variable:: CPACK_IFW_PACKAGE_BACKGROUND -# -# Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle). -# -# .. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE -# -# Wizard style to be used ("Modern", "Mac", "Aero" or "Classic"). -# -# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH -# -# Default width of the wizard in pixels. Setting a banner image will override this. -# -# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT -# -# Default height of the wizard in pixels. Setting a watermark image will override this. -# -# .. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR -# -# Color of the titles and subtitles (takes an HTML color code, such as "#88FF33"). -# -# .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY -# -# Name of the default program group for the product in the Windows Start menu. -# -# By default used :variable:`CPACK_IFW_PACKAGE_NAME`. -# -# .. variable:: CPACK_IFW_TARGET_DIRECTORY -# -# Default target directory for installation. -# By default used -# "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`" -# -# You can use predefined variables. -# -# .. variable:: CPACK_IFW_ADMIN_TARGET_DIRECTORY -# -# Default target directory for installation with administrator rights. -# -# You can use predefined variables. -# -# .. variable:: CPACK_IFW_PACKAGE_GROUP -# -# The group, which will be used to configure the root package -# -# .. variable:: CPACK_IFW_PACKAGE_NAME -# -# The root package name, which will be used if configuration group is not -# specified -# -# .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME -# -# Filename of the generated maintenance tool. -# The platform-specific executable file extension is appended. -# -# By default used QtIFW_ defaults (``maintenancetool``). -# -# .. variable:: CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR -# -# Set to ``OFF`` if the target directory should not be deleted when uninstalling. -# -# Is ``ON`` by default -# -# .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE -# -# Filename for the configuration of the generated maintenance tool. -# -# By default used QtIFW_ defaults (``maintenancetool.ini``). -# -# .. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS -# -# Set to ``ON`` if the installation path can contain non-ASCII characters. -# -# Is ``ON`` for QtIFW_ less 2.0 tools. -# -# .. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH -# -# Set to ``OFF`` if the installation path cannot contain space characters. -# -# Is ``ON`` for QtIFW_ less 2.0 tools. -# -# .. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT -# -# Filename for a custom installer control script. -# -# .. variable:: CPACK_IFW_PACKAGE_RESOURCES -# -# List of additional resources ('.qrc' files) to include in the installer -# binary. -# -# You can use :command:`cpack_ifw_add_package_resources` command to resolve -# relative paths. -# -# .. variable:: CPACK_IFW_PACKAGE_FILE_EXTENSION -# -# The target binary extension. -# -# On Linux, the name of the target binary is automatically extended with -# '.run', if you do not specify the extension. -# -# On Windows, the target is created as an application with the extension -# '.exe', which is automatically added, if not supplied. -# -# On Mac, the target is created as an DMG disk image with the extension -# '.dmg', which is automatically added, if not supplied. -# -# .. variable:: CPACK_IFW_REPOSITORIES_ALL -# -# The list of remote repositories. -# -# The default value of this variable is computed by CPack and contains -# all repositories added with command :command:`cpack_ifw_add_repository` -# or updated with command :command:`cpack_ifw_update_repository`. -# -# .. variable:: CPACK_IFW_DOWNLOAD_ALL -# -# If this is ``ON`` all components will be downloaded. -# By default is ``OFF`` or used value -# from ``CPACK_DOWNLOAD_ALL`` if set -# -# Components -# """""""""" -# -# .. variable:: CPACK_IFW_RESOLVE_DUPLICATE_NAMES -# -# Resolve duplicate names when installing components with groups. -# -# .. variable:: CPACK_IFW_PACKAGES_DIRECTORIES -# -# Additional prepared packages dirs that will be used to resolve -# dependent components. -# -# .. variable:: CPACK_IFW_REPOSITORIES_DIRECTORIES -# -# Additional prepared repository dirs that will be used to resolve and -# repack dependent components. This feature available only -# since QtIFW_ 3.1. -# -# Tools -# """"" -# -# .. variable:: CPACK_IFW_FRAMEWORK_VERSION -# -# The version of used QtIFW_ tools. -# -# .. variable:: CPACK_IFW_BINARYCREATOR_EXECUTABLE -# -# The path to "binarycreator" command line client. -# -# This variable is cached and may be configured if needed. -# -# .. variable:: CPACK_IFW_REPOGEN_EXECUTABLE -# -# The path to "repogen" command line client. -# -# This variable is cached and may be configured if needed. -# -# .. variable:: CPACK_IFW_INSTALLERBASE_EXECUTABLE -# -# The path to "installerbase" installer executable base. -# -# This variable is cached and may be configured if needed. -# -# .. variable:: CPACK_IFW_DEVTOOL_EXECUTABLE -# -# The path to "devtool" command line client. -# -# This variable is cached and may be configured if needed. -# -# Commands -# ^^^^^^^^^ -# -# The module defines the following commands: -# -# .. command:: cpack_ifw_configure_component -# -# Sets the arguments specific to the CPack IFW generator. -# -# :: -# -# cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL] -# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] -# [NAME <name>] -# [DISPLAY_NAME <display_name>] # Note: Internationalization supported -# [DESCRIPTION <description>] # Note: Internationalization supported -# [UPDATE_TEXT <update_text>] -# [VERSION <version>] -# [RELEASE_DATE <release_date>] -# [SCRIPT <script>] -# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated -# [DEPENDS|DEPENDENCIES <com_id> ...] -# [AUTO_DEPEND_ON <comp_id> ...] -# [LICENSES <display_name> <file_path> ...] -# [DEFAULT <value>] -# [USER_INTERFACES <file_path> <file_path> ...] -# [TRANSLATIONS <file_path> <file_path> ...] -# [REPLACES <comp_id> ...] -# [CHECKABLE <value>]) -# -# This command should be called after :command:`cpack_add_component` command. -# -# ``COMMON`` -# if set, then the component will be packaged and installed as part -# of a group to which it belongs. -# -# ``ESSENTIAL`` -# if set, then the package manager stays disabled until that -# component is updated. -# -# ``VIRTUAL`` -# if set, then the component will be hidden from the installer. -# It is a equivalent of the ``HIDDEN`` option from the -# :command:`cpack_add_component` command. -# -# ``FORCED_INSTALLATION`` -# if set, then the component must always be installed. -# It is a equivalent of the ``REQUARED`` option from the -# :command:`cpack_add_component` command. -# -# ``REQUIRES_ADMIN_RIGHTS`` -# set it if the component needs to be installed with elevated permissions. -# -# ``NAME`` -# is used to create domain-like identification for this component. -# By default used origin component name. -# -# ``DISPLAY_NAME`` -# set to rewrite original name configured by -# :command:`cpack_add_component` command. -# -# ``DESCRIPTION`` -# set to rewrite original description configured by -# :command:`cpack_add_component` command. -# -# ``UPDATE_TEXT`` -# will be added to the component description if this is an update to -# the component. -# -# ``VERSION`` -# is version of component. -# By default used :variable:`CPACK_PACKAGE_VERSION`. -# -# ``RELEASE_DATE`` -# keep empty to auto generate. -# -# ``SCRIPT`` -# is a relative or absolute path to operations script -# for this component. -# -# ``PRIORITY`` | ``SORTING_PRIORITY`` -# is priority of the component in the tree. -# The ``PRIORITY`` option is deprecated and will be removed in a future -# version of CMake. Please use ``SORTING_PRIORITY`` option instead. -# -# ``DEPENDS`` | ``DEPENDENCIES`` -# list of dependency component or component group identifiers in -# QtIFW_ style. -# -# ``AUTO_DEPEND_ON`` -# list of identifiers of component or component group in QtIFW_ style -# that this component has an automatic dependency on. -# -# ``LICENSES`` -# pair of <display_name> and <file_path> of license text for this -# component. You can specify more then one license. -# -# ``DEFAULT`` -# Possible values are: TRUE, FALSE, and SCRIPT. -# Set to FALSE to disable the component in the installer or to SCRIPT -# to resolved during runtime (don't forget add the file of the script -# as a value of the ``SCRIPT`` option). -# -# ``USER_INTERFACES`` -# is a list of <file_path> ('.ui' files) representing pages to load. -# -# ``TRANSLATIONS`` -# is a list of <file_path> ('.qm' files) representing translations to load. -# -# ``REPLACES`` -# list of identifiers of component or component group to replace. -# -# ``CHECKABLE`` -# Possible values are: TRUE, FALSE. -# Set to FALSE if you want to hide the checkbox for an item. -# This is useful when only a few subcomponents should be selected -# instead of all. -# -# -# .. command:: cpack_ifw_configure_component_group -# -# Sets the arguments specific to the CPack IFW generator. -# -# :: -# -# cpack_ifw_configure_component_group(<groupname> [VIRTUAL] -# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] -# [NAME <name>] -# [DISPLAY_NAME <display_name>] # Note: Internationalization supported -# [DESCRIPTION <description>] # Note: Internationalization supported -# [UPDATE_TEXT <update_text>] -# [VERSION <version>] -# [RELEASE_DATE <release_date>] -# [SCRIPT <script>] -# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated -# [DEPENDS|DEPENDENCIES <com_id> ...] -# [AUTO_DEPEND_ON <comp_id> ...] -# [LICENSES <display_name> <file_path> ...] -# [DEFAULT <value>] -# [USER_INTERFACES <file_path> <file_path> ...] -# [TRANSLATIONS <file_path> <file_path> ...] -# [REPLACES <comp_id> ...] -# [CHECKABLE <value>]) -# -# This command should be called after :command:`cpack_add_component_group` -# command. -# -# ``VIRTUAL`` -# if set, then the group will be hidden from the installer. -# Note that setting this on a root component does not work. -# -# ``FORCED_INSTALLATION`` -# if set, then the group must always be installed. -# -# ``REQUIRES_ADMIN_RIGHTS`` -# set it if the component group needs to be installed with elevated -# permissions. -# -# ``NAME`` -# is used to create domain-like identification for this component group. -# By default used origin component group name. -# -# ``DISPLAY_NAME`` -# set to rewrite original name configured by -# :command:`cpack_add_component_group` command. -# -# ``DESCRIPTION`` -# set to rewrite original description configured by -# :command:`cpack_add_component_group` command. -# -# ``UPDATE_TEXT`` -# will be added to the component group description if this is an update to -# the component group. -# -# ``VERSION`` -# is version of component group. -# By default used :variable:`CPACK_PACKAGE_VERSION`. -# -# ``RELEASE_DATE`` -# keep empty to auto generate. -# -# ``SCRIPT`` -# is a relative or absolute path to operations script -# for this component group. -# -# ``PRIORITY`` | ``SORTING_PRIORITY`` -# is priority of the component group in the tree. -# The ``PRIORITY`` option is deprecated and will be removed in a future -# version of CMake. Please use ``SORTING_PRIORITY`` option instead. -# -# ``DEPENDS`` | ``DEPENDENCIES`` -# list of dependency component or component group identifiers in -# QtIFW_ style. -# -# ``AUTO_DEPEND_ON`` -# list of identifiers of component or component group in QtIFW_ style -# that this component group has an automatic dependency on. -# -# ``LICENSES`` -# pair of <display_name> and <file_path> of license text for this -# component group. You can specify more then one license. -# -# ``DEFAULT`` -# Possible values are: TRUE, FALSE, and SCRIPT. -# Set to TRUE to preselect the group in the installer -# (this takes effect only on groups that have no visible child components) -# or to SCRIPT to resolved during runtime (don't forget add the file of -# the script as a value of the ``SCRIPT`` option). -# -# ``USER_INTERFACES`` -# is a list of <file_path> ('.ui' files) representing pages to load. -# -# ``TRANSLATIONS`` -# is a list of <file_path> ('.qm' files) representing translations to load. -# -# ``REPLACES`` -# list of identifiers of component or component group to replace. -# -# ``CHECKABLE`` -# Possible values are: TRUE, FALSE. -# Set to FALSE if you want to hide the checkbox for an item. -# This is useful when only a few subcomponents should be selected -# instead of all. -# -# -# .. command:: cpack_ifw_add_repository -# -# Add QtIFW_ specific remote repository to binary installer. -# -# :: -# -# cpack_ifw_add_repository(<reponame> [DISABLED] -# URL <url> -# [USERNAME <username>] -# [PASSWORD <password>] -# [DISPLAY_NAME <display_name>]) -# -# This command will also add the <reponame> repository -# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`. -# -# ``DISABLED`` -# if set, then the repository will be disabled by default. -# -# ``URL`` -# is points to a list of available components. -# -# ``USERNAME`` -# is used as user on a protected repository. -# -# ``PASSWORD`` -# is password to use on a protected repository. -# -# ``DISPLAY_NAME`` -# is string to display instead of the URL. -# -# -# .. command:: cpack_ifw_update_repository -# -# Update QtIFW_ specific repository from remote repository. -# -# :: -# -# cpack_ifw_update_repository(<reponame> -# [[ADD|REMOVE] URL <url>]| -# [REPLACE OLD_URL <old_url> NEW_URL <new_url>]] -# [USERNAME <username>] -# [PASSWORD <password>] -# [DISPLAY_NAME <display_name>]) -# -# This command will also add the <reponame> repository -# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`. -# -# ``URL`` -# is points to a list of available components. -# -# ``OLD_URL`` -# is points to a list that will replaced. -# -# ``NEW_URL`` -# is points to a list that will replace to. -# -# ``USERNAME`` -# is used as user on a protected repository. -# -# ``PASSWORD`` -# is password to use on a protected repository. -# -# ``DISPLAY_NAME`` -# is string to display instead of the URL. -# -# -# .. command:: cpack_ifw_add_package_resources -# -# Add additional resources in the installer binary. -# -# :: -# -# cpack_ifw_add_package_resources(<file_path> <file_path> ...) -# -# This command will also add the specified files -# to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`. -# -# -# Example usage -# ^^^^^^^^^^^^^ -# -# .. code-block:: cmake -# -# set(CPACK_PACKAGE_NAME "MyPackage") -# set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyPackage Installation Example") -# set(CPACK_PACKAGE_VERSION "1.0.0") # Version of installer -# -# include(CPack) -# include(CPackIFW) -# -# cpack_add_component(myapp -# DISPLAY_NAME "MyApp" -# DESCRIPTION "My Application") # Default description -# cpack_ifw_configure_component(myapp -# DESCRIPTION ru_RU "Мое Приложение" # Localized description -# VERSION "1.2.3" # Version of component -# SCRIPT "operations.qs") -# cpack_add_component(mybigplugin -# DISPLAY_NAME "MyBigPlugin" -# DESCRIPTION "My Big Downloadable Plugin" -# DOWNLOADED) -# cpack_ifw_add_repository(myrepo -# URL "http://example.com/ifw/repo/myapp" -# DISPLAY_NAME "My Application Repository") -# -# -# Online installer -# ^^^^^^^^^^^^^^^^ -# -# By default CPack IFW generator makes offline installer. This means that all -# components will be packaged into a binary file. -# -# To make a component downloaded, you must set the ``DOWNLOADED`` option in -# :command:`cpack_add_component`. -# -# Then you would use the command :command:`cpack_configure_downloads`. -# If you set ``ALL`` option all components will be downloaded. -# -# You also can use command :command:`cpack_ifw_add_repository` and -# variable :variable:`CPACK_IFW_DOWNLOAD_ALL` for more specific configuration. -# -# CPack IFW generator creates "repository" dir in current binary dir. You -# would copy content of this dir to specified ``site`` (``url``). -# -# See Also -# ^^^^^^^^ -# -# Qt Installer Framework Manual: -# -# * Index page: -# http://doc.qt.io/qtinstallerframework/index.html -# -# * Component Scripting: -# http://doc.qt.io/qtinstallerframework/scripting.html -# -# * Predefined Variables: -# http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables -# -# * Promoting Updates: -# http://doc.qt.io/qtinstallerframework/ifw-updates.html -# -# Download Qt Installer Framework for you platform from Qt site: -# http://download.qt.io/official_releases/qt-installer-framework -# +#[=======================================================================[.rst: +CPackIFW +-------- + +The documentation for the CPack IFW generator has moved here: :cpack_gen:`CPack IFW Generator` + +.. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html + +This module looks for the location of the command line utilities supplied +with the Qt Installer Framework (QtIFW_). + +The module also defines several commands to control the behavior of the +CPack ``IFW`` generator. + +Commands +^^^^^^^^ + +The module defines the following commands: + +.. command:: cpack_ifw_configure_component + + Sets the arguments specific to the CPack IFW generator. + + :: + + cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL] + [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] + [NAME <name>] + [DISPLAY_NAME <display_name>] # Note: Internationalization supported + [DESCRIPTION <description>] # Note: Internationalization supported + [UPDATE_TEXT <update_text>] + [VERSION <version>] + [RELEASE_DATE <release_date>] + [SCRIPT <script>] + [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated + [DEPENDS|DEPENDENCIES <com_id> ...] + [AUTO_DEPEND_ON <comp_id> ...] + [LICENSES <display_name> <file_path> ...] + [DEFAULT <value>] + [USER_INTERFACES <file_path> <file_path> ...] + [TRANSLATIONS <file_path> <file_path> ...] + [REPLACES <comp_id> ...] + [CHECKABLE <value>]) + + This command should be called after :command:`cpack_add_component` command. + + ``COMMON`` + if set, then the component will be packaged and installed as part + of a group to which it belongs. + + ``ESSENTIAL`` + if set, then the package manager stays disabled until that + component is updated. + + ``VIRTUAL`` + if set, then the component will be hidden from the installer. + It is a equivalent of the ``HIDDEN`` option from the + :command:`cpack_add_component` command. + + ``FORCED_INSTALLATION`` + if set, then the component must always be installed. + It is a equivalent of the ``REQUARED`` option from the + :command:`cpack_add_component` command. + + ``REQUIRES_ADMIN_RIGHTS`` + set it if the component needs to be installed with elevated permissions. + + ``NAME`` + is used to create domain-like identification for this component. + By default used origin component name. + + ``DISPLAY_NAME`` + set to rewrite original name configured by + :command:`cpack_add_component` command. + + ``DESCRIPTION`` + set to rewrite original description configured by + :command:`cpack_add_component` command. + + ``UPDATE_TEXT`` + will be added to the component description if this is an update to + the component. + + ``VERSION`` + is version of component. + By default used :variable:`CPACK_PACKAGE_VERSION`. + + ``RELEASE_DATE`` + keep empty to auto generate. + + ``SCRIPT`` + is a relative or absolute path to operations script + for this component. + + ``PRIORITY`` | ``SORTING_PRIORITY`` + is priority of the component in the tree. + The ``PRIORITY`` option is deprecated and will be removed in a future + version of CMake. Please use ``SORTING_PRIORITY`` option instead. + + ``DEPENDS`` | ``DEPENDENCIES`` + list of dependency component or component group identifiers in + QtIFW_ style. + + ``AUTO_DEPEND_ON`` + list of identifiers of component or component group in QtIFW_ style + that this component has an automatic dependency on. + + ``LICENSES`` + pair of <display_name> and <file_path> of license text for this + component. You can specify more then one license. + + ``DEFAULT`` + Possible values are: TRUE, FALSE, and SCRIPT. + Set to FALSE to disable the component in the installer or to SCRIPT + to resolved during runtime (don't forget add the file of the script + as a value of the ``SCRIPT`` option). + + ``USER_INTERFACES`` + is a list of <file_path> ('.ui' files) representing pages to load. + + ``TRANSLATIONS`` + is a list of <file_path> ('.qm' files) representing translations to load. + + ``REPLACES`` + list of identifiers of component or component group to replace. + + ``CHECKABLE`` + Possible values are: TRUE, FALSE. + Set to FALSE if you want to hide the checkbox for an item. + This is useful when only a few subcomponents should be selected + instead of all. + + +.. command:: cpack_ifw_configure_component_group + + Sets the arguments specific to the CPack IFW generator. + + :: + + cpack_ifw_configure_component_group(<groupname> [VIRTUAL] + [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] + [NAME <name>] + [DISPLAY_NAME <display_name>] # Note: Internationalization supported + [DESCRIPTION <description>] # Note: Internationalization supported + [UPDATE_TEXT <update_text>] + [VERSION <version>] + [RELEASE_DATE <release_date>] + [SCRIPT <script>] + [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated + [DEPENDS|DEPENDENCIES <com_id> ...] + [AUTO_DEPEND_ON <comp_id> ...] + [LICENSES <display_name> <file_path> ...] + [DEFAULT <value>] + [USER_INTERFACES <file_path> <file_path> ...] + [TRANSLATIONS <file_path> <file_path> ...] + [REPLACES <comp_id> ...] + [CHECKABLE <value>]) + + This command should be called after :command:`cpack_add_component_group` + command. + + ``VIRTUAL`` + if set, then the group will be hidden from the installer. + Note that setting this on a root component does not work. + + ``FORCED_INSTALLATION`` + if set, then the group must always be installed. + + ``REQUIRES_ADMIN_RIGHTS`` + set it if the component group needs to be installed with elevated + permissions. + + ``NAME`` + is used to create domain-like identification for this component group. + By default used origin component group name. + + ``DISPLAY_NAME`` + set to rewrite original name configured by + :command:`cpack_add_component_group` command. + + ``DESCRIPTION`` + set to rewrite original description configured by + :command:`cpack_add_component_group` command. + + ``UPDATE_TEXT`` + will be added to the component group description if this is an update to + the component group. + + ``VERSION`` + is version of component group. + By default used :variable:`CPACK_PACKAGE_VERSION`. + + ``RELEASE_DATE`` + keep empty to auto generate. + + ``SCRIPT`` + is a relative or absolute path to operations script + for this component group. + + ``PRIORITY`` | ``SORTING_PRIORITY`` + is priority of the component group in the tree. + The ``PRIORITY`` option is deprecated and will be removed in a future + version of CMake. Please use ``SORTING_PRIORITY`` option instead. + + ``DEPENDS`` | ``DEPENDENCIES`` + list of dependency component or component group identifiers in + QtIFW_ style. + + ``AUTO_DEPEND_ON`` + list of identifiers of component or component group in QtIFW_ style + that this component group has an automatic dependency on. + + ``LICENSES`` + pair of <display_name> and <file_path> of license text for this + component group. You can specify more then one license. + + ``DEFAULT`` + Possible values are: TRUE, FALSE, and SCRIPT. + Set to TRUE to preselect the group in the installer + (this takes effect only on groups that have no visible child components) + or to SCRIPT to resolved during runtime (don't forget add the file of + the script as a value of the ``SCRIPT`` option). + + ``USER_INTERFACES`` + is a list of <file_path> ('.ui' files) representing pages to load. + + ``TRANSLATIONS`` + is a list of <file_path> ('.qm' files) representing translations to load. + + ``REPLACES`` + list of identifiers of component or component group to replace. + + ``CHECKABLE`` + Possible values are: TRUE, FALSE. + Set to FALSE if you want to hide the checkbox for an item. + This is useful when only a few subcomponents should be selected + instead of all. + + +.. command:: cpack_ifw_add_repository + + Add QtIFW_ specific remote repository to binary installer. + + :: + + cpack_ifw_add_repository(<reponame> [DISABLED] + URL <url> + [USERNAME <username>] + [PASSWORD <password>] + [DISPLAY_NAME <display_name>]) + + This command will also add the <reponame> repository + to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`. + + ``DISABLED`` + if set, then the repository will be disabled by default. + + ``URL`` + is points to a list of available components. + + ``USERNAME`` + is used as user on a protected repository. + + ``PASSWORD`` + is password to use on a protected repository. + + ``DISPLAY_NAME`` + is string to display instead of the URL. + + +.. command:: cpack_ifw_update_repository + + Update QtIFW_ specific repository from remote repository. + + :: + + cpack_ifw_update_repository(<reponame> + [[ADD|REMOVE] URL <url>]| + [REPLACE OLD_URL <old_url> NEW_URL <new_url>]] + [USERNAME <username>] + [PASSWORD <password>] + [DISPLAY_NAME <display_name>]) + + This command will also add the <reponame> repository + to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`. + + ``URL`` + is points to a list of available components. + + ``OLD_URL`` + is points to a list that will replaced. + + ``NEW_URL`` + is points to a list that will replace to. + + ``USERNAME`` + is used as user on a protected repository. + + ``PASSWORD`` + is password to use on a protected repository. + + ``DISPLAY_NAME`` + is string to display instead of the URL. + + +.. command:: cpack_ifw_add_package_resources + + Add additional resources in the installer binary. + + :: + + cpack_ifw_add_package_resources(<file_path> <file_path> ...) + + This command will also add the specified files + to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`. + +#]=======================================================================] + +# TODO: +# All of the internal implementation CMake modules for other CPack generators +# have been moved into the Internal/CPack directory. This one has not, because +# it contains user-facing macros which would be lost if it were moved. At some +# point, this module should be split into user-facing macros (which would live +# in this module) and internal implementation details (which would live in +# Internal/CPack/CPackIFW.cmake). #============================================================================= # Search Qt Installer Framework tools diff --git a/Modules/CPackNSIS.cmake b/Modules/CPackNSIS.cmake deleted file mode 100644 index 5bc439555..000000000 --- a/Modules/CPackNSIS.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackNSIS -# --------- -# -# CPack NSIS generator specific options -# -# Variables specific to CPack NSIS generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variables are specific to the graphical installers built -# on Windows using the Nullsoft Installation System. -# -# .. variable:: CPACK_NSIS_INSTALL_ROOT -# -# The default installation directory presented to the end user by the NSIS -# installer is under this root dir. The full directory presented to the end -# user is: ${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY} -# -# .. variable:: CPACK_NSIS_MUI_ICON -# -# An icon filename. The name of a ``*.ico`` file used as the main icon for the -# generated install program. -# -# .. variable:: CPACK_NSIS_MUI_UNIICON -# -# An icon filename. The name of a ``*.ico`` file used as the main icon for the -# generated uninstall program. -# -# .. variable:: CPACK_NSIS_INSTALLER_MUI_ICON_CODE -# -# undocumented. -# -# .. variable:: CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP -# -# The filename of a bitmap to use as the NSIS MUI_WELCOMEFINISHPAGE_BITMAP. -# -# .. variable:: CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP -# -# The filename of a bitmap to use as the NSIS MUI_UNWELCOMEFINISHPAGE_BITMAP. -# -# .. variable:: CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS -# -# Extra NSIS commands that will be added to the beginning of the install -# Section, before your install tree is available on the target system. -# -# .. variable:: CPACK_NSIS_EXTRA_INSTALL_COMMANDS -# -# Extra NSIS commands that will be added to the end of the install Section, -# after your install tree is available on the target system. -# -# .. variable:: CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS -# -# Extra NSIS commands that will be added to the uninstall Section, before -# your install tree is removed from the target system. -# -# .. variable:: CPACK_NSIS_COMPRESSOR -# -# The arguments that will be passed to the NSIS SetCompressor command. -# -# .. variable:: CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL -# -# Ask about uninstalling previous versions first. If this is set to "ON", -# then an installer will look for previous installed versions and if one is -# found, ask the user whether to uninstall it before proceeding with the -# install. -# -# .. variable:: CPACK_NSIS_MODIFY_PATH -# -# Modify PATH toggle. If this is set to "ON", then an extra page will appear -# in the installer that will allow the user to choose whether the program -# directory should be added to the system PATH variable. -# -# .. variable:: CPACK_NSIS_DISPLAY_NAME -# -# The display name string that appears in the Windows Add/Remove Program -# control panel -# -# .. variable:: CPACK_NSIS_PACKAGE_NAME -# -# The title displayed at the top of the installer. -# -# .. variable:: CPACK_NSIS_INSTALLED_ICON_NAME -# -# A path to the executable that contains the installer icon. -# -# .. variable:: CPACK_NSIS_HELP_LINK -# -# URL to a web site providing assistance in installing your application. -# -# .. variable:: CPACK_NSIS_URL_INFO_ABOUT -# -# URL to a web site providing more information about your application. -# -# .. variable:: CPACK_NSIS_CONTACT -# -# Contact information for questions and comments about the installation -# process. -# -# .. variable:: CPACK_NSIS_<compName>_INSTALL_DIRECTORY -# -# Custom install directory for the specified component <compName> instead -# of $INSTDIR. -# -# .. variable:: CPACK_NSIS_CREATE_ICONS_EXTRA -# -# Additional NSIS commands for creating start menu shortcuts. -# -# .. variable:: CPACK_NSIS_DELETE_ICONS_EXTRA -# -# Additional NSIS commands to uninstall start menu shortcuts. -# -# .. variable:: CPACK_NSIS_EXECUTABLES_DIRECTORY -# -# Creating NSIS start menu links assumes that they are in 'bin' unless this -# variable is set. For example, you would set this to 'exec' if your -# executables are in an exec directory. -# -# .. variable:: CPACK_NSIS_MUI_FINISHPAGE_RUN -# -# Specify an executable to add an option to run on the finish page of the -# NSIS installer. -# -# .. variable:: CPACK_NSIS_MENU_LINKS -# -# Specify links in [application] menu. This should contain a list of pair -# "link" "link name". The link may be a URL or a path relative to -# installation prefix. Like:: -# -# set(CPACK_NSIS_MENU_LINKS -# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" -# "CMake Help" "https://cmake.org" "CMake Web Site") -# - -#FIXME we should put NSIS specific code here -#FIXME but I'm not doing it because I'm not able to test it... diff --git a/Modules/CPackPackageMaker.cmake b/Modules/CPackPackageMaker.cmake deleted file mode 100644 index c2ca4c63c..000000000 --- a/Modules/CPackPackageMaker.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackPackageMaker -# ----------------- -# -# PackageMaker CPack generator (Mac OS X). -# -# Variables specific to CPack PackageMaker generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variable is specific to installers built on Mac -# OS X using PackageMaker: -# -# .. variable:: CPACK_OSX_PACKAGE_VERSION -# -# The version of Mac OS X that the resulting PackageMaker archive should be -# compatible with. Different versions of Mac OS X support different -# features. For example, CPack can only build component-based installers for -# Mac OS X 10.4 or newer, and can only build installers that download -# component son-the-fly for Mac OS X 10.5 or newer. If left blank, this value -# will be set to the minimum version of Mac OS X that supports the requested -# features. Set this variable to some value (e.g., 10.4) only if you want to -# guarantee that your installer will work on that version of Mac OS X, and -# don't mind missing extra features available in the installer shipping with -# later versions of Mac OS X. diff --git a/Modules/CPackProductBuild.cmake b/Modules/CPackProductBuild.cmake deleted file mode 100644 index ee78d8d43..000000000 --- a/Modules/CPackProductBuild.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.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_PRODUCTBUILD_IDENTITY_NAME -# -# Adds a digital signature to the resulting package. -# -# -# .. variable:: CPACK_PRODUCTBUILD_KEYCHAIN_PATH -# -# Specify a specific keychain to search for the signing identity. -# -# -# .. 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.) -# -# -# .. variable:: CPACK_PKGBUILD_IDENTITY_NAME -# -# Adds a digital signature to the resulting package. -# -# -# .. variable:: CPACK_PKGBUILD_KEYCHAIN_PATH -# -# Specify a specific keychain to search for the signing identity. -# -# -# .. variable:: CPACK_PREFLIGHT_<COMP>_SCRIPT -# -# Full path to a file that will be used as the ``preinstall`` script for the -# named ``<COMP>`` component's package, where ``<COMP>`` is the uppercased -# component name. No ``preinstall`` script is added if this variable is not -# defined for a given component. -# -# -# .. variable:: CPACK_POSTFLIGHT_<COMP>_SCRIPT -# -# Full path to a file that will be used as the ``postinstall`` script for the -# named ``<COMP>`` component's package, where ``<COMP>`` is the uppercased -# component name. No ``postinstall`` script is added if this variable is not -# defined for a given component. -# -# -# .. variable:: CPACK_PRODUCTBUILD_RESOURCES_DIR -# -# If specified the productbuild generator copies files from this directory -# (including subdirectories) to the ``Resources`` directory. This is done -# before the :variable:`CPACK_RESOURCE_FILE_WELCOME`, -# :variable:`CPACK_RESOURCE_FILE_README`, and -# :variable:`CPACK_RESOURCE_FILE_LICENSE` files are copied. diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake deleted file mode 100644 index 27737e59d..000000000 --- a/Modules/CPackWIX.cmake +++ /dev/null @@ -1,307 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CPackWIX -# -------- -# -# CPack WiX generator specific options -# -# Variables specific to CPack WiX generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variables are specific to the installers built on -# Windows using WiX. -# -# .. variable:: CPACK_WIX_UPGRADE_GUID -# -# Upgrade GUID (``Product/@UpgradeCode``) -# -# Will be automatically generated unless explicitly provided. -# -# It should be explicitly set to a constant generated globally unique -# identifier (GUID) to allow your installers to replace existing -# installations that use the same GUID. -# -# You may for example explicitly set this variable in your -# CMakeLists.txt to the value that has been generated per default. You -# should not use GUIDs that you did not generate yourself or which may -# belong to other projects. -# -# A GUID shall have the following fixed length syntax:: -# -# XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX -# -# (each X represents an uppercase hexadecimal digit) -# -# .. variable:: CPACK_WIX_PRODUCT_GUID -# -# Product GUID (``Product/@Id``) -# -# Will be automatically generated unless explicitly provided. -# -# If explicitly provided this will set the Product Id of your installer. -# -# The installer will abort if it detects a pre-existing installation that -# uses the same GUID. -# -# The GUID shall use the syntax described for CPACK_WIX_UPGRADE_GUID. -# -# .. variable:: CPACK_WIX_LICENSE_RTF -# -# RTF License File -# -# If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension it is used as-is. -# -# If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly -# converted to RTF by the WiX Generator. -# The expected encoding of the .txt file is UTF-8. -# -# With CPACK_WIX_LICENSE_RTF you can override the license file used by the -# WiX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported -# format or the .txt -> .rtf conversion does not work as expected. -# -# .. variable:: CPACK_WIX_PRODUCT_ICON -# -# The Icon shown next to the program name in Add/Remove programs. -# -# If set, this icon is used in place of the default icon. -# -# .. variable:: CPACK_WIX_UI_REF -# -# This variable allows you to override the Id of the ``<UIRef>`` element -# in the WiX template. -# -# The default is ``WixUI_InstallDir`` in case no CPack components have -# been defined and ``WixUI_FeatureTree`` otherwise. -# -# .. variable:: CPACK_WIX_UI_BANNER -# -# The bitmap will appear at the top of all installer pages other than the -# welcome and completion dialogs. -# -# If set, this image will replace the default banner image. -# -# This image must be 493 by 58 pixels. -# -# .. variable:: CPACK_WIX_UI_DIALOG -# -# Background bitmap used on the welcome and completion dialogs. -# -# If this variable is set, the installer will replace the default dialog -# image. -# -# This image must be 493 by 312 pixels. -# -# .. variable:: CPACK_WIX_PROGRAM_MENU_FOLDER -# -# Start menu folder name for launcher. -# -# If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME -# -# .. variable:: CPACK_WIX_CULTURES -# -# Language(s) of the installer -# -# Languages are compiled into the WixUI extension library. To use them, -# simply provide the name of the culture. If you specify more than one -# culture identifier in a comma or semicolon delimited list, the first one -# that is found will be used. You can find a list of supported languages at: -# http://wix.sourceforge.net/manual-wix3/WixUI_localization.htm -# -# .. variable:: CPACK_WIX_TEMPLATE -# -# Template file for WiX generation -# -# If this variable is set, the specified template will be used to generate -# the WiX wxs file. This should be used if further customization of the -# output is required. -# -# If this variable is not set, the default MSI template included with CMake -# will be used. -# -# .. variable:: CPACK_WIX_PATCH_FILE -# -# Optional list of XML files with fragments to be inserted into -# generated WiX sources -# -# This optional variable can be used to specify an XML file that the -# WiX generator will use to inject fragments into its generated -# source files. -# -# Patch files understood by the CPack WiX generator -# roughly follow this RELAX NG compact schema: -# -# .. code-block:: none -# -# start = CPackWiXPatch -# -# CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* } -# -# CPackWiXFragment = element CPackWiXFragment -# { -# attribute Id { string }, -# fragmentContent* -# } -# -# fragmentContent = element * - CPackWiXFragment -# { -# (attribute * { text } | text | fragmentContent)* -# } -# -# Currently fragments can be injected into most -# Component, File, Directory and Feature elements. -# -# The following additional special Ids can be used: -# -# * ``#PRODUCT`` for the ``<Product>`` element. -# * ``#PRODUCTFEATURE`` for the root ``<Feature>`` element. -# -# The following example illustrates how this works. -# -# Given that the WiX generator creates the following XML element: -# -# .. code-block:: xml -# -# <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/> -# -# The following XML patch file may be used to inject an Environment element -# into it: -# -# .. code-block:: xml -# -# <CPackWiXPatch> -# <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe"> -# <Environment Id="MyEnvironment" Action="set" -# Name="MyVariableName" Value="MyVariableValue"/> -# </CPackWiXFragment> -# </CPackWiXPatch> -# -# .. variable:: CPACK_WIX_EXTRA_SOURCES -# -# Extra WiX source files -# -# This variable provides an optional list of extra WiX source files (.wxs) -# that should be compiled and linked. The full path to source files is -# required. -# -# .. variable:: CPACK_WIX_EXTRA_OBJECTS -# -# Extra WiX object files or libraries -# -# This variable provides an optional list of extra WiX object (.wixobj) -# and/or WiX library (.wixlib) files. The full path to objects and libraries -# is required. -# -# .. variable:: CPACK_WIX_EXTENSIONS -# -# This variable provides a list of additional extensions for the WiX -# tools light and candle. -# -# .. variable:: CPACK_WIX_<TOOL>_EXTENSIONS -# -# This is the tool specific version of CPACK_WIX_EXTENSIONS. -# ``<TOOL>`` can be either LIGHT or CANDLE. -# -# .. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS -# -# This list variable allows you to pass additional -# flags to the WiX tool ``<TOOL>``. -# -# Use it at your own risk. -# Future versions of CPack may generate flags which may be in conflict -# with your own flags. -# -# ``<TOOL>`` can be either LIGHT or CANDLE. -# -# .. variable:: CPACK_WIX_CMAKE_PACKAGE_REGISTRY -# -# If this variable is set the generated installer will create -# an entry in the windows registry key -# ``HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<package>`` -# The value for ``<package>`` is provided by this variable. -# -# Assuming you also install a CMake configuration file this will -# allow other CMake projects to find your package with -# the :command:`find_package` command. -# -# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY> -# -# This variable can be used to provide a value for -# the Windows Installer property ``<PROPERTY>`` -# -# The following list contains some example properties that can be used to -# customize information under -# "Programs and Features" (also known as "Add or Remove Programs") -# -# * ARPCOMMENTS - Comments -# * ARPHELPLINK - Help and support information URL -# * ARPURLINFOABOUT - General information URL -# * 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. -# -# .. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER -# -# If this variable is set to true, the default install location -# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly. -# The install location will not be located relatively below -# ProgramFiles or ProgramFiles64. -# -# .. note:: -# Installers created with this feature do not take differences -# between the system on which the installer is created -# and the system on which the installer might be used into account. -# -# It is therefore possible that the installer e.g. might try to install -# onto a drive that is unavailable or unintended or a path that does not -# follow the localization or convention of the system on which the -# installation is performed. -# -# .. variable:: CPACK_WIX_ROOT_FOLDER_ID -# -# This variable allows specification of a custom root folder ID. -# The generator specific ``<64>`` token can be used for -# folder IDs that come in 32-bit and 64-bit variants. -# In 32-bit builds the token will expand empty while in 64-bit builds -# it will expand to ``64``. -# -# When unset generated installers will default installing to -# ``ProgramFiles<64>Folder``. -# -# .. variable:: CPACK_WIX_ROOT -# -# This variable can optionally be set to the root directory -# of a custom WiX Toolset installation. -# -# When unspecified CPack will try to locate a WiX Toolset -# installation via the ``WIX`` environment variable instead. -# - -if(NOT CPACK_WIX_ROOT) - string(REPLACE "\\" "/" CPACK_WIX_ROOT "$ENV{WIX}") -endif() - -find_program(CPACK_WIX_CANDLE_EXECUTABLE candle - PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") - -if(NOT CPACK_WIX_CANDLE_EXECUTABLE) - message(FATAL_ERROR "Could not find the WiX candle executable.") -endif() - -find_program(CPACK_WIX_LIGHT_EXECUTABLE light - PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") - -if(NOT CPACK_WIX_LIGHT_EXECUTABLE) - message(FATAL_ERROR "Could not find the WiX light executable.") -endif() diff --git a/Modules/CSharpUtilities.cmake b/Modules/CSharpUtilities.cmake index e9e1510b6..6a4b5c7f7 100644 --- a/Modules/CSharpUtilities.cmake +++ b/Modules/CSharpUtilities.cmake @@ -184,6 +184,9 @@ Helper functions which are used by the above ones #]=======================================================================] +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + function(csharp_get_filename_keys OUT) set(${OUT} "") foreach(f ${ARGN}) @@ -304,3 +307,5 @@ function(csharp_set_xaml_cs_properties) endif() endforeach() endfunction() + +cmake_policy(POP) diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index 3344834cd..ad8852c06 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -226,7 +226,7 @@ function(check_ipo_supported) endif() endforeach() - if(CMAKE_GENERATOR MATCHES "^Visual Studio ") + if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 ") _ipo_not_supported("CMake doesn't support IPO for current generator") return() endif() diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake index 250a8f481..f94956821 100644 --- a/Modules/Compiler/ARMCC.cmake +++ b/Modules/Compiler/ARMCC.cmake @@ -34,4 +34,6 @@ macro(__compiler_armcc lang) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEPFILE> --depend_single_line --no_depend_system_headers") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") endmacro() diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake index da1fc80d4..76502dca7 100644 --- a/Modules/Compiler/Absoft-Fortran.cmake +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -8,3 +8,4 @@ set(CMAKE_Fortran_MODPATH_FLAG "-p") set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-X") diff --git a/Modules/Compiler/Bruce-C.cmake b/Modules/Compiler/Bruce-C.cmake index cfabe6523..6b64e5806 100644 --- a/Modules/Compiler/Bruce-C.cmake +++ b/Modules/Compiler/Bruce-C.cmake @@ -5,3 +5,5 @@ 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") + +set(CMAKE_C_LINKER_WRAPPER_FLAG "-X") diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 7ce1adb9d..e23470b14 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -30,6 +30,16 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=") endif() + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) + + if(CMAKE_${lang}_COMPILER_TARGET) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-target" "${CMAKE_${lang}_COMPILER_TARGET}") + else() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}") + endif() + endif() set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake index a1899e6dd..ff97e92aa 100644 --- a/Modules/Compiler/Cray-CXX.cmake +++ b/Modules/Compiler/Cray-CXX.cmake @@ -13,6 +13,10 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu) + endif() + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14) + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu) endif () endif () diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake index a1051f489..d52273947 100644 --- a/Modules/Compiler/Flang-Fortran.cmake +++ b/Modules/Compiler/Flang-Fortran.cmake @@ -2,7 +2,7 @@ include(Compiler/Clang) __compiler_clang(Fortran) set(CMAKE_Fortran_PREPROCESS_SOURCE - "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>") + "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake index 2c83fb8fc..03b7e08b9 100644 --- a/Modules/Compiler/G95-Fortran.cmake +++ b/Modules/Compiler/G95-Fortran.cmake @@ -7,3 +7,5 @@ set(CMAKE_Fortran_MODDIR_FLAG "-fmod=") set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index a3ef2bc68..4491d4b39 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -24,6 +24,9 @@ macro(__compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + # Older versions of gcc (< 4.5) contain a bug causing them to report a missing # header file as a warning if depfiles are enabled, causing check_header_file # tests to always succeed. Work around this by disabling dependency tracking @@ -87,5 +90,11 @@ macro(__compiler_gnu lang) ) endif() - set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() diff --git a/Modules/Compiler/HP-C.cmake b/Modules/Compiler/HP-C.cmake index b42ba2be8..8fa4c08e2 100644 --- a/Modules/Compiler/HP-C.cmake +++ b/Modules/Compiler/HP-C.cmake @@ -2,3 +2,6 @@ set(CMAKE_C_VERBOSE_FLAG "-v") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + +set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/Compiler/HP-CXX.cmake b/Modules/Compiler/HP-CXX.cmake index 7548754d3..5726b6494 100644 --- a/Modules/Compiler/HP-CXX.cmake +++ b/Modules/Compiler/HP-CXX.cmake @@ -3,6 +3,9 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",") + # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98 # template support. It is known that version 6.25 doesn't need that flag. # Current assumption: the flag is needed for every version from 3.80 to 4 diff --git a/Modules/Compiler/HP-Fortran.cmake b/Modules/Compiler/HP-Fortran.cmake index a6ca2c2b8..63a033135 100644 --- a/Modules/Compiler/HP-Fortran.cmake +++ b/Modules/Compiler/HP-Fortran.cmake @@ -4,3 +4,6 @@ set(CMAKE_Fortran_FORMAT_FREE_FLAG "+source=free") set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG ",") diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake index 651bc3ae1..e12bfd18e 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -18,4 +18,6 @@ elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") __compiler_iar_AVR(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa) +else() + message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic.") endif() diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index 55e019ec7..2ed88188c 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -5,6 +5,9 @@ include(Compiler/CMakeCommonCompilerMacros) # The toolchains for ARM and AVR are quite different: if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + if(NOT CMAKE_C_COMPILER_VERSION) + message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") + endif() set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) @@ -40,4 +43,7 @@ elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) get_filename_component(_compilerDir "${_compilerDir}" PATH) include_directories("${_compilerDir}/inc" ) + +else() + message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic.") endif() diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index 8d86100a5..5b783b29f 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -10,6 +10,9 @@ if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") # # --c++ is full C++ and supported since 6.10 if(NOT CMAKE_IAR_CXX_FLAG) + if(NOT CMAKE_CXX_COMPILER_VERSION) + message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") + endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.10) set(CMAKE_IAR_CXX_FLAG --c++) else() @@ -48,4 +51,7 @@ elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) get_filename_component(_compilerDir "${_compilerDir}" PATH) include_directories("${_compilerDir}/inc") + +else() + message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic." ) endif() diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake index 635ac4d3c..f2f16e010 100644 --- a/Modules/Compiler/Intel.cmake +++ b/Modules/Compiler/Intel.cmake @@ -25,6 +25,12 @@ else() string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") - set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() endif() diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index 39aae1883..9973febc3 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -34,3 +34,4 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC") set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-PIC") +set(CMAKE_Fortran_RESPONSE_FILE_LINK_FLAG "-Wl,@") diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake index d5a57ee1c..4f8b90b13 100644 --- a/Modules/Compiler/PGI.cmake +++ b/Modules/Compiler/PGI.cmake @@ -25,6 +25,9 @@ macro(__compiler_pgi lang) string(APPEND CMAKE_${lang}_FLAGS_INIT " -Bdynamic") endif() + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG ",") + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le AND (NOT CMAKE_HOST_WIN32 OR CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 16.3)) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake index a5e2b0b5e..9df826909 100644 --- a/Modules/Compiler/QCC.cmake +++ b/Modules/Compiler/QCC.cmake @@ -11,12 +11,21 @@ macro(__compiler_qcc lang) set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") - set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE NO) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) - set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-Wp,-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-Wp,-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO) unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO) diff --git a/Modules/Compiler/SCO.cmake b/Modules/Compiler/SCO.cmake index c55a048a5..7f643d920 100644 --- a/Modules/Compiler/SCO.cmake +++ b/Modules/Compiler/SCO.cmake @@ -15,4 +15,7 @@ macro(__compiler_sco lang) set(CMAKE_${lang}_COMPILE_OPTIONS_DLL -belf) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-Kpic -belf") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-belf -Wl,-Bexport") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") endmacro() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 8d0e6d698..047de43f0 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -29,6 +29,9 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Bdynamic") endforeach() +set(CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") +set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 14196b71d..4c1ac5be6 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -29,6 +29,9 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Bdynamic") endforeach() +set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") +set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",") + set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index 9b25c0b25..2247dd085 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -18,6 +18,9 @@ string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") set(CMAKE_Fortran_MODDIR_FLAG "-moddir=") set(CMAKE_Fortran_MODPATH_FLAG "-M") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",") + set(CMAKE_Fortran_PREPROCESS_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -F -fpp <SOURCE> -o <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake index fbd2841e3..6367695b9 100644 --- a/Modules/Compiler/TinyCC-C.cmake +++ b/Modules/Compiler/TinyCC-C.cmake @@ -6,3 +6,6 @@ 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") + +set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index 3361f8f70..21fe5e8c3 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -20,9 +20,13 @@ macro(__compiler_xl lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-V") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpic") set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O") diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 94bcbf868..4686b645b 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -73,6 +73,7 @@ isa = XCBuildConfiguration; buildSettings = { @id_development_team@ + @id_code_sign_identity@ PRODUCT_NAME = CompilerId@id_lang@; }; name = Debug; diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index e758f3a9c..c69cd3885 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -1,388 +1,400 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# DeployQt4 -# --------- -# -# Functions to help assemble a standalone Qt4 executable. -# -# A collection of CMake utility functions useful for deploying Qt4 -# executables. -# -# The following functions are provided by this module: -# -# :: -# -# write_qt4_conf -# resolve_qt4_paths -# fixup_qt4_executable -# install_qt4_plugin_path -# install_qt4_plugin -# install_qt4_executable -# -# Requires CMake 2.6 or greater because it uses function and -# PARENT_SCOPE. Also depends on BundleUtilities.cmake. -# -# :: -# -# WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>) -# -# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>. -# -# :: -# -# RESOLVE_QT4_PATHS(<paths_var> [<executable_path>]) -# -# Loop through <paths_var> list and if any don't exist resolve them -# relative to the <executable_path> (if supplied) or the -# CMAKE_INSTALL_PREFIX. -# -# :: -# -# FIXUP_QT4_EXECUTABLE(<executable> -# [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>]) -# -# Copies Qt plugins, writes a Qt configuration file (if needed) and -# fixes up a Qt4 executable using BundleUtilities so it is standalone -# and can be drag-and-drop copied to another machine as long as all of -# the system libraries are compatible. -# -# <executable> should point to the executable to be fixed-up. -# -# <qtplugins> should contain a list of the names or paths of any Qt -# plugins to be installed. -# -# <libs> will be passed to BundleUtilities and should be a list of any -# already installed plugins, libraries or executables to also be -# fixed-up. -# -# <dirs> will be passed to BundleUtilities and should contain and -# directories to be searched to find library dependencies. -# -# <plugins_dir> allows an custom plugins directory to be used. -# -# <request_qt_conf> will force a qt.conf file to be written even if not -# needed. -# -# :: -# -# INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var -# <plugins_dir> <component> <configurations>) -# -# Install (or copy) a resolved <plugin> to the default plugins directory -# (or <plugins_dir>) relative to <executable> and store the result in -# <installed_plugin_path_var>. -# -# If <copy> is set to TRUE then the plugins will be copied rather than -# installed. This is to allow this module to be used at CMake time -# rather than install time. -# -# If <component> is set then anything installed will use this COMPONENT. -# -# :: -# -# INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var -# <plugins_dir> <component>) -# -# Install (or copy) an unresolved <plugin> to the default plugins -# directory (or <plugins_dir>) relative to <executable> and store the -# result in <installed_plugin_path_var>. See documentation of -# INSTALL_QT4_PLUGIN_PATH. -# -# :: -# -# INSTALL_QT4_EXECUTABLE(<executable> -# [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>]) -# -# Installs Qt plugins, writes a Qt configuration file (if needed) and -# fixes up a Qt4 executable using BundleUtilities so it is standalone -# and can be drag-and-drop copied to another machine as long as all of -# the system libraries are compatible. The executable will be fixed-up -# at install time. <component> is the COMPONENT used for bundle fixup -# and plugin installation. See documentation of FIXUP_QT4_BUNDLE. +#[=======================================================================[.rst: +DeployQt4 +--------- + +Functions to help assemble a standalone Qt4 executable. + +A collection of CMake utility functions useful for deploying Qt4 +executables. + +The following functions are provided by this module: + +:: + + write_qt4_conf + resolve_qt4_paths + fixup_qt4_executable + install_qt4_plugin_path + install_qt4_plugin + install_qt4_executable + +Requires CMake 2.6 or greater because it uses function and +PARENT_SCOPE. Also depends on BundleUtilities.cmake. + +:: + + WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>) + +Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>. + +:: + + RESOLVE_QT4_PATHS(<paths_var> [<executable_path>]) + +Loop through <paths_var> list and if any don't exist resolve them +relative to the <executable_path> (if supplied) or the +CMAKE_INSTALL_PREFIX. + +:: + + FIXUP_QT4_EXECUTABLE(<executable> + [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>]) + +Copies Qt plugins, writes a Qt configuration file (if needed) and +fixes up a Qt4 executable using BundleUtilities so it is standalone +and can be drag-and-drop copied to another machine as long as all of +the system libraries are compatible. + +<executable> should point to the executable to be fixed-up. + +<qtplugins> should contain a list of the names or paths of any Qt +plugins to be installed. + +<libs> will be passed to BundleUtilities and should be a list of any +already installed plugins, libraries or executables to also be +fixed-up. + +<dirs> will be passed to BundleUtilities and should contain and +directories to be searched to find library dependencies. + +<plugins_dir> allows an custom plugins directory to be used. + +<request_qt_conf> will force a qt.conf file to be written even if not +needed. + +:: + + INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var + <plugins_dir> <component> <configurations>) + +Install (or copy) a resolved <plugin> to the default plugins directory +(or <plugins_dir>) relative to <executable> and store the result in +<installed_plugin_path_var>. + +If <copy> is set to TRUE then the plugins will be copied rather than +installed. This is to allow this module to be used at CMake time +rather than install time. + +If <component> is set then anything installed will use this COMPONENT. + +:: + + INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var + <plugins_dir> <component>) + +Install (or copy) an unresolved <plugin> to the default plugins +directory (or <plugins_dir>) relative to <executable> and store the +result in <installed_plugin_path_var>. See documentation of +INSTALL_QT4_PLUGIN_PATH. + +:: + + INSTALL_QT4_EXECUTABLE(<executable> + [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>]) + +Installs Qt plugins, writes a Qt configuration file (if needed) and +fixes up a Qt4 executable using BundleUtilities so it is standalone +and can be drag-and-drop copied to another machine as long as all of +the system libraries are compatible. The executable will be fixed-up +at install time. <component> is the COMPONENT used for bundle fixup +and plugin installation. See documentation of FIXUP_QT4_BUNDLE. +#]=======================================================================] # The functions defined in this file depend on the fixup_bundle function # (and others) found in BundleUtilities.cmake -include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake") set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") set(DeployQt4_apple_plugins_dir "PlugIns") function(write_qt4_conf qt_conf_dir qt_conf_contents) - set(qt_conf_path "${qt_conf_dir}/qt.conf") - message(STATUS "Writing ${qt_conf_path}") - file(WRITE "${qt_conf_path}" "${qt_conf_contents}") + set(qt_conf_path "${qt_conf_dir}/qt.conf") + message(STATUS "Writing ${qt_conf_path}") + file(WRITE "${qt_conf_path}" "${qt_conf_contents}") endfunction() function(resolve_qt4_paths paths_var) - unset(executable_path) - if(ARGC GREATER 1) - set(executable_path ${ARGV1}) - endif() - - set(paths_resolved) - foreach(path ${${paths_var}}) - if(EXISTS "${path}") - list(APPEND paths_resolved "${path}") - else() - if(${executable_path}) - list(APPEND paths_resolved "${executable_path}/${path}") - else() - list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}") - endif() - endif() - endforeach() - set(${paths_var} ${paths_resolved} PARENT_SCOPE) -endfunction() + unset(executable_path) + if(ARGC GREATER 1) + set(executable_path ${ARGV1}) + endif() -function(fixup_qt4_executable executable) - unset(qtplugins) - if(ARGC GREATER 1) - set(qtplugins ${ARGV1}) - endif() - unset(libs) - if(ARGC GREATER 2) - set(libs ${ARGV2}) - endif() - unset(dirs) - if(ARGC GREATER 3) - set(dirs ${ARGV3}) - endif() - unset(plugins_dir) - if(ARGC GREATER 4) - set(plugins_dir ${ARGV4}) - endif() - unset(request_qt_conf) - if(ARGC GREATER 5) - set(request_qt_conf ${ARGV5}) - endif() - - message(STATUS "fixup_qt4_executable") - message(STATUS " executable='${executable}'") - message(STATUS " qtplugins='${qtplugins}'") - message(STATUS " libs='${libs}'") - message(STATUS " dirs='${dirs}'") - message(STATUS " plugins_dir='${plugins_dir}'") - message(STATUS " request_qt_conf='${request_qt_conf}'") - - if(QT_LIBRARY_DIR) - list(APPEND dirs "${QT_LIBRARY_DIR}") - endif() - if(QT_BINARY_DIR) - list(APPEND dirs "${QT_BINARY_DIR}") - endif() - - if(APPLE) - set(qt_conf_dir "${executable}/Contents/Resources") - set(executable_path "${executable}") - set(write_qt_conf TRUE) - if(NOT DEFINED plugins_dir) - set(plugins_dir "${DeployQt4_apple_plugins_dir}") - endif() - else() - get_filename_component(executable_path "${executable}" PATH) - if(NOT executable_path) - set(executable_path ".") - endif() - set(qt_conf_dir "${executable_path}") - set(write_qt_conf ${request_qt_conf}) - endif() - - foreach(plugin ${qtplugins}) - set(installed_plugin_path "") - install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path) - list(APPEND libs ${installed_plugin_path}) - endforeach() - - foreach(lib ${libs}) - if(NOT EXISTS "${lib}") - message(FATAL_ERROR "Library does not exist: ${lib}") - endif() - endforeach() - - resolve_qt4_paths(libs "${executable_path}") - - if(write_qt_conf) - set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") - write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") - endif() - - fixup_bundle("${executable}" "${libs}" "${dirs}") + set(paths_resolved) + foreach(path ${${paths_var}}) + if(EXISTS "${path}") + list(APPEND paths_resolved "${path}") + else() + if(${executable_path}) + list(APPEND paths_resolved "${executable_path}/${path}") + else() + list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}") + endif() + endif() + endforeach() + set(${paths_var} ${paths_resolved} PARENT_SCOPE) endfunction() +cmake_policy(GET CMP0080 _cmp0080_value) +if(NOT DEFINED CMAKE_GENERATOR OR NOT _cmp0080_value STREQUAL "NEW") + set(_CMP0080_SUPPRESS_WARNING TRUE) + include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake") + unset(_CMP0080_SUPPRESS_WARNING) + + function(fixup_qt4_executable executable) + cmake_policy(GET CMP0080 _cmp0080_value) + if(_cmp0080_value STREQUAL "" AND DEFINED CMAKE_GENERATOR) + _warn_cmp0080() + endif() + + unset(qtplugins) + if(ARGC GREATER 1) + set(qtplugins ${ARGV1}) + endif() + unset(libs) + if(ARGC GREATER 2) + set(libs ${ARGV2}) + endif() + unset(dirs) + if(ARGC GREATER 3) + set(dirs ${ARGV3}) + endif() + unset(plugins_dir) + if(ARGC GREATER 4) + set(plugins_dir ${ARGV4}) + endif() + unset(request_qt_conf) + if(ARGC GREATER 5) + set(request_qt_conf ${ARGV5}) + endif() + + message(STATUS "fixup_qt4_executable") + message(STATUS " executable='${executable}'") + message(STATUS " qtplugins='${qtplugins}'") + message(STATUS " libs='${libs}'") + message(STATUS " dirs='${dirs}'") + message(STATUS " plugins_dir='${plugins_dir}'") + message(STATUS " request_qt_conf='${request_qt_conf}'") + + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + if(QT_BINARY_DIR) + list(APPEND dirs "${QT_BINARY_DIR}") + endif() + + if(APPLE) + set(qt_conf_dir "${executable}/Contents/Resources") + set(executable_path "${executable}") + set(write_qt_conf TRUE) + if(NOT DEFINED plugins_dir) + set(plugins_dir "${DeployQt4_apple_plugins_dir}") + endif() + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(qt_conf_dir "${executable_path}") + set(write_qt_conf ${request_qt_conf}) + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_path "") + install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path) + list(APPEND libs ${installed_plugin_path}) + endforeach() + + foreach(lib ${libs}) + if(NOT EXISTS "${lib}") + message(FATAL_ERROR "Library does not exist: ${lib}") + endif() + endforeach() + + resolve_qt4_paths(libs "${executable_path}") + + if(write_qt_conf) + set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") + write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") + endif() + + fixup_bundle("${executable}" "${libs}" "${dirs}") + endfunction() +endif() + function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var) - unset(plugins_dir) - if(ARGC GREATER 4) - set(plugins_dir ${ARGV4}) - endif() - unset(component) - if(ARGC GREATER 5) - set(component ${ARGV5}) - endif() + unset(plugins_dir) + if(ARGC GREATER 4) + set(plugins_dir ${ARGV4}) + endif() + unset(component) + if(ARGC GREATER 5) + set(component ${ARGV5}) + endif() + unset(configurations) + if(ARGC GREATER 6) + set(configurations ${ARGV6}) + endif() + + if(EXISTS "${plugin}") + if(APPLE) + if(NOT plugins_dir) + set(plugins_dir "${DeployQt4_apple_plugins_dir}") + endif() + set(plugins_path "${executable}/Contents/${plugins_dir}") + else() + get_filename_component(plugins_path "${executable}" PATH) + if(NOT plugins_path) + set(plugins_path ".") + endif() + if(plugins_dir) + string(APPEND plugins_path "/${plugins_dir}") + endif() + endif() + + set(plugin_group "") + + get_filename_component(plugin_path "${plugin}" PATH) + get_filename_component(plugin_parent_path "${plugin_path}" PATH) + get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME) + get_filename_component(plugin_name "${plugin}" NAME) + string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name) + + if("${plugin_parent_dir_name}" STREQUAL "plugins") + get_filename_component(plugin_group "${plugin_path}" NAME) + set(${plugin_group_var} "${plugin_group}") + endif() + string(APPEND plugins_path "/${plugin_group}") + + if(${copy}) + file(MAKE_DIRECTORY "${plugins_path}") + file(COPY "${plugin}" DESTINATION "${plugins_path}") + else() + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE)) + set(configurations CONFIGURATIONS ${configurations}) + else() unset(configurations) - if(ARGC GREATER 6) - set(configurations ${ARGV6}) - endif() - - if(EXISTS "${plugin}") - if(APPLE) - if(NOT plugins_dir) - set(plugins_dir "${DeployQt4_apple_plugins_dir}") - endif() - set(plugins_path "${executable}/Contents/${plugins_dir}") - else() - get_filename_component(plugins_path "${executable}" PATH) - if(NOT plugins_path) - set(plugins_path ".") - endif() - if(plugins_dir) - string(APPEND plugins_path "/${plugins_dir}") - endif() - endif() - - set(plugin_group "") - - get_filename_component(plugin_path "${plugin}" PATH) - get_filename_component(plugin_parent_path "${plugin_path}" PATH) - get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME) - get_filename_component(plugin_name "${plugin}" NAME) - string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name) - - if("${plugin_parent_dir_name}" STREQUAL "plugins") - get_filename_component(plugin_group "${plugin_path}" NAME) - set(${plugin_group_var} "${plugin_group}") - endif() - string(APPEND plugins_path "/${plugin_group}") - - if(${copy}) - file(MAKE_DIRECTORY "${plugins_path}") - file(COPY "${plugin}" DESTINATION "${plugins_path}") - else() - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE)) - set(configurations CONFIGURATIONS ${configurations}) - else() - unset(configurations) - endif() - install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) - endif() - set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE) - endif() + endif() + install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) + endif() + set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE) + endif() endfunction() function(install_qt4_plugin plugin executable copy installed_plugin_path_var) - unset(plugins_dir) - if(ARGC GREATER 4) - set(plugins_dir ${ARGV4}) - endif() - unset(component) - if(ARGC GREATER 5) - set(component ${ARGV5}) - endif() - - if(EXISTS "${plugin}") - install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") - else() - string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) - set(plugin_release_var "${plugin_var}_RELEASE") - set(plugin_debug_var "${plugin_var}_DEBUG") - set(plugin_release "${${plugin_release_var}}") - set(plugin_debug "${${plugin_debug_var}}") - if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") - message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") - endif() - if(NOT EXISTS "${${plugin_debug_var}}") - set(plugin_debug "${plugin_release}") - endif() - - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(_isMultiConfig OR CMAKE_BUILD_TYPE) - set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}") - if (_RELEASE_CONFIGS) - list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]") - endif() - string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}") - install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}") - install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug") - unset(_RELEASE_CONFIGS) - - if(CMAKE_BUILD_TYPE MATCHES "^Debug$") - set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug}) - else() - set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release}) - endif() - else() - install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") - endif() - endif() - set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE) + unset(plugins_dir) + if(ARGC GREATER 4) + set(plugins_dir ${ARGV4}) + endif() + unset(component) + if(ARGC GREATER 5) + set(component ${ARGV5}) + endif() + + if(EXISTS "${plugin}") + install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + else() + string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) + set(plugin_release_var "${plugin_var}_RELEASE") + set(plugin_debug_var "${plugin_var}_DEBUG") + set(plugin_release "${${plugin_release_var}}") + set(plugin_debug "${${plugin_debug_var}}") + if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") + message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") + endif() + if(NOT EXISTS "${${plugin_debug_var}}") + set(plugin_debug "${plugin_release}") + endif() + + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(_isMultiConfig OR CMAKE_BUILD_TYPE) + set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}") + if (_RELEASE_CONFIGS) + list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]") + endif() + string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}") + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}") + install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug") + unset(_RELEASE_CONFIGS) + + if(CMAKE_BUILD_TYPE MATCHES "^Debug$") + set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug}) + else() + set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release}) + endif() + else() + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + endif() + endif() + set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE) endfunction() function(install_qt4_executable executable) - unset(qtplugins) - if(ARGC GREATER 1) - set(qtplugins ${ARGV1}) - endif() - unset(libs) - if(ARGC GREATER 2) - set(libs ${ARGV2}) - endif() - unset(dirs) - if(ARGC GREATER 3) - set(dirs ${ARGV3}) - endif() - unset(plugins_dir) - if(ARGC GREATER 4) - set(plugins_dir ${ARGV4}) - endif() - unset(request_qt_conf) - if(ARGC GREATER 5) - set(request_qt_conf ${ARGV5}) - endif() - unset(component) - if(ARGC GREATER 6) - set(component ${ARGV6}) - endif() - - if(QT_LIBRARY_DIR) - list(APPEND dirs "${QT_LIBRARY_DIR}") - endif() - if(QT_BINARY_DIR) - list(APPEND dirs "${QT_BINARY_DIR}") - endif() - if(component) - set(component COMPONENT ${component}) - else() - unset(component) - endif() - - get_filename_component(executable_absolute "${executable}" ABSOLUTE) - if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}") - gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type) - elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}") - gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type) - endif() - if(qtcore_type STREQUAL "system") - set(qt_plugins_dir "") - endif() - - if(QT_IS_STATIC) - message(WARNING "Qt built statically: not installing plugins.") - else() - foreach(plugin ${qtplugins}) - set(installed_plugin_paths "") - install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") - list(APPEND libs ${installed_plugin_paths}) - endforeach() - endif() - - resolve_qt4_paths(libs "") - - install(CODE - "include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\") - set(BU_CHMOD_BUNDLE_ITEMS TRUE) - FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")" - ${component} - ) + unset(qtplugins) + if(ARGC GREATER 1) + set(qtplugins ${ARGV1}) + endif() + unset(libs) + if(ARGC GREATER 2) + set(libs ${ARGV2}) + endif() + unset(dirs) + if(ARGC GREATER 3) + set(dirs ${ARGV3}) + endif() + unset(plugins_dir) + if(ARGC GREATER 4) + set(plugins_dir ${ARGV4}) + endif() + unset(request_qt_conf) + if(ARGC GREATER 5) + set(request_qt_conf ${ARGV5}) + endif() + unset(component) + if(ARGC GREATER 6) + set(component ${ARGV6}) + endif() + + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + if(QT_BINARY_DIR) + list(APPEND dirs "${QT_BINARY_DIR}") + endif() + if(component) + set(component COMPONENT ${component}) + else() + unset(component) + endif() + + get_filename_component(executable_absolute "${executable}" ABSOLUTE) + if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type) + elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type) + endif() + if(qtcore_type STREQUAL "system") + set(qt_plugins_dir "") + endif() + + if(QT_IS_STATIC) + message(WARNING "Qt built statically: not installing plugins.") + else() + foreach(plugin ${qtplugins}) + set(installed_plugin_paths "") + install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") + list(APPEND libs ${installed_plugin_paths}) + endforeach() + endif() + + resolve_qt4_paths(libs "") + + install(CODE +"include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\") +set(BU_CHMOD_BUNDLE_ITEMS TRUE) +FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")" + ${component} + ) endfunction() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0c5b33f7e..f987d2d8f 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -934,6 +934,11 @@ function(_ep_parse_arguments f name ns args) # We loop through ARGN and consider the namespace starting with an # upper-case letter followed by at least two more upper-case letters, # numbers or underscores to be keywords. + + if(NOT DEFINED _ExternalProject_SELF) + message(FATAL_ERROR "error: ExternalProject module must be explicitly included before using ${f} function") + endif() + set(key) foreach(arg IN LISTS args) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index d684ccd86..2000f7ff6 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -149,17 +149,25 @@ if(BISON_EXECUTABLE) set(BISON_TARGET_verbose_file "${ReportFile}") list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}") endif() + if(NOT IS_ABSOLUTE "${BISON_TARGET_verbose_file}") + set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_TARGET_verbose_file}") + endif() endmacro() # internal macro # adds a custom command and sets - # BISON_TARGET_cmdopt, BISON_TARGET_verbose_file, BISON_TARGET_extraoutputs + # BISON_TARGET_cmdopt, BISON_TARGET_extraoutputs macro(BISON_TARGET_option_verbose Name BisonOutput filename) list(APPEND BISON_TARGET_cmdopt "--verbose") - list(APPEND BISON_TARGET_extraoutputs + list(APPEND BISON_TARGET_outputs "${BISON_TARGET_verbose_file}") if (NOT "${filename}" STREQUAL "") - add_custom_command(OUTPUT ${filename} + if(IS_ABSOLUTE "${filename}") + set(BISON_TARGET_verbose_extra_file "${filename}") + else() + set(BISON_TARGET_verbose_extra_file "${CMAKE_CURRENT_SOURCE_DIR}/${filename}") + endif() + add_custom_command(OUTPUT ${BISON_TARGET_verbose_extra_file} COMMAND ${CMAKE_COMMAND} -E copy "${BISON_TARGET_verbose_file}" "${filename}" @@ -167,10 +175,10 @@ if(BISON_EXECUTABLE) 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}) + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND BISON_TARGET_extraoutputs - "${filename}") + "${BISON_TARGET_verbose_extra_file}") + unset(BISON_TARGET_verbose_extra_file) endif() endmacro() @@ -226,7 +234,6 @@ if(BISON_EXECUTABLE) list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}") add_custom_command(OUTPUT ${BISON_TARGET_outputs} - ${BISON_TARGET_extraoutputs} COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput} VERBATIM DEPENDS ${BisonInput} diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 5ee703a73..b5546e094 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -22,7 +22,8 @@ # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l # and -L). # BLAS_LIBRARIES - uncached list of libraries (using full path name) to -# link against to use BLAS +# link against to use BLAS (may be empty if compiler implicitly links +# BLAS) # BLAS95_LIBRARIES - uncached list of libraries (using full path name) # to link against to use BLAS95 interface # BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface @@ -52,8 +53,10 @@ # * SGIMATH # * IBMESSL # * Intel10_32 (intel mkl v10 32 bit) -# * Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model) -# * Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model) +# * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model) +# * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model) +# * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model) +# * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model) # * Intel (older versions of mkl 32 and 64 bit) # * ACML # * ACML_MP @@ -90,83 +93,88 @@ if(BLA_PREFER_PKGCONFIG) find_package(PkgConfig) pkg_check_modules(PKGC_BLAS blas) if(PKGC_BLAS_FOUND) + set(BLAS_FOUND ${PKGC_BLAS_FOUND}) set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}") return() endif() endif() macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) -# This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the -# Check_Fortran_Function_Exists macro) whether can link against that library -# combination using the name of a routine given by _name using the linker -# flags given by _flags. If the combination of libraries is found and passes -# the link test, LIBRARIES is set to the list of complete library paths that -# have been found. Otherwise, LIBRARIES is set to FALSE. - -# N.B. _prefix is the prefix applied to the names of all cached variables that -# are generated internally and marked advanced by this macro. - -set(_libdir ${ARGN}) - -set(_libraries_work TRUE) -set(${LIBRARIES}) -set(_combined_name) -if (NOT _libdir) - if (WIN32) - set(_libdir ENV LIB) - elseif (APPLE) - set(_libdir ENV DYLD_LIBRARY_PATH) - else () - set(_libdir ENV LD_LIBRARY_PATH) + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + + set(_libdir ${ARGN}) + + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir ENV DYLD_LIBRARY_PATH) + else () + set(_libdir ENV LD_LIBRARY_PATH) + endif () endif () -endif () -foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) + foreach(_library ${_list}) + set(_combined_name ${_combined_name}_${_library}) - if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(_libraries_work) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else () + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () else () - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - else () - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () endif () - endif () - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_libdir} - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_libdir} + ) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif() + endforeach() + if(_libraries_work) + # Test this combination of libraries. + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread}) + # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if (CMAKE_Fortran_COMPILER_LOADED) + check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + else() + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + endif() + set(CMAKE_REQUIRED_LIBRARIES) + mark_as_advanced(${_prefix}${_combined_name}_WORKS) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif() -endforeach() -if(_libraries_work) - # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread}) -# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if (CMAKE_Fortran_COMPILER_LOADED) - check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + if(_libraries_work) + if("${_list}" STREQUAL "") + set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + endif() else() - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + set(${LIBRARIES} FALSE) endif() - set(CMAKE_REQUIRED_LIBRARIES) - mark_as_advanced(${_prefix}${_combined_name}_WORKS) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) -endif() -if(NOT _libraries_work) - set(${LIBRARIES} FALSE) -endif() -#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") + #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endmacro() set(BLAS_LINKER_FLAGS) @@ -180,516 +188,539 @@ else () endif() endif () +if (BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # Implicitly linked BLAS libraries + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "" + "" + ) + endif() +endif () + +#BLAS in intel mkl 10+ library? (em64t 64bit) +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if (NOT BLAS_LIBRARIES) + if (BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else () + set(BLAS_mkl_ILP_MODE "lp64") + endif () + if (NOT WIN32) + set(LM "-lm") + endif () + if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + set(BLAS_SEARCH_LIBS "") + + if(BLA_F95) + set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95) + set(_LIBRARIES BLAS95_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else () + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + endif () + endif () + else () + set(BLAS_mkl_SEARCH_SYMBOL sgemm) + set(_LIBRARIES BLAS_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else () + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + endif () + + #older vesions of intel mkl libs + if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl") + list(APPEND BLAS_SEARCH_LIBS + "mkl_ia32") + list(APPEND BLAS_SEARCH_LIBS + "mkl_em64t") + endif () + endif () + endif () + + foreach (IT ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if (NOT ${_LIBRARIES}) + check_fortran_libraries( + ${_LIBRARIES} + BLAS + ${BLAS_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + endif () + endforeach () + + endif () + unset(BLAS_mkl_ILP_MODE) + endif () +endif () + if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "goto2" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + ) + endif() endif () if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # OpenBLAS (http://www.openblas.net) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "openblas" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + # OpenBLAS (http://www.openblas.net) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "" + ) + endif() endif () if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # FLAME's blis library (https://github.com/flame/blis) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "blis" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + # FLAME's blis library (https://github.com/flame/blis) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blis" + "" + ) + endif() endif () if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "f77blas;atlas" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "f77blas;atlas" + "" + ) + endif() endif () # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "sgemm;dgemm;blas" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "sgemm;dgemm;blas" + "" + ) + endif() endif () # BLAS in Alpha CXML library? if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "cxml" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "cxml" + "" + ) + endif() endif () # BLAS in Alpha DXML library? (now called CXML, see above) if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "dxml" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "dxml" + "" + ) + endif() endif () # BLAS in Sun Performance library? if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "-xlic_lib=sunperf" - "sunperf;sunmath" - "" - ) - if(BLAS_LIBRARIES) - set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-xlic_lib=sunperf" + "sunperf;sunmath" + "" + ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") + endif() endif() - endif() endif () # BLAS in SCSL library? (SGI/Cray Scientific Library) if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "scsl" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "scsl" + "" + ) + endif() endif () # BLAS in SGIMATH library? if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "complib.sgimath" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "complib.sgimath" + "" + ) + endif() endif () # BLAS in IBM ESSL library? (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "essl;blas" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "essl;blas" + "" + ) + endif() endif () #BLAS in acml library? if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") - if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR - ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR - ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) - ) - # try to find acml in "standard" paths - if( WIN32 ) + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) + ) + # try to find acml in "standard" paths + if( WIN32 ) file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) - else() + else() file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) - endif() - if( WIN32 ) + endif() + if( WIN32 ) file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) - else() + else() file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) - endif() - list(GET _ACML_ROOT 0 _ACML_ROOT) - list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) - if( _ACML_ROOT ) + endif() + list(GET _ACML_ROOT 0 _ACML_ROOT) + list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) + if( _ACML_ROOT ) get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) if( SIZEOF_INTEGER EQUAL 8 ) - set( _ACML_PATH_SUFFIX "_int64" ) + set( _ACML_PATH_SUFFIX "_int64" ) + else() + set( _ACML_PATH_SUFFIX "" ) + endif() + if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) + set( _ACML_COMPILER32 "ifort32" ) + set( _ACML_COMPILER64 "ifort64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) + set( _ACML_COMPILER32 "sun32" ) + set( _ACML_COMPILER64 "sun64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) + set( _ACML_COMPILER32 "pgi32" ) + if( WIN32 ) + set( _ACML_COMPILER64 "win64" ) + else() + set( _ACML_COMPILER64 "pgi64" ) + endif() + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + # 32 bit builds not supported on Open64 but for code simplicity + # We'll just use the same directory twice + set( _ACML_COMPILER32 "open64_64" ) + set( _ACML_COMPILER64 "open64_64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) + set( _ACML_COMPILER32 "nag32" ) + set( _ACML_COMPILER64 "nag64" ) else() - set( _ACML_PATH_SUFFIX "" ) - endif() - if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) - set( _ACML_COMPILER32 "ifort32" ) - set( _ACML_COMPILER64 "ifort64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) - set( _ACML_COMPILER32 "sun32" ) - set( _ACML_COMPILER64 "sun64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) - set( _ACML_COMPILER32 "pgi32" ) - if( WIN32 ) - set( _ACML_COMPILER64 "win64" ) + set( _ACML_COMPILER32 "gfortran32" ) + set( _ACML_COMPILER64 "gfortran64" ) + endif() + + if( BLA_VENDOR STREQUAL "ACML_MP" ) + set(_ACML_MP_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) else() - set( _ACML_COMPILER64 "pgi64" ) + set(_ACML_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) endif() - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) - # 32 bit builds not supported on Open64 but for code simplicity - # We'll just use the same directory twice - set( _ACML_COMPILER32 "open64_64" ) - set( _ACML_COMPILER64 "open64_64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) - set( _ACML_COMPILER32 "nag32" ) - set( _ACML_COMPILER64 "nag64" ) - else() - set( _ACML_COMPILER32 "gfortran32" ) - set( _ACML_COMPILER64 "gfortran64" ) - endif() - - if( BLA_VENDOR STREQUAL "ACML_MP" ) - set(_ACML_MP_LIB_DIRS - "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) - else() - set(_ACML_LIB_DIRS - "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) - endif() endif() - elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) - set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) - endif() +elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) +endif() - if( BLA_VENDOR STREQUAL "ACML_MP" ) +if( BLA_VENDOR STREQUAL "ACML_MP" ) foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() endforeach() - elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) +elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() endforeach() - else() +else() foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() endforeach() - endif() +endif() - # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both - if(NOT BLAS_LIBRARIES) +# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both +if(NOT BLAS_LIBRARIES) check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml;acml_mv" - "" - ) - endif() - if(NOT BLAS_LIBRARIES) + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv" + "" + ) +endif() +if(NOT BLAS_LIBRARIES) check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml_mp;acml_mv" - "" - ) - endif() - if(NOT BLAS_LIBRARIES) + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml_mp;acml_mv" + "" + ) +endif() +if(NOT BLAS_LIBRARIES) check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml;acml_mv;CALBLAS" - "" - ) - endif() + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv;CALBLAS" + "" + ) +endif() endif () # ACML # Apple BLAS library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") -if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "Accelerate" - "" - ) - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "Accelerate" + "" + ) + endif() endif () if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if ( NOT BLAS_LIBRARIES ) + if ( NOT BLAS_LIBRARIES ) check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "vecLib" - "" - ) - endif () + BLAS_LIBRARIES + BLAS + dgemm + "" + "vecLib" + "" + ) + endif () endif () + # Generic BLAS library? if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "blas" - "" - ) - endif() -endif () - -#BLAS in intel mkl 10 library? (em64t 64bit) -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (NOT WIN32) - set(LM "-lm") - endif () - if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) - find_package(Threads) - else() - find_package(Threads REQUIRED) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "blas" + "" + ) endif() - - set(BLAS_SEARCH_LIBS "") - - if(BLA_F95) - set(BLAS_mkl_SEARCH_SYMBOL SGEMM) - set(_LIBRARIES BLAS95_LIBRARIES) - if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - - # Find the main file (32-bit or 64-bit) - set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - else () - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") - - # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") - endif () - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - endif () - endif () - else () - set(BLAS_mkl_SEARCH_SYMBOL sgemm) - set(_LIBRARIES BLAS_LIBRARIES) - if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - - # Find the main file (32-bit or 64-bit) - set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - else () - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel mkl_intel_thread mkl_core guide") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core guide") - - # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") - endif () - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - endif () - - #older vesions of intel mkl libs - if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl") - list(APPEND BLAS_SEARCH_LIBS - "mkl_ia32") - list(APPEND BLAS_SEARCH_LIBS - "mkl_em64t") - endif () - endif () - endif () - - foreach (IT ${BLAS_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if (NOT ${_LIBRARIES}) - check_fortran_libraries( - ${_LIBRARIES} - BLAS - ${BLAS_mkl_SEARCH_SYMBOL} - "" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - endif () - endforeach () - - endif () endif () if(BLA_F95) @@ -702,5 +733,11 @@ else() find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES) endif() +# On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines) +# we used a placeholder for empty BLAS_LIBRARIES to get through our logic above. +if (BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(BLAS_LIBRARIES "") +endif() + cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index d5e701170..3e011adfb 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -147,6 +147,9 @@ # used if multiple compatible suffixes should # be tested for, in decreasing order of # preference. +# Boost_ARCHITECTURE - Set to the architecture-specific library suffix +# (e.g. "-x64"). Default is auto-computed for the +# C++ compiler in use. # Boost_THREADAPI - Suffix for "thread" component library name, # such as "pthread" or "win32". Names with # and without this suffix will both be tried. @@ -410,11 +413,17 @@ endmacro() # Runs compiler with "-dumpversion" and parses major/minor # version with a regex. # -function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) - string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1\\2" - _boost_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) +function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION _OUTPUT_VERSION_MAJOR _OUTPUT_VERSION_MINOR) + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1" + _boost_COMPILER_VERSION_MAJOR ${CMAKE_CXX_COMPILER_VERSION}) + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\2" + _boost_COMPILER_VERSION_MINOR ${CMAKE_CXX_COMPILER_VERSION}) + + set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}${_boost_COMPILER_VERSION_MINOR}") set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) + set(${_OUTPUT_VERSION_MAJOR} ${_boost_COMPILER_VERSION_MAJOR} PARENT_SCOPE) + set(${_OUTPUT_VERSION_MINOR} ${_boost_COMPILER_VERSION_MINOR} PARENT_SCOPE) endfunction() # @@ -479,25 +488,35 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() - _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) + _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") endif() elseif (UNIX) - if (CMAKE_COMPILER_IS_GNUCXX) + _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) + if(NOT Boost_VERSION VERSION_LESS 106900) + # From GCC 5 and clang 4, versioning changes and minor becomes patch. + # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming. + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4) + set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 3) + set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") + endif() + endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() - _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) # Determine which version of GCC we have. if(APPLE) if(Boost_MINOR_VERSION) if(${Boost_MINOR_VERSION} GREATER 35) # In Boost 1.36.0 and newer, the mangled compiler name used - # on Mac OS X/Darwin is "xgcc". + # on macOS/Darwin is "xgcc". set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") else() # In Boost <= 1.35.0, there is no mangled compiler name for - # the Mac OS X/Darwin version of GCC. + # the macOS/Darwin version of GCC. set(_boost_COMPILER "") endif() else() @@ -509,7 +528,10 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") endif() endif() - endif () + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # TODO: Find out any Boost version constraints vs clang support. + set(_boost_COMPILER "-clang${_boost_COMPILER_VERSION}") + endif() else() # TODO at least Boost_DEBUG here? set(_boost_COMPILER "") @@ -573,7 +595,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) endif() set(_Boost_IMPORTED_TARGETS TRUE) - if(Boost_VERSION VERSION_LESS 103300) + if(Boost_VERSION AND Boost_VERSION VERSION_LESS 103300) message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION} (all versions older than 1.33)") set(_Boost_IMPORTED_TARGETS FALSE) elseif(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500) @@ -823,27 +845,41 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(NOT Boost_VERSION VERSION_LESS 106800 AND Boost_VERSION VERSION_LESS 106900) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_TIMER_DEPENDENCIES chrono system) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() - if(NOT Boost_VERSION VERSION_LESS 106800) - set(_Boost_CHRONO_DEPENDENCIES system) - set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) - set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) - set(_Boost_COROUTINE_DEPENDENCIES context system) - set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) - set(_Boost_FILESYSTEM_DEPENDENCIES system) + if(NOT Boost_VERSION VERSION_LESS 106900) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) + set(_Boost_COROUTINE_DEPENDENCIES context) + set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) - set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) - set(_Boost_RANDOM_DEPENDENCIES system) - set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) - set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) endif() - if(NOT Boost_VERSION VERSION_LESS 106900) + if(NOT Boost_VERSION VERSION_LESS 107000) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -914,6 +950,12 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_REGEX_HEADERS "boost/regex.hpp") set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp") set(_Boost_SIGNALS_HEADERS "boost/signals.hpp") + set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_NOOP_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_WINDBG_CACHED_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_WINDBG_HEADERS "boost/stacktrace.hpp") set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp") set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp") set(_Boost_THREAD_HEADERS "boost/thread.hpp") @@ -1085,6 +1127,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65" "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55" @@ -1478,27 +1521,35 @@ endif() # -x86 Architecture and address model tag # First character is the architecture, then word-size, either 32 or 64 # Only used in 'versioned' layout, added in Boost 1.66.0 -set(_boost_ARCHITECTURE_TAG "") -# {CMAKE_CXX_COMPILER_ARCHITECTURE_ID} is not currently set for all compilers -if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION VERSION_LESS 106600) - string(APPEND _boost_ARCHITECTURE_TAG "-") - # This needs to be kept in-sync with the section of CMakePlatformId.h.in - # inside 'defined(_WIN32) && defined(_MSC_VER)' - if(${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} STREQUAL "IA64") - string(APPEND _boost_ARCHITECTURE_TAG "i") - elseif(${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} STREQUAL "X86" - OR ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} STREQUAL "x64") - string(APPEND _boost_ARCHITECTURE_TAG "x") - elseif(${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} MATCHES "^ARM") - string(APPEND _boost_ARCHITECTURE_TAG "a") - elseif(${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} STREQUAL "MIPS") - string(APPEND _boost_ARCHITECTURE_TAG "m") +if(DEFINED Boost_ARCHITECTURE) + set(_boost_ARCHITECTURE_TAG "${Boost_ARCHITECTURE}") + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "using user-specified Boost_ARCHITECTURE = ${_boost_ARCHITECTURE_TAG}") endif() +else() + set(_boost_ARCHITECTURE_TAG "") + # {CMAKE_CXX_COMPILER_ARCHITECTURE_ID} is not currently set for all compilers + if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION VERSION_LESS 106600) + string(APPEND _boost_ARCHITECTURE_TAG "-") + # This needs to be kept in-sync with the section of CMakePlatformId.h.in + # inside 'defined(_WIN32) && defined(_MSC_VER)' + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "IA64") + string(APPEND _boost_ARCHITECTURE_TAG "i") + elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "X86" + OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "x64") + string(APPEND _boost_ARCHITECTURE_TAG "x") + elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "^ARM") + string(APPEND _boost_ARCHITECTURE_TAG "a") + elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "MIPS") + string(APPEND _boost_ARCHITECTURE_TAG "m") + endif() - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - string(APPEND _boost_ARCHITECTURE_TAG "64") - else() - string(APPEND _boost_ARCHITECTURE_TAG "32") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + string(APPEND _boost_ARCHITECTURE_TAG "64") + else() + string(APPEND _boost_ARCHITECTURE_TAG "32") + endif() endif() endif() @@ -1740,6 +1791,7 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") @@ -2041,6 +2093,9 @@ if(Boost_FOUND) message (STATUS " ${COMPONENT}") endif() list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY}) + if(COMPONENT STREQUAL "thread") + list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + endif() endif() endforeach() else() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 1650e55a7..3527979e7 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -43,7 +43,7 @@ # matches what is needed by the CUDA runtime version. # # The following variables affect the behavior of the macros in the -# script (in alphebetical order). Note that any of these flags can be +# script (in alphabetical order). Note that any of these flags can be # changed multiple times in the same directory before calling # ``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, # ``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` @@ -105,6 +105,8 @@ # the host compiler is constructed with one or more visual studio macros # such as $(VCInstallDir), that expands out to the path when # the command is run from within VS. +# If the CUDAHOSTCXX environment variable is set it will +# be used as the default. # # CUDA_NVCC_FLAGS # CUDA_NVCC_FLAGS_<CONFIG> @@ -147,7 +149,7 @@ # VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will # always print the output. # -# The script creates the following macros (in alphebetical order):: +# The script creates the following macros (in alphabetical order):: # # CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) # -- Adds the cufft library to the target (can be any target). Handles whether @@ -527,7 +529,9 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) # Extra user settable flags cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") -if(CMAKE_GENERATOR MATCHES "Visual Studio") +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") if(MSVC_VERSION LESS 1910) set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index cf4fc39df..1baf0515a 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -109,6 +109,9 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) RUN_OUTPUT_VARIABLE compute_capabilities) endif() + # Filter unrelated content out of the output. + string(REGEX MATCHALL "[0-9]+\\.[0-9]+" compute_capabilities "${compute_capabilities}") + if(run_result EQUAL 0) string(REPLACE "2.1" "2.1(2.0)" compute_capabilities "${compute_capabilities}") set(CUDA_GPU_DETECT_OUTPUT ${compute_capabilities} diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index a549765be..60ddf7b8f 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -34,17 +34,29 @@ find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) mark_as_advanced(CURL_INCLUDE_DIR) -# Look for the library (sorted from most current/relevant entry to least). -find_library(CURL_LIBRARY NAMES - curl - # Windows MSVC prebuilts: - curllib - libcurl_imp - curllib_static - # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): - libcurl -) -mark_as_advanced(CURL_LIBRARY) +if(NOT CURL_LIBRARY) + # Look for the library (sorted from most current/relevant entry to least). + find_library(CURL_LIBRARY_RELEASE NAMES + curl + # Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static + # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): + libcurl + ) + mark_as_advanced(CURL_LIBRARY_RELEASE) + + find_library(CURL_LIBRARY_DEBUG NAMES + # Windows MSVC CMake builds in debug configuration on vcpkg: + libcurl-d_imp + libcurl-d + ) + mark_as_advanced(CURL_LIBRARY_DEBUG) + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(CURL) +endif() if(CURL_INCLUDE_DIR) foreach(_curl_version_header curlver.h curl.h) @@ -69,7 +81,27 @@ if(CURL_FOUND) if(NOT TARGET CURL::libcurl) add_library(CURL::libcurl UNKNOWN IMPORTED) - set_target_properties(CURL::libcurl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}") - set_property(TARGET CURL::libcurl APPEND PROPERTY IMPORTED_LOCATION "${CURL_LIBRARY}") + set_target_properties(CURL::libcurl PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}") + + if(EXISTS "${CURL_LIBRARY}") + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${CURL_LIBRARY}") + endif() + if(CURL_LIBRARY_RELEASE) + set_property(TARGET CURL::libcurl APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") + endif() + if(CURL_LIBRARY_DEBUG) + set_property(TARGET CURL::libcurl APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") + endif() endif() endif() diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 88d4b2918..177968387 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -34,20 +34,30 @@ # GLUT_Xmu_LIBRARY = the full path to the Xmu library. # GLUT_Xi_LIBRARY = the full path to the Xi Library. +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + if (WIN32) find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h PATHS ${GLUT_ROOT_PATH}/include ) - find_library( GLUT_glut_LIBRARY NAMES glut glut32 freeglut + find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut PATHS ${OPENGL_LIBRARY_DIR} ${GLUT_ROOT_PATH}/Release ) + find_library( GLUT_glut_LIBRARY_DEBUG NAMES freeglutd + PATHS + ${OPENGL_LIBRARY_DIR} + ${GLUT_ROOT_PATH}/Debug + ) + mark_as_advanced(GLUT_glut_LIBRARY_RELEASE GLUT_glut_LIBRARY_DEBUG) + select_library_configurations(GLUT_glut) else () if (APPLE) find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") + mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa) add_library(GLUT::Cocoa UNKNOWN IMPORTED) @@ -72,10 +82,12 @@ else () find_library( GLUT_Xi_LIBRARY Xi /usr/openwin/lib ) + mark_as_advanced(GLUT_Xi_LIBRARY) find_library( GLUT_Xmu_LIBRARY Xmu /usr/openwin/lib ) + mark_as_advanced(GLUT_Xmu_LIBRARY) if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi) add_library(GLUT::Xi UNKNOWN IMPORTED) @@ -104,6 +116,7 @@ else () /usr/openwin/lib ${_GLUT_glut_LIB_DIR} ) + mark_as_advanced(GLUT_glut_LIBRARY) unset(_GLUT_INC_DIR) unset(_GLUT_glut_LIB_DIR) @@ -135,8 +148,24 @@ if (GLUT_FOUND) set_target_properties(GLUT::GLUT PROPERTIES IMPORTED_LOCATION "${GLUT_glut_LIBRARY}/${CMAKE_MATCH_1}") else() - set_target_properties(GLUT::GLUT PROPERTIES - IMPORTED_LOCATION "${GLUT_glut_LIBRARY}") + if(GLUT_glut_LIBRARY_RELEASE) + set_property(TARGET GLUT::GLUT APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(GLUT::GLUT PROPERTIES + IMPORTED_LOCATION_RELEASE "${GLUT_glut_LIBRARY_RELEASE}") + endif() + + if(GLUT_glut_LIBRARY_DEBUG) + set_property(TARGET GLUT::GLUT APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(GLUT::GLUT PROPERTIES + IMPORTED_LOCATION_DEBUG "${GLUT_glut_LIBRARY_DEBUG}") + endif() + + if(NOT GLUT_glut_LIBRARY_RELEASE AND NOT GLUT_glut_LIBRARY_DEBUG) + set_property(TARGET GLUT::GLUT APPEND PROPERTY + IMPORTED_LOCATION "${GLUT_glut_LIBRARY}") + endif() endif() if(TARGET GLUT::Xmu) @@ -160,9 +189,4 @@ if (GLUT_FOUND) set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR}) endif() -mark_as_advanced( - GLUT_INCLUDE_DIR - GLUT_glut_LIBRARY - GLUT_Xmu_LIBRARY - GLUT_Xi_LIBRARY - ) +mark_as_advanced(GLUT_INCLUDE_DIR) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 4913e05e7..fdddcc7e0 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -1,29 +1,49 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindJNI -# ------- -# -# Find JNI java libraries. -# -# This module finds if Java is installed and determines where the -# include files and libraries are. It also determines what the name of -# the library is. The caller may set variable JAVA_HOME to specify a -# Java installation prefix explicitly. -# -# This module sets the following result variables: -# -# :: -# -# JNI_INCLUDE_DIRS = the include dirs to use -# JNI_LIBRARIES = the libraries to use -# JNI_FOUND = TRUE if JNI headers and libraries were found. -# JAVA_AWT_LIBRARY = the path to the jawt library -# JAVA_JVM_LIBRARY = the path to the jvm library -# JAVA_INCLUDE_PATH = the include path to jni.h -# JAVA_INCLUDE_PATH2 = the include path to jni_md.h -# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h +#[=======================================================================[.rst: +FindJNI +------- + +Find Java Native Interface (JNI) libraries. + +JNI enables Java code running in a Java Virtual Machine (JVM) to call +and be called by native applications and libraries written in other +languages such as C, C++. + +This module finds if Java is installed and determines where the +include files and libraries are. It also determines what the name of +the library is. The caller may set variable ``JAVA_HOME`` to specify a +Java installation prefix explicitly. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following result variables: + +``JNI_INCLUDE_DIRS`` + the include dirs to use +``JNI_LIBRARIES`` + the libraries to use (JAWT and JVM) +``JNI_FOUND`` + TRUE if JNI headers and libraries were found. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables are also available to set or use: + +``JAVA_AWT_LIBRARY`` + the path to the Java AWT Native Interface (JAWT) library +``JAVA_JVM_LIBRARY`` + the path to the Java Virtual Machine (JVM) library +``JAVA_INCLUDE_PATH`` + the include path to jni.h +``JAVA_INCLUDE_PATH2`` + the include path to jni_md.h and jniport.h +``JAVA_AWT_INCLUDE_PATH`` + the include path to jawt.h +#]=======================================================================] # Expand {libarch} occurrences to java_libarch subdirectory(-ies) and set ${_var} macro(java_append_library_directories _var) @@ -187,6 +207,7 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/lib/jvm/default/jre/lib/{libarch} /usr/lib/jvm/default/lib/{libarch} # Ubuntu specific paths for default JVM + /usr/lib/jvm/java-11-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 18.04 LTS /usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10 /usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10 /usr/lib/jvm/java-6-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10 diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index cddc5d21f..bcdf166fd 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -8,19 +8,19 @@ # Find Java # # This module finds if Java is installed and determines where the -# include files and libraries are. The caller may set variable JAVA_HOME +# 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. +# See also the :module:`FindJNI` module to find Java Native Interface (JNI). # # Specify one or more of the following components as you call this find module. See example below. # # :: # -# Runtime = User just want to execute some Java byte-compiled +# Runtime = Java Runtime Environment used to execute Java byte-compiled applications # Development = Development tools (java, javac, javah, jar and javadoc), includes Runtime component -# IdlJ = idl compiler for Java -# JarSigner = signer tool for jar +# IdlJ = Interface Description Language (IDL) to Java compiler +# JarSigner = Signer and verifier tool for Java Archive (JAR) files # # # This module sets the following result variables: @@ -44,14 +44,18 @@ # # # The minimum required version of Java can be specified using the -# standard CMake syntax, e.g. find_package(Java 1.5) +# :command:`find_package` syntax, e.g. # -# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to +# .. code-block:: cmake +# +# find_package(Java 1.8) +# +# NOTE: ``${Java_VERSION}`` and ``${Java_VERSION_STRING}`` are not guaranteed to # be identical. For example some java version may return: -# Java_VERSION_STRING = 1.5.0_17 and Java_VERSION = 1.5.0.17 +# ``Java_VERSION_STRING = 1.8.0_17`` and ``Java_VERSION = 1.8.0.17`` # -# another example is the Java OEM, with: Java_VERSION_STRING = 1.6.0-oem -# and Java_VERSION = 1.6.0 +# another example is the Java OEM, with: ``Java_VERSION_STRING = 1.8.0-oem`` +# and ``Java_VERSION = 1.8.0`` # # For these components the following variables are set: # @@ -67,6 +71,7 @@ # :: # # find_package(Java) +# find_package(Java 1.8 REQUIRED) # find_package(Java COMPONENTS Runtime) # find_package(Java COMPONENTS Development) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index a3c87f81e..2c6145afb 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -278,10 +278,16 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") find_package(Threads REQUIRED) endif() + if (BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else () + set(BLAS_mkl_ILP_MODE "lp64") + endif () + set(LAPACK_SEARCH_LIBS "") if (BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV") + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") set(_LIBRARIES LAPACK95_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) @@ -292,7 +298,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND LAPACK_SEARCH_LIBS "mkl_intel_c") list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_lp64") + "mkl_lapack95_${BLAS_mkl_ILP_MODE}") else() set(LAPACK_mkl_SEARCH_SYMBOL "cheev") set(_LIBRARIES LAPACK_LIBRARIES) @@ -303,7 +309,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "mkl_lapack") # new >= 10.3 list(APPEND LAPACK_SEARCH_LIBS - "mkl_gf_lp64") + "mkl_gf_${BLAS_mkl_ILP_MODE}") endif() # First try empty lapack libs @@ -332,6 +338,8 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") ) endif () endforeach () + + unset(BLAS_mkl_ILP_MODE) endif () endif() else() diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index b57a46ede..68530b353 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -42,13 +42,6 @@ cmake_policy(SET CMP0012 NEW) # For while(TRUE) unset(_lua_include_subdirs) unset(_lua_library_names) unset(_lua_append_versions) -set(_lua_additional_paths - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt) # this is a function only to have all the variables inside go away automatically function(_lua_get_versions) @@ -161,7 +154,6 @@ function(_lua_find_header) HINTS ENV LUA_DIR PATH_SUFFIXES ${subdir} - PATHS ${_lua_additional_paths} ) if (LUA_INCLUDE_DIR) break() @@ -206,10 +198,10 @@ endif () find_library(LUA_LIBRARY NAMES ${_lua_library_names} lua + NAMES_PER_DIR HINTS ENV LUA_DIR PATH_SUFFIXES lib - PATHS ${_lua_additional_paths} ) unset(_lua_library_names) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index bfcd87660..b94e69eac 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1131,7 +1131,12 @@ macro(_MPI_create_imported_target LANG) add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) endif() - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'. + string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread" + _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") + unset(_MPI_${LANG}_COMPILE_OPTIONS) + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index d765bdf47..547a33085 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -21,10 +21,13 @@ # # * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``MX``, # ``ENG`` and ``MAT`` libraries of Matlab +# * ``ENGINE_LIBRARY``, ``DATAARRAY_LIBRARY``: respectively the ``MatlabEngine`` +# and ``MatlabDataArray`` libraries of Matlab (Matlab 2018a and later) # * ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not # available on the MCR version, and will yield an error if the MCR is found # instead of the regular Matlab installation. # * ``MEX_COMPILER`` the MEX compiler. +# * ``MCC_COMPILER`` the MCC compiler, included with the Matlab Compiler add-on. # * ``SIMULINK`` the Simulink environment. # # .. note:: @@ -106,11 +109,20 @@ # ``Matlab_MAT_LIBRARY`` # Matlab matrix library. Available only if the component ``MAT_LIBRARY`` # is requested. +# ``Matlab_ENGINE_LIBRARY`` +# Matlab C++ engine library. Available only if the component ``ENGINE_LIBRARY`` +# is requested. +# ``Matlab_DATAARRAY_LIBRARY`` +# Matlab C++ data array library. Available only if the component ``DATAARRAY_LIBRARY`` +# is requested. # ``Matlab_LIBRARIES`` # the whole set of libraries of Matlab # ``Matlab_MEX_COMPILER`` # the mex compiler of Matlab. Currently not used. -# Available only if the component ``MEX_COMPILER`` is asked +# Available only if the component ``MEX_COMPILER`` is requested. +# ``Matlab_MCC_COMPILER`` +# the mcc compiler of Matlab. Included with the Matlab Compiler add-on. +# Available only if the component ``MCC_COMPILER`` is requested. # # Cached variables # """""""""""""""" @@ -230,6 +242,8 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS) endif() set(MATLAB_VERSIONS_MAPPING + "R2018b=9.5" + "R2018a=9.4" "R2017b=9.3" "R2017a=9.2" "R2016b=9.1" @@ -956,6 +970,14 @@ function(matlab_add_mex) target_link_libraries(${${prefix}_NAME} ${Matlab_MX_LIBRARY}) endif() + if(DEFINED Matlab_ENGINE_LIBRARY) + target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY}) + endif() + + if(DEFINED Matlab_DATAARRAY_LIBRARY) + target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY}) + endif() + target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${${prefix}_LINK_TO}) set_target_properties(${${prefix}_NAME} PROPERTIES @@ -976,6 +998,20 @@ function(matlab_add_mex) endif() # documentation # entry point in the mex file + taking care of visibility and symbol clashes. + if (MSVC) + get_target_property( + _previous_link_flags + ${${prefix}_NAME} + LINK_FLAGS) + if(NOT _previous_link_flags) + set(_previous_link_flags) + endif() + + set_target_properties(${${prefix}_NAME} + PROPERTIES + LINK_FLAGS "${_previous_link_flags} /EXPORT:mexFunction") + endif() + if(WIN32) set_target_properties(${${prefix}_NAME} PROPERTIES @@ -1356,7 +1392,7 @@ else() # if the user does not specify the possible installation root, we look for # one installation using the appropriate heuristics. # There is apparently no standard way on Linux. - if(WIN32) + if(CMAKE_HOST_WIN32) _Matlab_find_instances_win32(_matlab_possible_roots_win32) list(APPEND _matlab_possible_roots ${_matlab_possible_roots_win32}) elseif(APPLE) @@ -1407,10 +1443,13 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED) Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY Matlab_MEX_COMPILER + Matlab_MCC_COMPILER Matlab_MAIN_PROGRAM Matlab_MX_LIBRARY Matlab_ENG_LIBRARY Matlab_MAT_LIBRARY + Matlab_ENGINE_LIBRARY + Matlab_DATAARRAY_LIBRARY Matlab_MEX_EXTENSION Matlab_SIMULINK_INCLUDE_DIR @@ -1647,10 +1686,68 @@ if(_matlab_find_simulink GREATER -1) endif() unset(_matlab_find_simulink) +# component MCC Compiler +list(FIND Matlab_FIND_COMPONENTS MCC_COMPILER _matlab_find_mcc_compiler) +if(_matlab_find_mcc_compiler GREATER -1) + find_program( + Matlab_MCC_COMPILER + "mcc" + PATHS ${Matlab_BINARIES_DIR} + DOC "Matlab MCC compiler" + NO_DEFAULT_PATH + ) + if(Matlab_MCC_COMPILER) + set(Matlab_MCC_COMPILER_FOUND TRUE) + endif() +endif() +unset(_matlab_find_mcc_compiler) + +# component MatlabEngine +list(FIND Matlab_FIND_COMPONENTS ENGINE_LIBRARY _matlab_find_matlab_engine) +if(_matlab_find_matlab_engine GREATER -1) + _Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_ENGINE_LIBRARY + MatlabEngine + PATHS ${_matlab_lib_dir_for_search} + DOC "MatlabEngine Library" + NO_DEFAULT_PATH + ) + if(Matlab_ENGINE_LIBRARY) + set(Matlab_ENGINE_LIBRARY_FOUND TRUE) + endif() +endif() +unset(_matlab_find_matlab_engine) + +# component MatlabDataArray +list(FIND Matlab_FIND_COMPONENTS DATAARRAY_LIBRARY _matlab_find_matlab_dataarray) +if(_matlab_find_matlab_dataarray GREATER -1) + _Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_DATAARRAY_LIBRARY + MatlabDataArray + PATHS ${_matlab_lib_dir_for_search} + DOC "MatlabDataArray Library" + NO_DEFAULT_PATH + ) + if(Matlab_DATAARRAY_LIBRARY) + set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE) + endif() +endif() +unset(_matlab_find_matlab_dataarray) + unset(_matlab_lib_dir_for_search) set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}) +if(Matlab_DATAARRAY_LIBRARY_FOUND) + set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_DATAARRAY_LIBRARY}) +endif() + +if(Matlab_ENGINE_LIBRARY_FOUND) + set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_ENGINE_LIBRARY}) +endif() + find_package_handle_standard_args( Matlab FOUND_VAR Matlab_FOUND @@ -1671,6 +1768,8 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES) Matlab_MEX_LIBRARY Matlab_MX_LIBRARY Matlab_ENG_LIBRARY + Matlab_ENGINE_LIBRARY + Matlab_DATAARRAY_LIBRARY Matlab_MAT_LIBRARY Matlab_INCLUDE_DIRS Matlab_FOUND diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 297a5fba7..fe162b49b 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -119,16 +119,27 @@ if(WIN32) OpenCL/common/lib/x64) endif() else() - find_library(OpenCL_LIBRARY - NAMES OpenCL - PATHS - ENV AMDAPPSDKROOT - ENV CUDA_PATH - PATH_SUFFIXES - lib/x86_64 - lib/x64 - lib - lib64) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS + ENV AMDAPPSDKROOT + ENV CUDA_PATH + PATH_SUFFIXES + lib/x86 + lib) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS + ENV AMDAPPSDKROOT + ENV CUDA_PATH + PATH_SUFFIXES + lib/x86_64 + lib/x64 + lib + lib64) + endif() endif() set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index df0bbc433..cbc6ed846 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -124,7 +124,7 @@ endfunction() set(OpenMP_C_CXX_TEST_SOURCE " #include <omp.h> -int main() { +int main(void) { #ifdef _OPENMP omp_get_max_threads(); return 0; @@ -270,6 +270,9 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) break() endif() endif() + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting ${LANG} OpenMP failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n") endif() set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE) set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE) @@ -291,7 +294,7 @@ const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M', ('0' + ((_OPENMP/10)%10)), ('0' + ((_OPENMP/1)%10)), ']', '\\0' }; -int main() +int main(void) { puts(ompver_str); return 0; @@ -324,7 +327,8 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" - COPY_FILE ${BIN_FILE}) + COPY_FILE ${BIN_FILE} + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") @@ -332,6 +336,9 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) if("${specstr}" MATCHES "${regex_spec_date}") set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE) endif() + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting ${LANG} OpenMP version failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n") endif() endfunction() diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake index a197e4d2b..91545e0ea 100644 --- a/Modules/FindOpenThreads.cmake +++ b/Modules/FindOpenThreads.cmake @@ -47,6 +47,8 @@ # standard install paths. # Explicit -DVAR=value arguments should still be able to override everything. +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread HINTS ENV OPENTHREADS_INCLUDE_DIR @@ -62,7 +64,7 @@ find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread ) -find_library(OPENTHREADS_LIBRARY +find_library(OPENTHREADS_LIBRARY_RELEASE NAMES OpenThreads OpenThreadsWin32 HINTS ENV OPENTHREADS_LIBRARY_DIR @@ -93,13 +95,7 @@ find_library(OPENTHREADS_LIBRARY_DEBUG PATH_SUFFIXES lib ) -if(OPENTHREADS_LIBRARY_DEBUG) - set(OPENTHREADS_LIBRARIES - optimized ${OPENTHREADS_LIBRARY} - debug ${OPENTHREADS_LIBRARY_DEBUG}) -else() - set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY}) -endif() +select_library_configurations(OPENTHREADS) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 67f6bd6f2..1722d6aaf 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -145,7 +145,7 @@ endmacro() # internal helper macro to generate the failure message when used in CONFIG_MODE: macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + # <PackageName>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: if(${_NAME}_CONFIG) _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") else() @@ -199,7 +199,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") endif() - # In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package() + # In config-mode, we rely on the variable <PackageName>_CONFIG, which is set by find_package() # when it successfully found the config-file, including version checking: if(FPHSA_CONFIG_MODE) list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 775a9d7d0..06beb7d84 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -114,12 +114,13 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) set(${_is_req} 0) set(${_is_silent} 0) set(${_no_cmake_path} 0) set(${_no_cmake_environment_path} 0) set(${_imp_target} 0) + set(${_imp_target_global} 0) if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) set(${_no_cmake_path} 1) @@ -146,14 +147,22 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma if (_pkg STREQUAL "IMPORTED_TARGET") set(${_imp_target} 1) endif() + if (_pkg STREQUAL "GLOBAL") + set(${_imp_target_global} 1) + endif() endforeach() + if (${_imp_target_global} AND NOT ${_imp_target}) + message(SEND_ERROR "the argument GLOBAL may only be used together with IMPORTED_TARGET") + endif() + set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") list(REMOVE_ITEM ${_result} "QUIET") list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") list(REMOVE_ITEM ${_result} "IMPORTED_TARGET") + list(REMOVE_ITEM ${_result} "GLOBAL") endmacro() # Add the content of a variable or an environment variable to a list of @@ -225,11 +234,16 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) endfunction() # create an imported target from all the information returned by pkg-config -function(_pkg_create_imp_target _prefix) +function(_pkg_create_imp_target _prefix _imp_target_global) # only create the target if it is linkable, i.e. no executables if (NOT TARGET PkgConfig::${_prefix} AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_CFLAGS_OTHER )) - add_library(PkgConfig::${_prefix} INTERFACE IMPORTED) + if(${_imp_target_global}) + set(_global_opt "GLOBAL") + else() + unset(_global_opt) + endif() + add_library(PkgConfig::${_prefix} INTERFACE IMPORTED ${_global_opt}) if(${_prefix}_INCLUDE_DIRS) set_property(TARGET PkgConfig::${_prefix} PROPERTY @@ -248,15 +262,15 @@ endfunction() # recalculate the dynamic output # this is a macro and not a function so the result of _pkg_find_libs is automatically propagated -macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target) +macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path}) if(${_imp_target}) - _pkg_create_imp_target(${_prefix}) + _pkg_create_imp_target(${_prefix} ${_imp_target_global}) endif() endmacro() ### -macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -383,7 +397,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma set(_pkg_check_modules_exist_query) # check whether version is given - if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)") + if (_pkg_check_modules_pkg MATCHES "(.*[^><])(=|[><]=?)(.*)") set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}") set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}") set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}") @@ -401,9 +415,11 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") # create the final query which is of the format: + # * <pkg-name> > <version> # * <pkg-name> >= <version> # * <pkg-name> = <version> # * <pkg-name> <= <version> + # * <pkg-name> < <version> # * --exists <pkg-name> list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors) if (_pkg_check_modules_pkg_op) @@ -474,7 +490,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) endif() if(NOT "${_extra_paths}" STREQUAL "") @@ -502,7 +518,7 @@ endmacro() [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] - [IMPORTED_TARGET] + [IMPORTED_TARGET [GLOBAL]] <moduleSpec> [<moduleSpec>...]) When the ``REQUIRED`` argument is given, the command will fail with an error @@ -521,14 +537,18 @@ endmacro() The ``IMPORTED_TARGET`` argument will create an imported target named ``PkgConfig::<prefix>`` that can be passed directly as an argument to - :command:`target_link_libraries`. + :command:`target_link_libraries`. The ``GLOBAL`` argument will make the + imported target available in global scope. - Each ``<moduleSpec>`` must be in one of the following formats:: + Each ``<moduleSpec>`` can be either a bare module name or it can be a + module name with a version constraint (operators ``=``, ``<``, ``>``, + ``<=`` and ``>=`` are supported). The following are examples for a module + named ``foo`` with various constraints:: - {moduleName} ... matches any version - {moduleName}>={version} ... at least version <version> is required - {moduleName}={version} ... exactly version <version> is required - {moduleName}<={version} ... modules must not be newer than <version> + foo # Any version matches + foo<2 # Only match versions before 2 + foo>=3.1 # Match any version from 3.1 or later + foo=1.2.3 # Foo must be exactly version 1.2.3 The following variables may be set upon return. Two sets of values exist, one for the common case (``<XXX> = <prefix>``) and another for the @@ -594,12 +614,12 @@ endmacro() XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp #]========================================] macro(pkg_check_modules _prefix _module0) - _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR (NOT "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") OR ( "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0}")) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) if (${_prefix}_FOUND) @@ -607,7 +627,7 @@ macro(pkg_check_modules _prefix _module0) endif() else() if (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) endif() endif() endmacro() @@ -624,7 +644,7 @@ endmacro() [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] - [IMPORTED_TARGET] + [IMPORTED_TARGET [GLOBAL]] <moduleSpec> [<moduleSpec>...]) Examples @@ -634,7 +654,7 @@ endmacro() pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) #]========================================] macro(pkg_search_module _prefix _module0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) @@ -646,7 +666,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -662,7 +682,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) elseif (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) endif() endmacro() diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 3f6fa6c0f..c044ab3b7 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -27,7 +27,7 @@ # In Windows the default installation of PostgreSQL uses that as part of the path. # E.g C:\Program Files\PostgreSQL\8.4. # Currently, the following version numbers are known to this module: -# "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" # # To use this variable just do something like this: # set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") @@ -71,7 +71,7 @@ set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to wher set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} - "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") # Define additional search paths for root directories. set( PostgreSQL_ROOT_DIRECTORIES diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index e1a715e66..eda036158 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -119,115 +119,140 @@ # ``ARGN`` # ``.proto`` filess -function(PROTOBUF_GENERATE_CPP SRCS HDRS) - cmake_parse_arguments(protobuf "" "EXPORT_MACRO;DESCRIPTORS" "" ${ARGN}) +function(protobuf_generate) + include(CMakeParseArguments) - set(PROTO_FILES "${protobuf_UNPARSED_ARGUMENTS}") - if(NOT PROTO_FILES) - message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files") + set(_options APPEND_PATH DESCRIPTORS) + set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR) + if(COMMAND target_sources) + list(APPEND _singleargs TARGET) + endif() + set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS) + + cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}") + + if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET) + message(SEND_ERROR "Error: protobuf_generate called without any targets or source files") return() endif() - if(protobuf_EXPORT_MACRO) - set(DLL_EXPORT_DECL "dllexport_decl=${protobuf_EXPORT_MACRO}:") + if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET) + message(SEND_ERROR "Error: protobuf_generate called without a target or output variable") + return() endif() - if(PROTOBUF_GENERATE_CPP_APPEND_PATH) - # Create an include path for each file specified - foreach(FIL ${PROTO_FILES}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + if(NOT protobuf_generate_LANGUAGE) + set(protobuf_generate_LANGUAGE cpp) endif() + string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE) - if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS) - set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}") + if(NOT protobuf_generate_PROTOC_OUT_DIR) + set(protobuf_generate_PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() - if(DEFINED Protobuf_IMPORT_DIRS) - foreach(DIR ${Protobuf_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) + if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp) + set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:") + endif() + + if(NOT protobuf_generate_GENERATE_EXTENSIONS) + if(protobuf_generate_LANGUAGE STREQUAL cpp) + set(protobuf_generate_GENERATE_EXTENSIONS .pb.h .pb.cc) + elseif(protobuf_generate_LANGUAGE STREQUAL python) + set(protobuf_generate_GENERATE_EXTENSIONS _pb2.py) + else() + message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a value for GENERATE_EXTENSIONS") + return() + endif() + endif() + + if(protobuf_generate_TARGET) + get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES) + foreach(_file ${_source_list}) + if(_file MATCHES "proto$") + list(APPEND protobuf_generate_PROTOS ${_file}) endif() endforeach() endif() - set(${SRCS}) - set(${HDRS}) - if (protobuf_DESCRIPTORS) - set(${protobuf_DESCRIPTORS}) + if(NOT protobuf_generate_PROTOS) + message(SEND_ERROR "Error: protobuf_generate could not find any .proto files") + return() endif() - foreach(FIL ${PROTO_FILES}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH) - get_filename_component(FIL_DIR ${FIL} DIRECTORY) - if(FIL_DIR) - set(FIL_WE "${FIL_DIR}/${FIL_WE}") + if(protobuf_generate_APPEND_PATH) + # Create an include path for each file specified + foreach(_file ${protobuf_generate_PROTOS}) + get_filename_component(_abs_file ${_file} ABSOLUTE) + get_filename_component(_abs_path ${_abs_file} PATH) + list(FIND _protobuf_include_path ${_abs_path} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${_abs_path}) endif() + endforeach() + else() + set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + + foreach(DIR ${protobuf_generate_IMPORT_DIRS}) + get_filename_component(ABS_PATH ${DIR} ABSOLUTE) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) endif() + endforeach() - set(_protobuf_protoc_src "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") - set(_protobuf_protoc_hdr "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") - list(APPEND ${SRCS} "${_protobuf_protoc_src}") - list(APPEND ${HDRS} "${_protobuf_protoc_hdr}") + set(_generated_srcs_all) + foreach(_proto ${protobuf_generate_PROTOS}) + get_filename_component(_abs_file ${_proto} ABSOLUTE) + get_filename_component(_abs_dir ${_abs_file} DIRECTORY) + get_filename_component(_basename ${_proto} NAME_WE) + file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir}) - if(protobuf_DESCRIPTORS) - set(_protobuf_protoc_desc "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.desc") - set(_protobuf_protoc_flags "--descriptor_set_out=${_protobuf_protoc_desc}") - list(APPEND ${protobuf_DESCRIPTORS} "${_protobuf_protoc_desc}") - else() - set(_protobuf_protoc_desc "") - set(_protobuf_protoc_flags "") + set(_generated_srcs) + foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS}) + list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_basename}${_ext}") + endforeach() + + if(protobuf_generate_DESCRIPTORS AND protobuf_generate_LANGUAGE STREQUAL cpp) + set(_descriptor_file "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.desc") + set(_dll_desc_out "--descriptor_set_out=${_descriptor_file}") + list(APPEND _generated_srcs ${_descriptor_file}) endif() + list(APPEND _generated_srcs_all ${_generated_srcs}) add_custom_command( - OUTPUT "${_protobuf_protoc_src}" - "${_protobuf_protoc_hdr}" - ${_protobuf_protoc_desc} + OUTPUT ${_generated_srcs} COMMAND protobuf::protoc - "--cpp_out=${DLL_EXPORT_DECL}${CMAKE_CURRENT_BINARY_DIR}" - ${_protobuf_protoc_flags} - ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} protobuf::protoc - COMMENT "Running C++ protocol buffer compiler on ${FIL}" + ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file} + DEPENDS ${_abs_file} protobuf::protoc + COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}" VERBATIM ) endforeach() - set(${SRCS} "${${SRCS}}" PARENT_SCOPE) - set(${HDRS} "${${HDRS}}" PARENT_SCOPE) - if(protobuf_DESCRIPTORS) - set(${protobuf_DESCRIPTORS} "${${protobuf_DESCRIPTORS}}" PARENT_SCOPE) + set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE) + if(protobuf_generate_OUT_VAR) + set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) + endif() + if(protobuf_generate_TARGET) + target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all}) endif() endfunction() -function(PROTOBUF_GENERATE_PYTHON SRCS) - if(NOT ARGN) - message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files") +function(PROTOBUF_GENERATE_CPP SRCS HDRS) + cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO;DESCRIPTORS" "" ${ARGN}) + + set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}") + if(NOT _proto_files) + message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files") return() endif() if(PROTOBUF_GENERATE_CPP_APPEND_PATH) - # Create an include path for each file specified - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + set(_append_arg APPEND_PATH) + endif() + + if(protobuf_generate_cpp_DESCRIPTORS) + set(_descriptors DESCRIPTORS) endif() if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS) @@ -235,36 +260,55 @@ function(PROTOBUF_GENERATE_PYTHON SRCS) endif() if(DEFINED Protobuf_IMPORT_DIRS) - foreach(DIR ${Protobuf_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() + set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS}) endif() + set(_outvar) + protobuf_generate(${_append_arg} ${_descriptors} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files}) + set(${SRCS}) - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH) - get_filename_component(FIL_DIR ${FIL} DIRECTORY) - if(FIL_DIR) - set(FIL_WE "${FIL_DIR}/${FIL_WE}") - endif() - endif() + set(${HDRS}) + if(protobuf_generate_cpp_DESCRIPTORS) + set(${protobuf_generate_cpp_DESCRIPTORS}) + endif() - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py") - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py" - COMMAND protobuf::protoc --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} protobuf::protoc - COMMENT "Running Python protocol buffer compiler on ${FIL}" - VERBATIM ) + foreach(_file ${_outvar}) + if(_file MATCHES "cc$") + list(APPEND ${SRCS} ${_file}) + elseif(_file MATCHES "desc$") + list(APPEND ${protobuf_generate_cpp_DESCRIPTORS} ${_file}) + else() + list(APPEND ${HDRS} ${_file}) + endif() endforeach() - set(${SRCS} ${${SRCS}} PARENT_SCOPE) + set(${HDRS} ${${HDRS}} PARENT_SCOPE) + if(protobuf_generate_cpp_DESCRIPTORS) + set(${protobuf_generate_cpp_DESCRIPTORS} "${${protobuf_generate_cpp_DESCRIPTORS}}" PARENT_SCOPE) + endif() +endfunction() + +function(PROTOBUF_GENERATE_PYTHON SRCS) + if(NOT ARGN) + message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files") + return() + endif() + + if(PROTOBUF_GENERATE_CPP_APPEND_PATH) + set(_append_arg APPEND_PATH) + endif() + + if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS) + set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}") + endif() + + if(DEFINED Protobuf_IMPORT_DIRS) + set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS}) + endif() + + set(_outvar) + protobuf_generate(${_append_arg} LANGUAGE python OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN}) + set(${SRCS} ${_outvar} PARENT_SCOPE) endfunction() @@ -337,21 +381,16 @@ function(_protobuf_find_libraries name filename) mark_as_advanced(${name}_LIBRARY_DEBUG) select_library_configurations(${name}) + + if(UNIX AND Threads_FOUND) + list(APPEND ${name}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + endif() + set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE) set(${name}_LIBRARIES "${${name}_LIBRARIES}" PARENT_SCOPE) endif() endfunction() -# Internal function: find threads library -function(_protobuf_find_threads) - set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - find_package(Threads) - if(Threads_FOUND) - list(APPEND Protobuf_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - set(Protobuf_LIBRARIES "${Protobuf_LIBRARIES}" PARENT_SCOPE) - endif() -endfunction() - # # Main. # @@ -372,6 +411,11 @@ if(MSVC) find_path(Protobuf_SRC_ROOT_FOLDER protobuf.pc.in) endif() +if(UNIX) + # Protobuf headers may depend on threading. + find_package(Threads QUIET) +endif() + # The Protobuf library _protobuf_find_libraries(Protobuf protobuf) #DOC "The Google Protocol Buffers RELEASE Library" @@ -386,10 +430,6 @@ if(MSVC) set(CMAKE_FIND_LIBRARY_PREFIXES "${Protobuf_ORIG_FIND_LIBRARY_PREFIXES}") endif() -if(UNIX) - _protobuf_find_threads() -endif() - # Find the include directory find_path(Protobuf_INCLUDE_DIR google/protobuf/service.h @@ -477,6 +517,10 @@ if(Protobuf_INCLUDE_DIR) set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_LOCATION_DEBUG "${Protobuf_LIBRARY_DEBUG}") endif() + if(UNIX AND TARGET Threads::Threads) + set_property(TARGET protobuf::libprotobuf APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Threads::Threads) + endif() endif() endif() @@ -501,6 +545,10 @@ if(Protobuf_INCLUDE_DIR) set_target_properties(protobuf::libprotobuf-lite PROPERTIES IMPORTED_LOCATION_DEBUG "${Protobuf_LITE_LIBRARY_DEBUG}") endif() + if(UNIX AND TARGET Threads::Threads) + set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Threads::Threads) + endif() endif() endif() @@ -525,6 +573,10 @@ if(Protobuf_INCLUDE_DIR) set_target_properties(protobuf::libprotoc PROPERTIES IMPORTED_LOCATION_DEBUG "${Protobuf_PROTOC_LIBRARY_DEBUG}") endif() + if(UNIX AND TARGET Threads::Threads) + set_property(TARGET protobuf::libprotoc APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Threads::Threads) + endif() endif() endif() diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 8139e53f0..8645a0db5 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -116,6 +116,31 @@ Hints * If set to TRUE, search **only** for static libraries. * If set to FALSE, search **only** for shared libraries. +``Python_FIND_REGISTRY`` + On Windows the ``Python_FIND_REGISTRY`` variable determine the order + of preference between registry and environment variables. + the ``Python_FIND_REGISTRY`` variable can be set to empty or one of the + following: + + * ``FIRST``: Try to use registry before environment variables. + This is the default. + * ``LAST``: Try to use registry after environment variables. + * ``NEVER``: Never try to use registry. + +``CMAKE_FIND_FRAMEWORK`` + On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of + preference between Apple-style and unix-style package components. + + .. note:: + + Value ``ONLY`` is not supported so ``FIRST`` will be used instead. + +.. note:: + + If a Python virtual environment is configured, set variable + ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with + value ``LAST`` or ``NEVER`` to select it preferably. + Commands ^^^^^^^^ diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index fe3df9119..e0ebb9033 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -44,9 +44,28 @@ macro (_PYTHON_DISPLAY_FAILURE _PYTHON_MSG) endmacro() +macro (_PYTHON_FIND_FRAMEWORKS) + set (${_PYTHON_PREFIX}_FRAMEWORKS) + if (APPLE) + set (_pff_frameworks ${CMAKE_FRAMEWORK_PATH} + $ENV{CMAKE_FRAMEWORK_PATH} + ~/Library/Frameworks + /usr/local/Frameworks + ${CMAKE_SYSTEM_FRAMEWORK_PATH}) + list (REMOVE_DUPLICATES _pff_frameworks) + foreach (_pff_framework IN LISTS _pff_frameworks) + if (EXISTS ${_pff_framework}/Python.framework) + list (APPEND ${_PYTHON_PREFIX}_FRAMEWORKS ${_pff_framework}/Python.framework) + endif() + endforeach() + unset (_pff_frameworks) + unset (_pff_framework) + endif() +endmacro() + function (_PYTHON_GET_FRAMEWORKS _PYTHON_PGF_FRAMEWORK_PATHS _PYTHON_VERSION) set (_PYTHON_FRAMEWORK_PATHS) - foreach (_PYTHON_FRAMEWORK IN LISTS Python_FRAMEWORKS) + foreach (_PYTHON_FRAMEWORK IN LISTS ${_PYTHON_PREFIX}_FRAMEWORKS) list (APPEND _PYTHON_FRAMEWORK_PATHS "${_PYTHON_FRAMEWORK}/Versions/${_PYTHON_VERSION}") endforeach() @@ -59,20 +78,43 @@ function (_PYTHON_VALIDATE_INTERPRETER) return() endif() - if (${_PYTHON_PREFIX}_EXECUTABLE MATCHES "python${CMAKE_EXECUTABLE_SUFFIX}$") - # executable found do not have version in name - # ensure major version is OK + if (ARGC EQUAL 1) + set (expected_version ${ARGV0}) + else() + unset (expected_version) + endif() + + get_filename_component (python_name "${${_PYTHON_PREFIX}_EXECUTABLE}" NAME) + + if (expected_version AND NOT python_name STREQUAL "python${expected_version}${CMAKE_EXECUTABLE_SUFFIX}") + # executable found must have a specific version execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys; sys.stdout.write(str(sys.version_info[0]))" + "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))" RESULT_VARIABLE result OUTPUT_VARIABLE version ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) + if (result OR NOT version EQUAL expected_version) # interpreter not usable or has wrong major version set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) return() endif() + else() + if (NOT python_name STREQUAL "python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}") + # executable found do not have version in name + # ensure major version is OK + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "import sys; sys.stdout.write(str(sys.version_info[0]))" + RESULT_VARIABLE result + OUTPUT_VARIABLE version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) + # interpreter not usable or has wrong major version + set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) + return() + endif() + endif() endif() if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS @@ -93,6 +135,33 @@ function (_PYTHON_VALIDATE_INTERPRETER) endfunction() +function (_PYTHON_VALIDATE_COMPILER expected_version) + if (NOT ${_PYTHON_PREFIX}_COMPILER) + return() + endif() + + # retrieve python environment version from compiler + set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir") + file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))\n") + execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py" + WORKING_DIRECTORY "${working_dir}" + OUTPUT_QUIET + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND "${working_dir}/version" + WORKING_DIRECTORY "${working_dir}" + RESULT_VARIABLE result + OUTPUT_VARIABLE version + ERROR_QUIET) + file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}") + + if (result OR NOT version EQUAL expected_version) + # Compiler not usable or has wrong major version + set (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE) + endif() +endfunction() + + function (_PYTHON_FIND_RUNTIME_LIBRARY _PYTHON_LIB) string (REPLACE "_RUNTIME" "" _PYTHON_LIB "${_PYTHON_LIB}") # look at runtime part on systems supporting it @@ -161,7 +230,7 @@ if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1) endif() endif() -# Anaconda distribution: define which architectures can be used +# Python and Anaconda distributions: define which architectures can be used if (CMAKE_SIZEOF_VOID_P) # In this case, search only for 64bit or 32bit math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8") @@ -181,19 +250,47 @@ else() # architecture unknown, search for natural interpreter set (_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES ipy) endif() +set (_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES net45 net40) # Apple frameworks handling -include (${CMAKE_CURRENT_LIST_DIR}/../CMakeFindFrameworks.cmake) -cmake_find_frameworks (Python) +_python_find_frameworks () + +# Save CMAKE_FIND_APPBUNDLE +if (DEFINED CMAKE_FIND_APPBUNDLE) + set (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE}) +else() + unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE) +endif() +# To avoid app bundle lookup +set (CMAKE_FIND_APPBUNDLE "NEVER") # Save CMAKE_FIND_FRAMEWORK if (DEFINED CMAKE_FIND_FRAMEWORK) set (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) + if (CMAKE_FIND_FRAMEWORK STREQUAL "ONLY") + message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: CMAKE_FIND_FRAMEWORK: 'ONLY' value is not supported. 'FIRST' will be used instead.") + set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST") + else() + set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) + endif() else() unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK) + set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST") +endif() +# To avoid framework lookup +set (CMAKE_FIND_FRAMEWORK "NEVER") + +# Windows Registry handling +if (DEFINED ${_PYTHON_PREFIX}_FIND_REGISTRY) + if (NOT ${_PYTHON_PREFIX}_FIND_REGISTRY MATCHES "^(FIRST|LAST|NEVER)$") + message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_REGISTRY}: invalid value for '${_PYTHON_PREFIX}_FIND_REGISTRY'. 'FIRST', 'LAST' or 'NEVER' expected.") + set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST") + else() + set (_${_PYTHON_PREFIX}_FIND_REGISTRY ${${_PYTHON_PREFIX}_FIND_REGISTRY}) + endif() +else() + set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST") endif() -# To avoid picking up the system elements pre-maturely. -set (CMAKE_FIND_FRAMEWORK LAST) unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) @@ -215,50 +312,133 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + # Apple frameworks handling + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + # Windows registry + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + # try using HINTS find_program (${_PYTHON_PREFIX}_EXECUTABLE NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - # try using registry + # try using standard paths. if (WIN32) find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_VERSION} python + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR) + else() + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + NAMES_PER_DIR) + endif() + + # Apple frameworks handling + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) + endif() + + # Windows registry + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - PATH_SUFFIXES bin - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) endif() - # try in standard paths - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_VERSION}) - _python_validate_interpreter () + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION}) if (${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endforeach() - # try more generic names if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) + # No specific version found. Retry with generic names + # try using HINTS find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python + NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin) + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + # try using standard paths. + # NAMES_PER_DIR is not defined on purpose to have a chance to find + # expected version. + # For example, typical systems have 'python' for version 2.* and 'python3' + # for version 3.*. So looking for names per dir will find, potentially, + # systematically 'python' (i.e. version 2) even if version 3 is searched. + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) _python_validate_interpreter () endif() @@ -291,6 +471,23 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() if (${_PYTHON_PREFIX}_Interpreter_FOUND) + if (NOT CMAKE_SIZEOF_VOID_P) + # determine interpreter architecture + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE ${_PYTHON_PREFIX}_IS64BIT + ERROR_VARIABLE ${_PYTHON_PREFIX}_IS64BIT) + if (NOT _${_PYTHON_PREFIX}_RESULT) + if (${_PYTHON_PREFIX}_IS64BIT) + set (_${_PYTHON_PREFIX}_ARCH 64) + set (_${_PYTHON_PREFIX}_ARCH2 64) + else() + set (_${_PYTHON_PREFIX}_ARCH 32) + set (_${_PYTHON_PREFIX}_ARCH2 32) + endif() + endif() + endif() + # retrieve interpreter identity execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -V RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT @@ -359,19 +556,42 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # try using root dir and registry foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + find_program (${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) + endif() + + _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION}) if (${_PYTHON_PREFIX}_COMPILER) break() endif() endforeach() - # try in standard paths + + # no specific version found, re-try in standard paths find_program (${_PYTHON_PREFIX}_COMPILER - NAMES ipyc) + NAMES ipyc + HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) if (${_PYTHON_PREFIX}_COMPILER) # retrieve python environment version from compiler @@ -483,6 +703,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "python${_${_PYTHON_PREFIX}_VERSION}-config") find_program (_${_PYTHON_PREFIX}_CONFIG NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES bin) unset (_${_PYTHON_PREFIX}_CONFIG_NAMES) @@ -490,6 +711,23 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (NOT _${_PYTHON_PREFIX}_CONFIG) continue() endif() + if (DEFINED CMAKE_LIBRARY_ARCHITECTURE) + # check that config tool match library architecture + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) + if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + endif() # retrieve root install directory execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --prefix @@ -571,7 +809,60 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - # search first in known locations + set (_${_PYTHON_PREFIX}_REGISTRY_PATHS + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]) + + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS} + python${_${_PYTHON_PREFIX}_VERSION}mu + python${_${_PYTHON_PREFIX}_VERSION}m + python${_${_PYTHON_PREFIX}_VERSION}u + python${_${_PYTHON_PREFIX}_VERSION} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}u + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION} + lib/python${_${_PYTHON_PREFIX}_VERSION}/config + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS} + python${_${_PYTHON_PREFIX}_VERSION}mu + python${_${_PYTHON_PREFIX}_VERSION}m + python${_${_PYTHON_PREFIX}_VERSION}u + python${_${_PYTHON_PREFIX}_VERSION} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}u + lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION} + lib/python${_${_PYTHON_PREFIX}_VERSION}/config + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + # search in HINTS locations find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS} python${_${_PYTHON_PREFIX}_VERSION}mu @@ -580,11 +871,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS python${_${_PYTHON_PREFIX}_VERSION} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m @@ -593,6 +879,19 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS lib/python${_${_PYTHON_PREFIX}_VERSION}/config NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS) + endif() + + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) + endif() + # search in all default paths find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS} @@ -601,6 +900,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS python${_${_PYTHON_PREFIX}_VERSION}u python${_${_PYTHON_PREFIX}_VERSION} NAMES_PER_DIR + PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m @@ -618,11 +919,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS python${_${_PYTHON_PREFIX}_VERSION} NAMES_PER_DIR HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] PATH_SUFFIXES bin) endif() @@ -632,27 +928,28 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # use library location as a hint get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d - NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} - NO_DEFAULT_PATH) - else() - # search first in known locations - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - PATH_SUFFIXES lib libs - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} + NO_DEFAULT_PATH) + else() + # search first in known locations + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG + NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES lib libs + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() # search in all default paths find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib libs) endif() if (${_PYTHON_PREFIX}_LIBRARY_DEBUG) @@ -661,10 +958,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d NAMES_PER_DIR HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} - PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] PATH_SUFFIXES bin) endif() endif() @@ -672,6 +965,21 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # Don't search for include dir until library location is known if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG) unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) + + if (${_PYTHON_PREFIX}_EXECUTABLE) + # pick up include directory from configuration + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "import sys; import sysconfig; sys.stdout.write(sysconfig.get_path('include'))" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PATH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${_PYTHON_PREFIX}_RESULT) + file (TO_CMAKE_PATH "${_${_PYTHON_PREFIX}_PATH}" _${_PYTHON_PREFIX}_PATH) + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PATH}") + endif() + endif() + foreach (_${_PYTHON_PREFIX}_LIB IN ITEMS ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG) if (${_${_PYTHON_PREFIX}_LIB}) # Use the library's install prefix as a hint @@ -691,14 +999,41 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endforeach() list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_HINTS) + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + NAMES Python.h + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu + include/python${_${_PYTHON_PREFIX}_VERSION}m + include/python${_${_PYTHON_PREFIX}_VERSION}u + include/python${_${_PYTHON_PREFIX}_VERSION} + include + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + NAMES Python.h + HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu + include/python${_${_PYTHON_PREFIX}_VERSION}m + include/python${_${_PYTHON_PREFIX}_VERSION}u + include/python${_${_PYTHON_PREFIX}_VERSION} + include + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + find_path (${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] + PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu include/python${_${_PYTHON_PREFIX}_VERSION}m include/python${_${_PYTHON_PREFIX}_VERSION}u @@ -914,6 +1249,13 @@ endif() # final clean-up +# Restore CMAKE_FIND_APPBUNDLE +if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE) + set (CMAKE_FIND_APPBUNDLE ${_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE}) + unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE) +else() + unset (CMAKE_FIND_APPBUNDLE) +endif() # Restore CMAKE_FIND_FRAMEWORK if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK) set (CMAKE_FIND_FRAMEWORK ${_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK}) diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 22e9a8fdb..998e99223 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -117,6 +117,31 @@ Hints * If set to TRUE, search **only** for static libraries. * If set to FALSE, search **only** for shared libraries. +``Python2_FIND_REGISTRY`` + On Windows the ``Python2_FIND_REGISTRY`` variable determine the order + of preference between registry and environment variables. + the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the + following: + + * ``FIRST``: Try to use registry before environment variables. + This is the default. + * ``LAST``: Try to use registry after environment variables. + * ``NEVER``: Never try to use registry. + +``CMAKE_FIND_FRAMEWORK`` + On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of + preference between Apple-style and unix-style package components. + + .. note:: + + Value ``ONLY`` is not supported so ``FIRST`` will be used instead. + +.. note:: + + If a Python virtual environment is configured, set variable + ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with + value ``LAST`` or ``NEVER`` to select it preferably. + Commands ^^^^^^^^ diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 99c159b4b..2176f3f4f 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -117,6 +117,31 @@ Hints * If set to TRUE, search **only** for static libraries. * If set to FALSE, search **only** for shared libraries. +``Python3_FIND_REGISTRY`` + On Windows the ``Python3_FIND_REGISTRY`` variable determine the order + of preference between registry and environment variables. + the ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the + following: + + * ``FIRST``: Try to use registry before environment variables. + This is the default. + * ``LAST``: Try to use registry after environment variables. + * ``NEVER``: Never try to use registry. + +``CMAKE_FIND_FRAMEWORK`` + On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of + preference between Apple-style and unix-style package components. + + .. note:: + + Value ``ONLY`` is not supported so ``FIRST`` will be used instead. + +.. note:: + + If a Python virtual environment is configured, set variable + ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with + value ``LAST`` or ``NEVER`` to select it preferably. + Commands ^^^^^^^^ diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 3ac1ce225..6da87a88f 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -121,6 +121,34 @@ unset(_PYTHON1_VERSIONS) unset(_PYTHON2_VERSIONS) unset(_PYTHON3_VERSIONS) +# Python distribution: define which architectures can be used +if (CMAKE_SIZEOF_VOID_P) + # In this case, search only for 64bit or 32bit + math (EXPR _PYTHON_ARCH "${CMAKE_SIZEOF_VOID_P} * 8") + set (_PYTHON_ARCH2 _PYTHON_PREFIX_ARCH}) +else() + if (PYTHON_EXECUTABLE) + # determine interpreter architecture + execute_process (COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" + RESULT_VARIABLE _PYTHON_RESULT + OUTPUT_VARIABLE _PYTHON_IS64BIT + ERROR_VARIABLE _PYTHON_IS64BIT) + if (NOT _PYTHON_RESULT) + if (_PYTHON_IS64BIT) + set (_PYTHON_ARCH 64) + set (_PYTHON_ARCH2 64) + else() + set (_PYTHON_ARCH 32) + set (_PYTHON_ARCH2 32) + endif() + endif() + else() + # architecture unknown, search for both 64bit and 32bit + set (_PYTHON_ARCH 64) + set (_PYTHON_ARCH2 32) + endif() +endif() + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) if(WIN32) @@ -130,9 +158,17 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) HINTS ${_Python_LIBRARY_PATH_HINT} PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs ) endif() @@ -156,7 +192,11 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) PATHS ${PYTHON_FRAMEWORK_LIBRARIES} [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs ) # Look for the static library in the Python config directory find_library(PYTHON_LIBRARY @@ -201,7 +241,11 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) PATHS ${PYTHON_FRAMEWORK_INCLUDES} [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include PATH_SUFFIXES python${_CURRENT_VERSION}mu python${_CURRENT_VERSION}m diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 537d3b241..e18ae880f 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -19,17 +19,21 @@ # # # The minimum required version of Subversion can be specified using the -# standard syntax, e.g. find_package(Subversion 1.4) +# standard syntax, e.g. ``find_package(Subversion 1.4)``. # # If the command line client executable is found two macros are defined: # # :: # -# Subversion_WC_INFO(<dir> <var-prefix>) +# Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) # Subversion_WC_LOG(<dir> <var-prefix>) # -# Subversion_WC_INFO extracts information of a subversion working copy -# at a given location. This macro defines the following variables: +# ``Subversion_WC_INFO`` extracts information of a subversion working copy at a +# given location. This macro defines the following variables if running +# Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a +# ``SEND_ERROR`` message is generated. The error can be ignored by providing the +# ``IGNORE_SVN_FAILURE`` option, which causes these variables to remain +# undefined. # # :: # @@ -41,9 +45,8 @@ # <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit # <var-prefix>_WC_INFO - output of command `svn info <dir>' # -# Subversion_WC_LOG retrieves the log message of the base revision of a -# subversion working copy at a given location. This macro defines the -# variable: +# ``Subversion_WC_LOG`` retrieves the log message of the base revision of a +# subversion working copy at a given location. This macro defines the variable: # # :: # @@ -84,6 +87,14 @@ if(Subversion_SVN_EXECUTABLE) "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") macro(Subversion_WC_INFO dir prefix) + + cmake_parse_arguments( + "Subversion_WC_INFO" + "IGNORE_SVN_FAILURE" + "" "" + ${ARGN} + ) + # the subversion commands should be executed with the C locale, otherwise # the message (which are parsed) may be translated, Alex set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") @@ -95,10 +106,7 @@ if(Subversion_SVN_EXECUTABLE) RESULT_VARIABLE Subversion_svn_info_result OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT ${Subversion_svn_info_result} EQUAL 0) - message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") - else() - + if(${Subversion_svn_info_result} EQUAL 0) string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") string(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*" @@ -111,7 +119,8 @@ if(Subversion_SVN_EXECUTABLE) "\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}") string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" "\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}") - + elseif(NOT Subversion_WC_INFO_IGNORE_SVN_FAILURE) + message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") endif() # restore the previous LC_ALL diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a0148dd90..75e83ea4a 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -208,7 +208,9 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads) add_library(Threads::Threads INTERFACE IMPORTED) if(THREADS_HAVE_PTHREAD_ARG) - set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") + set_property(TARGET Threads::Threads + PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>" + "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>") endif() if(CMAKE_THREAD_LIBS_INIT) diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index 51e68d599..55db7aeb7 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -59,6 +59,9 @@ function(_XercesC_GET_VERSION version_hdr) endif() set(XercesC_VERSION "${XercesC_MAJOR}.${XercesC_MINOR}.${XercesC_PATCH}" PARENT_SCOPE) + set(XercesC_VERSION_MAJOR "${XercesC_MAJOR}" PARENT_SCOPE) + set(XercesC_VERSION_MINOR "${XercesC_MINOR}" PARENT_SCOPE) + set(XercesC_VERSION_PATCH "${XercesC_PATCH}" PARENT_SCOPE) else() message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information") endif() @@ -70,22 +73,26 @@ find_path(XercesC_INCLUDE_DIR DOC "Xerces-C++ include directory") mark_as_advanced(XercesC_INCLUDE_DIR) +if(XercesC_INCLUDE_DIR) + _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") +endif() + if(NOT XercesC_LIBRARY) # Find all XercesC libraries find_library(XercesC_LIBRARY_RELEASE - NAMES "xerces-c" "xerces-c_3" + NAMES "xerces-c" "xerces-c_${XercesC_VERSION_MAJOR}" DOC "Xerces-C++ libraries (release)") find_library(XercesC_LIBRARY_DEBUG - NAMES "xerces-cd" "xerces-c_3D" "xerces-c_3_1D" + NAMES "xerces-cd" "xerces-c_${XercesC_VERSION_MAJOR}D" "xerces-c_${XercesC_VERSION_MAJOR}_${XercesC_VERSION_MINOR}D" DOC "Xerces-C++ libraries (debug)") include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(XercesC) mark_as_advanced(XercesC_LIBRARY_RELEASE XercesC_LIBRARY_DEBUG) endif() -if(XercesC_INCLUDE_DIR) - _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") -endif() +unset(XercesC_VERSION_MAJOR) +unset(XercesC_VERSION_MINOR) +unset(XercesC_VERSION_PATCH) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(XercesC diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index a5c04aca2..1a4635a7d 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -58,10 +58,12 @@ if(ZLIB_ROOT) endif() # Normal search. +set(_ZLIB_x86 "(x86)") set(_ZLIB_SEARCH_NORMAL - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" - "$ENV{PROGRAMFILES}/zlib" - ) + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" + "$ENV{ProgramFiles}/zlib" + "$ENV{ProgramFiles${_ZLIB_x86}}/zlib") +unset(_ZLIB_x86) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) set(ZLIB_NAMES z zlib zdll zlib1) diff --git a/Modules/Findosg_functions.cmake b/Modules/Findosg_functions.cmake index 60de726e1..adaeb6b1d 100644 --- a/Modules/Findosg_functions.cmake +++ b/Modules/Findosg_functions.cmake @@ -13,6 +13,8 @@ # libraries and nodekits. Please see FindOpenSceneGraph.cmake for full # documentation. +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + # # OSG_FIND_PATH # @@ -39,7 +41,7 @@ endfunction() function(OSG_FIND_LIBRARY module library) string(TOUPPER ${module} module_uc) - find_library(${module_uc}_LIBRARY + find_library(${module_uc}_LIBRARY_RELEASE NAMES ${library} HINTS ENV ${module_uc}_DIR @@ -63,18 +65,12 @@ function(OSG_FIND_LIBRARY module library) PATH_SUFFIXES lib ) - if(NOT ${module_uc}_LIBRARY_DEBUG) - # They don't have a debug library - set(${module_uc}_LIBRARY_DEBUG ${${module_uc}_LIBRARY} PARENT_SCOPE) - set(${module_uc}_LIBRARIES ${${module_uc}_LIBRARY} PARENT_SCOPE) - else() - # They really have a FOO_LIBRARY_DEBUG - set(${module_uc}_LIBRARIES - optimized ${${module_uc}_LIBRARY} - debug ${${module_uc}_LIBRARY_DEBUG} - PARENT_SCOPE - ) - endif() + select_library_configurations(${module_uc}) + + # the variables set by select_library_configurations go out of scope + # here, so we need to set them again + set(${module_uc}_LIBRARY ${${module_uc}_LIBRARY} PARENT_SCOPE) + set(${module_uc}_LIBRARIES ${${module_uc}_LIBRARIES} PARENT_SCOPE) endfunction() # diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 9dd464c8d..3dfcf8c95 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -276,7 +276,7 @@ _GNUInstallDirs_cache_path(CMAKE_INSTALL_DATAROOTDIR "share" _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}" "Read-only architecture-independent data (DATAROOTDIR)") -if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$") +if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$") _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_INFODIR "info" "Info documentation (info)") _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "man" diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index d3977910b..ca710090f 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -275,7 +275,6 @@ function(gp_item_default_embedded_path item default_embedded_path_var) # as the executable by default: # set(path "@executable_path") - set(overridden 0) # On the Mac, relative to the executable depending on the type # of the thing we are embedding: @@ -294,20 +293,11 @@ function(gp_item_default_embedded_path item default_embedded_path_var) # set(path "@executable_path/../../Contents/MacOS") - # Embed .dylibs right next to the main bundle executable: + # Embed frameworks and .dylibs in the embedded "Frameworks" directory + # (sibling of MacOS): # - if(item MATCHES "\\.dylib$") - set(path "@executable_path/../MacOS") - set(overridden 1) - endif() - - # Embed frameworks in the embedded "Frameworks" directory (sibling of MacOS): - # - if(NOT overridden) - if(item MATCHES "[^/]+\\.framework/") - set(path "@executable_path/../Frameworks") - set(overridden 1) - endif() + if(item MATCHES "[^/]+\\.framework/" OR item MATCHES "\\.dylib$") + set(path "@executable_path/../Frameworks") endif() endif() diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index 2c9ee1180..a5bb86360 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -308,7 +308,7 @@ function(gtest_add_tests) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source}) endif() file(READ "${source}" contents) - string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) + string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests "${contents}") foreach(hit ${found_tests}) string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 36dd0a0e3..b5e5d69f8 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -302,7 +302,15 @@ if(MSVC) get_filename_component(windows_kits_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE) set(programfilesx86 "ProgramFiles(x86)") - find_path(WINDOWS_KITS_DIR NAMES Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll + if(";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;(10\.[0-9.]+)[;\]]=]) + set(__ucrt_version "${CMAKE_MATCH_1}/") + else() + set(__ucrt_version "") + endif() + find_path(WINDOWS_KITS_DIR + NAMES + Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll + Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll PATHS $ENV{CMAKE_WINDOWS_KITS_10_DIR} "${windows_kits_dir}" @@ -313,11 +321,19 @@ if(MSVC) # Glob the list of UCRT DLLs. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) - file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll") + if(EXISTS "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll") + file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll") + else() + file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll") + endif() list(APPEND __install__libs ${__ucrt_dlls}) endif() if(CMAKE_INSTALL_DEBUG_LIBRARIES) - file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll") + if(EXISTS "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/ucrtbased.dll") + file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/*.dll") + else() + file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll") + endif() list(APPEND __install__libs ${__ucrt_dlls}) endif() endif() @@ -362,7 +378,7 @@ if(MSVC) ) endif() - # include the language dll's for vs8 as well as the actuall dll's + # include the language dll's for vs8 as well as the actual dll's set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. @@ -406,7 +422,7 @@ if(MSVC) ) endif() - # include the language dll's for vs9 as well as the actuall dll's + # include the language dll's for vs9 as well as the actual dll's set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. @@ -487,7 +503,7 @@ if(MSVC) endif() endif() - # include the language dll's as well as the actuall dll's + # include the language dll's as well as the actual dll's set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC") set(__install__libs ${__install__libs} "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll" diff --git a/Modules/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index fdbae326c..3042a16f8 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -1,537 +1,6 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CPackDeb -# -------- -# -# The built in (binary) CPack Deb generator (Unix only) -# -# Variables specific to CPack Debian (DEB) generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# CPackDeb may be used to create Deb package using :module:`CPack`. -# CPackDeb is a :module:`CPack` generator thus it uses the ``CPACK_XXX`` -# variables used by :module:`CPack`. -# -# CPackDeb generator should work on any Linux host but it will produce -# better deb package when Debian specific tools ``dpkg-xxx`` are usable on -# the build system. -# -# CPackDeb has specific features which are controlled by the specifics -# :code:`CPACK_DEBIAN_XXX` variables. -# -# :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have -# **component** specific values. Note however that ``<COMPONENT>`` refers to -# the **grouping name** written in upper case. It may be either a component name -# or a component GROUP name. -# -# Here are some CPackDeb wiki resources that are here for historic reasons and -# are no longer maintained but may still prove useful: -# -# - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration -# - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#deb-unix-only -# -# List of CPackDEB specific variables: -# -# .. variable:: CPACK_DEB_COMPONENT_INSTALL -# -# Enable component packaging for CPackDEB -# -# * Mandatory : NO -# * Default : OFF -# -# If enabled (ON) multiple packages are generated. By default a single package -# containing files of all components is generated. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_NAME -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME -# -# Set Package control field (variable is automatically transformed to lower -# case). -# -# * Mandatory : YES -# * Default : -# -# - :variable:`CPACK_PACKAGE_NAME` for non-component based -# installations -# - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT> -# for component-based installations. -# -# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source -# -# .. variable:: CPACK_DEBIAN_FILE_NAME -# CPACK_DEBIAN_<COMPONENT>_FILE_NAME -# -# Package file name. -# -# * Mandatory : YES -# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb`` -# -# This may be set to ``DEB-DEFAULT`` to allow CPackDeb to generate package file -# name by itself in deb format:: -# -# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb -# -# Alternatively provided package file name must end -# with either ``.deb`` or ``.ipk`` suffix. -# -# .. note:: -# -# Preferred setting of this variable is ``DEB-DEFAULT`` but for backward -# compatibility with CPackDeb in CMake prior to version 3.6 this feature -# is disabled by default. -# -# .. note:: -# -# By using non default filenames duplicate names may occur. Duplicate files -# get overwritten and it is up to the packager to set the variables in a -# manner that will prevent such errors. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_EPOCH -# -# The Debian package epoch -# -# * Mandatory : No -# * Default : - -# -# Optional number that should be incremented when changing versioning schemas -# or fixing mistakes in the version numbers of older packages. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_VERSION -# -# The Debian package version -# -# * Mandatory : YES -# * Default : :variable:`CPACK_PACKAGE_VERSION` -# -# This variable may contain only alphanumerics (A-Za-z0-9) and the characters -# . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If -# :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` is not set then hyphens are not -# allowed. -# -# .. note:: -# -# For backward compatibility with CMake 3.9 and lower a failed test of this -# variable's content is not a hard error when both -# :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` and -# :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables are not set. An author -# warning is reported instead. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE -# -# The Debian package release - Debian revision number. -# -# * Mandatory : No -# * Default : - -# -# This is the numbering of the DEB package itself, i.e. the version of the -# packaging and not the version of the content (see -# :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value -# if the previous packaging was buggy and/or you want to put here a fancy Linux -# distro specific numbering. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE -# -# The Debian package architecture -# -# * Mandatory : YES -# * Default : Output of :code:`dpkg --print-architecture` (or :code:`i386` -# if :code:`dpkg` is not found) -# -# .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS -# -# Sets the Debian dependencies of this package. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based -# installations. -# -# .. note:: -# -# If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or -# more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS` -# is set for this component, the discovered dependencies will be appended -# to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of -# :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If -# :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string, -# only the automatically discovered dependencies will be set for this -# component. -# -# Example:: -# -# set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)") -# -# .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS -# -# Sets inter component dependencies if listed with -# :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables. -# -# * Mandatory : NO -# * Default : - -# -# .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER -# -# The Debian package maintainer -# -# * Mandatory : YES -# * Default : :code:`CPACK_PACKAGE_CONTACT` -# -# .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION -# CPACK_COMPONENT_<COMPONENT>_DESCRIPTION -# -# The Debian package description -# -# * Mandatory : YES -# * Default : -# -# - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or -# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` -# -# -# .. variable:: CPACK_DEBIAN_PACKAGE_SECTION -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION -# -# Set Section control field e.g. admin, devel, doc, ... -# -# * Mandatory : YES -# * Default : "devel" -# -# See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections -# -# .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE -# -# The archive format used for creating the Debian package. -# -# * Mandatory : YES -# * Default : "paxr" -# -# Possible values are: -# -# - paxr -# - gnutar -# -# .. note:: -# -# Default pax archive format is the most portable format and generates -# packages that do not treat sparse files specially. -# GNU tar format on the other hand supports longer filenames. -# -# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE -# -# The compression used for creating the Debian package. -# -# * Mandatory : YES -# * Default : "gzip" -# -# Possible values are: -# -# - lzma -# - xz -# - bzip2 -# - gzip -# -# .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY -# -# Set Priority control field e.g. required, important, standard, optional, -# extra -# -# * Mandatory : YES -# * Default : "optional" -# -# See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities -# -# .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE -# -# The URL of the web site for this package, preferably (when applicable) the -# site from which the original source can be obtained and any additional -# upstream documentation or information may be found. -# -# * Mandatory : NO -# * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL` -# -# .. note:: -# -# The content of this field is a simple URL without any surrounding -# characters such as <>. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS -# -# May be set to ON in order to use :code:`dpkg-shlibdeps` to generate -# better package dependency list. -# -# * Mandatory : NO -# * Default : -# -# - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or -# - OFF -# -# .. note:: -# -# You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value -# if you use this feature, because if you don't :code:`dpkg-shlibdeps` -# may fail to find your own shared libs. -# See https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling -# -# .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG -# -# May be set when invoking cpack in order to trace debug information -# during CPackDeb run. -# -# * Mandatory : NO -# * Default : - -# -# .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS -# -# Sets the `Pre-Depends` field of the Debian package. -# Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it -# also forces :code:`dpkg` to complete installation of the packages named -# before even starting the installation of the package which declares the -# pre-dependency. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based -# installations. -# -# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES -# -# Sets the `Enhances` field of the Debian package. -# Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works -# in the opposite direction: declares that a package can enhance the -# functionality of another package. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based -# installations. -# -# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS -# -# Sets the `Breaks` field of the Debian package. -# When a binary package (P) declares that it breaks other packages (B), -# :code:`dpkg` will not allow the package (P) which declares `Breaks` be -# **unpacked** unless the packages that will be broken (B) are deconfigured -# first. -# As long as the package (P) is configured, the previously deconfigured -# packages (B) cannot be reconfigured again. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based -# installations. -# -# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks -# -# .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS -# -# Sets the `Conflicts` field of the Debian package. -# When one binary package declares a conflict with another using a `Conflicts` -# field, :code:`dpkg` will not allow them to be unpacked on the system at -# the same time. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based -# installations. -# -# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts -# -# .. note:: -# -# This is a stronger restriction than -# :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the -# broken package from being configured while the breaking package is in -# the "Unpacked" state but allows both packages to be unpacked at the same -# time. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES -# -# Sets the `Provides` field of the Debian package. -# A virtual package is one which appears in the `Provides` control field of -# another package. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based -# installations. -# -# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual -# -# .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES -# -# Sets the `Replaces` field of the Debian package. -# Packages can declare in their control file that they should overwrite -# files in certain other packages, or completely replace other packages. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based -# installations. -# -# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS -# -# Sets the `Recommends` field of the Debian package. -# Allows packages to declare a strong, but not absolute, dependency on other -# packages. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based -# installations. -# -# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS -# -# Sets the `Suggests` field of the Debian package. -# Allows packages to declare a suggested package install grouping. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based -# installations. -# -# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS -# -# * Mandatory : NO -# * Default : OFF -# -# Allows to generate shlibs control file automatically. Compatibility is defined by -# :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value. -# -# .. note:: -# -# Libraries are only considered if they have both library name and version -# set. This can be done by setting SOVERSION property with -# :command:`set_target_properties` command. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY -# -# Compatibility policy for auto-generated shlibs control file. -# -# * Mandatory : NO -# * Default : "=" -# -# Defines compatibility policy for auto-generated shlibs control file. -# Possible values: "=", ">=" -# -# See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps -# -# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA -# -# This variable allow advanced user to add custom script to the -# control.tar.gz. -# Typical usage is for conffiles, postinst, postrm, prerm. -# -# * Mandatory : NO -# * Default : - -# -# Usage:: -# -# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA -# "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") -# -# .. note:: -# -# The original permissions of the files will be used in the final -# package unless the variable -# :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set. -# In particular, the scripts should have the proper executable -# flag prior to the generation of the package. -# -# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION -# -# This variable indicates if the Debian policy on control files should be -# strictly followed. -# -# * Mandatory : NO -# * Default : FALSE -# -# Usage:: -# -# set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) -# -# .. note:: -# -# This overrides the permissions on the original files, following the rules -# set by Debian policy -# https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners -# -# .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE -# -# Sets the ``Source`` field of the binary Debian package. -# When the binary package name is not the same as the source package name -# (in particular when several components/binaries are generated from one -# source) the source from which the binary has been generated should be -# indicated with the field ``Source``. -# -# * Mandatory : NO -# * Default : -# -# - An empty string for non-component based installations -# - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based -# installations. -# -# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source -# -# .. note:: -# -# This value is not interpreted. It is possible to pass an optional -# revision number of the referenced source package as well. -# -# Building Debian packages on Windows -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# To communicate UNIX file permissions from the install stage -# to the CPack DEB generator the "cmake_mode_t" NTFS -# alternate data stream (ADT) is used. -# -# When a filesystem without ADT support is used only owner read/write -# permissions can be preserved. - # CPack script for creating Debian package # Author: Mathieu Malaterre # @@ -541,6 +10,9 @@ if(CMAKE_BINARY_DIR) message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.") endif() +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + function(cpack_deb_variable_fallback OUTPUT_VAR_NAME) set(FALLBACK_VAR_NAMES ${ARGN}) @@ -592,6 +64,8 @@ function(cpack_deb_prepare_package_vars) endif() set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}") + set(DBGSYMDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}-dbgsym") + file(REMOVE_RECURSE "${DBGSYMDIR}") # per component automatic discover: some of the component might not have # binaries. @@ -608,7 +82,10 @@ function(cpack_deb_prepare_package_vars) endif() endif() - if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) + cpack_deb_variable_fallback("CPACK_DEBIAN_DEBUGINFO_PACKAGE" + "CPACK_DEBIAN_${_local_component_name}_DEBUGINFO_PACKAGE" + "CPACK_DEBIAN_DEBUGINFO_PACKAGE") + if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS OR CPACK_DEBIAN_DEBUGINFO_PACKAGE) # Generating binary list - Get type of all install files file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*") @@ -620,7 +97,7 @@ function(cpack_deb_prepare_package_vars) # get file info so that we can determine if file is executable or not unset(CPACK_DEB_INSTALL_FILES) foreach(FILE_ IN LISTS FILE_PATHS_) - execute_process(COMMAND env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}" + execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}" WORKING_DIRECTORY "${WDIR}" RESULT_VARIABLE FILE_RESULT_ OUTPUT_VARIABLE INSTALL_FILE_) @@ -642,6 +119,81 @@ function(cpack_deb_prepare_package_vars) string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}") endif() + if(_FILE MATCHES "ELF.*not stripped") + string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") + list(APPEND CPACK_DEB_UNSTRIPPED_FILES "${CMAKE_MATCH_1}") + endif() + endforeach() + endif() + + find_program(READELF_EXECUTABLE NAMES readelf) + + if(CPACK_DEBIAN_DEBUGINFO_PACKAGE AND CPACK_DEB_UNSTRIPPED_FILES) + find_program(OBJCOPY_EXECUTABLE NAMES objcopy) + + if(NOT OBJCOPY_EXECUTABLE) + message(FATAL_ERROR "debuginfo packages require the objcopy tool") + endif() + if(NOT READELF_EXECUTABLE) + message(FATAL_ERROR "debuginfo packages require the readelf tool") + endif() + + file(RELATIVE_PATH _DBGSYM_ROOT "${CPACK_TEMPORARY_DIRECTORY}" "${DBGSYMDIR}") + foreach(_FILE IN LISTS CPACK_DEB_UNSTRIPPED_FILES) + + # Get the file's Build ID + execute_process(COMMAND env LC_ALL=C ${READELF_EXECUTABLE} -n "${_FILE}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE READELF_OUTPUT + RESULT_VARIABLE READELF_RESULT + ERROR_VARIABLE READELF_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT READELF_RESULT EQUAL 0) + message(FATAL_ERROR "CPackDeb: readelf: '${READELF_ERROR}';\n" + "executed command: '${READELF_EXECUTABLE} -n ${_FILE}'") + endif() + if(READELF_OUTPUT MATCHES "Build ID: ([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z]*)") + set(_BUILD_ID_START ${CMAKE_MATCH_1}) + set(_BUILD_ID_REMAINING ${CMAKE_MATCH_2}) + list(APPEND BUILD_IDS ${_BUILD_ID_START}${_BUILD_ID_REMAINING}) + else() + message(FATAL_ERROR "Unable to determine Build ID for ${_FILE}") + endif() + + # Split out the debug symbols from the binaries + set(_FILE_DBGSYM ${_DBGSYM_ROOT}/usr/lib/debug/.build-id/${_BUILD_ID_START}/${_BUILD_ID_REMAINING}.debug) + get_filename_component(_OUT_DIR "${_FILE_DBGSYM}" DIRECTORY) + file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/${_OUT_DIR}") + execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE OBJCOPY_OUTPUT + RESULT_VARIABLE OBJCOPY_RESULT + ERROR_VARIABLE OBJCOPY_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT OBJCOPY_RESULT EQUAL 0) + message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" + "executed command: '${OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'") + endif() + execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE OBJCOPY_OUTPUT + RESULT_VARIABLE OBJCOPY_RESULT + ERROR_VARIABLE OBJCOPY_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT OBJCOPY_RESULT EQUAL 0) + message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" + "executed command: '${OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'") + endif() + execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE OBJCOPY_OUTPUT + RESULT_VARIABLE OBJCOPY_RESULT + ERROR_VARIABLE OBJCOPY_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT OBJCOPY_RESULT EQUAL 0) + message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" + "executed command: '${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'") + endif() endforeach() endif() @@ -651,7 +203,7 @@ function(cpack_deb_prepare_package_vars) if(SHLIBDEPS_EXECUTABLE) # Check version of the dpkg-shlibdeps tool using CPackDEB method - execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version + execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version OUTPUT_VARIABLE _TMP_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -679,7 +231,7 @@ function(cpack_deb_prepare_package_vars) file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN") # Add --ignore-missing-info if the tool supports it - execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help + execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help OUTPUT_VARIABLE _TMP_HELP ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -978,8 +530,6 @@ function(cpack_deb_prepare_package_vars) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") endif() - find_program(READELF_EXECUTABLE NAMES readelf) - if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) if(READELF_EXECUTABLE) foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) @@ -1035,18 +585,24 @@ function(cpack_deb_prepare_package_vars) # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + set(CPACK_DBGSYM_OUTPUT_FILE_NAME + "${CPACK_DEBIAN_PACKAGE_NAME}-dbgsym_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ddeb") else() if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)") message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!") endif() set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}") + string(REGEX REPLACE "\.deb$" "-dbgsym.ddeb" CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}") endif() set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}") get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY) set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}") - endif() # else() back compatibility - don't change the name + else() + # back compatibility - don't change the name + string(REGEX REPLACE "\.deb$" "-dbgsym.ddeb" CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") + endif() # Print out some debug information if we were asked for that if(CPACK_DEBIAN_PACKAGE_DEBUG) @@ -1107,6 +663,16 @@ function(cpack_deb_prepare_package_vars) set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE) set(GEN_WDIR "${WDIR}" PARENT_SCOPE) + + set(GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE "${CPACK_DEBIAN_DEBUGINFO_PACKAGE}" PARENT_SCOPE) + if(BUILD_IDS) + set(GEN_DBGSYMDIR "${DBGSYMDIR}" PARENT_SCOPE) + set(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DBGSYM_OUTPUT_FILE_NAME}" PARENT_SCOPE) + string(REPLACE ";" " " BUILD_IDS "${BUILD_IDS}") + set(GEN_BUILD_IDS "${BUILD_IDS}" PARENT_SCOPE) + endif() endfunction() cpack_deb_prepare_package_vars() + +cmake_policy(POP) diff --git a/Modules/Internal/CPack/CPackExternal.cmake b/Modules/Internal/CPack/CPackExternal.cmake new file mode 100644 index 000000000..e4d055a2d --- /dev/null +++ b/Modules/Internal/CPack/CPackExternal.cmake @@ -0,0 +1,53 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +if(NOT "${CPACK_EXTERNAL_REQUESTED_VERSIONS}" STREQUAL "") + unset(_found_major) + + foreach(_req_version IN LISTS CPACK_EXTERNAL_REQUESTED_VERSIONS) + if(_req_version MATCHES "^([0-9]+)\\.([0-9]+)$") + set(_req_major "${CMAKE_MATCH_1}") + set(_req_minor "${CMAKE_MATCH_2}") + + foreach(_known_version IN LISTS CPACK_EXTERNAL_KNOWN_VERSIONS) + string(REGEX MATCH + "^([0-9]+)\\.([0-9]+)$" + _known_version_dummy + "${_known_version}" + ) + + set(_known_major "${CMAKE_MATCH_1}") + set(_known_minor "${CMAKE_MATCH_2}") + + if(_req_major EQUAL _known_major AND NOT _known_minor LESS _req_minor) + set(_found_major "${_known_major}") + set(_found_minor "${_known_minor}") + break() + endif() + endforeach() + + if(DEFINED _found_major) + break() + endif() + endif() + endforeach() + + if(DEFINED _found_major) + set(CPACK_EXTERNAL_SELECTED_MAJOR "${_found_major}") + set(CPACK_EXTERNAL_SELECTED_MINOR "${_found_minor}") + set(CPACK_EXTERNAL_SELECTED_VERSION "${_found_major}.${_found_minor}") + else() + message(FATAL_ERROR + "Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS" + ) + endif() +else() + list(GET CPACK_EXTERNAL_KNOWN_VERSIONS 0 CPACK_EXTERNAL_SELECTED_VERSION) + string(REGEX MATCH + "^([0-9]+)\\.([0-9]+)$" + _dummy + "${CPACK_EXTERNAL_SELECTED_VERSION}" + ) + set(CPACK_EXTERNAL_SELECTED_MAJOR "${CMAKE_MATCH_1}") + set(CPACK_EXTERNAL_SELECTED_MINOR "${CMAKE_MATCH_2}") +endif() diff --git a/Modules/Internal/CPack/CPackFreeBSD.cmake b/Modules/Internal/CPack/CPackFreeBSD.cmake new file mode 100644 index 000000000..16f906cac --- /dev/null +++ b/Modules/Internal/CPack/CPackFreeBSD.cmake @@ -0,0 +1,107 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +if(CMAKE_BINARY_DIR) + message(FATAL_ERROR "CPackFreeBSD.cmake may only be used by CPack internally.") +endif() + +if(NOT UNIX) + message(FATAL_ERROR "CPackFreeBSD.cmake may only be used under UNIX.") +endif() + + +### +# +# These bits are copied from the Debian packaging file; slightly modified. +# They are used for filling in FreeBSD-packaging variables that can take +# on values from elsewhere -- e.g. the package description may as well be +# copied from Debian. +# +function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME) + set(FALLBACK_VAR_NAMES ${ARGN}) + + set(VALUE "${${OUTPUT_VAR_NAME}}") + if(VALUE) + return() + endif() + + foreach(variable_name IN LISTS FALLBACK_VAR_NAMES) + if(${variable_name}) + set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE) + set(VALUE "${${variable_name}}") + break() + endif() + endforeach() + if(NOT VALUE) + message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.") + endif() +endfunction() + +function(check_required_var VAR_NAME) + if(NOT ${VAR_NAME}) + message(FATAL_ERROR "Variable ${VAR_NAME} is not set.") + endif() +endfunction() + +set(_cpack_freebsd_fallback_origin "misc/bogus") + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_NAME" + "CPACK_PACKAGE_NAME" + "CMAKE_PROJECT_NAME" + ) + +set(_cpack_freebsd_fallback_www "http://example.com/?pkg=${CPACK_FREEBSD_PACKAGE_NAME}") + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_COMMENT" + "CPACK_PACKAGE_DESCRIPTION_SUMMARY" + ) + +# TODO: maybe read the PACKAGE_DESCRIPTION file for the longer +# FreeBSD pkg-descr? +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION" + "CPACK_DEBIAN_PACKAGE_DESCRIPTION" + "CPACK_PACKAGE_DESCRIPTION_SUMMARY" + "PACKAGE_DESCRIPTION" + ) + +# There's really only one homepage for a project, so +# re-use the Debian setting if it's there. +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW" + "CMAKE_PROJECT_HOMEPAGE_URL" + "CPACK_DEBIAN_PACKAGE_HOMEPAGE" + "_cpack_freebsd_fallback_www" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_VERSION" + "CMAKE_PROJECT_VERSION" + "${CMAKE_PROJECT_NAME}_VERSION" + "PROJECT_VERSION" + "CPACK_PACKAGE_VERSION" + "CPACK_PACKAGE_VERSION" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_MAINTAINER" + "CPACK_PACKAGE_CONTACT" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_LICENSE" + "CPACK_RPM_PACKAGE_LICENSE" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_ORIGIN" + "_cpack_freebsd_fallback_origin" + ) + +if(NOT CPACK_FREEBSD_PACKAGE_CATEGORIES) + string(REGEX REPLACE "/.*" "" CPACK_FREEBSD_PACKAGE_CATEGORIES ${CPACK_FREEBSD_PACKAGE_ORIGIN}) +endif() + +check_required_var("CPACK_FREEBSD_PACKAGE_NAME") +check_required_var("CPACK_FREEBSD_PACKAGE_ORIGIN") +check_required_var("CPACK_FREEBSD_PACKAGE_VERSION") +check_required_var("CPACK_FREEBSD_PACKAGE_MAINTAINER") +check_required_var("CPACK_FREEBSD_PACKAGE_COMMENT") +check_required_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION") +check_required_var("CPACK_FREEBSD_PACKAGE_WWW") +check_required_var("CPACK_FREEBSD_PACKAGE_LICENSE") diff --git a/Modules/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index 05403bc36..198ccad59 100644 --- a/Modules/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -1,199 +1,6 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#[=======================================================================[.rst: -CPackNuGet ----------- - -When build a NuGet package there is no direct way to control an output -filename due a lack of the corresponding CLI option of NuGet, so there -is no ``CPACK_NUGET_PACKAGE_FILENAME`` variable. To form the output filename -NuGet uses the package name and the version according to its built-in rules. - -Also, be aware that including a top level directory -(``CPACK_INCLUDE_TOPLEVEL_DIRECTORY``) is ignored by this generator. - - -Variables specific to CPack NuGet generator -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -CPackNuGet may be used to create NuGet packages using :module:`CPack`. -CPackNuGet is a :module:`CPack` generator thus it uses the ``CPACK_XXX`` -variables used by :module:`CPack`. - -CPackNuGet has specific features which are controlled by the specifics -:code:`CPACK_NUGET_XXX` variables. In the "one per group" mode -(see :variable:`CPACK_COMPONENTS_GROUPING`), ``<compName>`` placeholder -in the variables below would contain a group name (uppercased and turned into -a "C" identifier). - -List of CPackNuGet specific variables: - -.. variable:: CPACK_NUGET_COMPONENT_INSTALL - - Enable component packaging for CPackNuGet - - * Mandatory : NO - * Default : OFF - -.. variable:: CPACK_NUGET_PACKAGE_NAME - CPACK_NUGET_<compName>_PACKAGE_NAME - - The NUGET package name. - - * Mandatory : YES - * Default : :variable:`CPACK_PACKAGE_NAME` - -.. variable:: CPACK_NUGET_PACKAGE_VERSION - CPACK_NUGET_<compName>_PACKAGE_VERSION - - The NuGet package version. - - * Mandatory : YES - * Default : :variable:`CPACK_PACKAGE_VERSION` - -.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION - CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION - - A long description of the package for UI display. - - * Mandatory : YES - * Default : - - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION`, - - ``CPACK_COMPONENT_GROUP_<groupName>_DESCRIPTION``, - - :variable:`CPACK_PACKAGE_DESCRIPTION` - -.. variable:: CPACK_NUGET_PACKAGE_AUTHORS - CPACK_NUGET_<compName>_PACKAGE_AUTHORS - - A comma-separated list of packages authors, matching the profile names - on nuget.org_. These are displayed in the NuGet Gallery on - nuget.org_ and are used to cross-reference packages by the same - authors. - - * Mandatory : YES - * Default : :variable:`CPACK_PACKAGE_VENDOR` - -.. variable:: CPACK_NUGET_PACKAGE_TITLE - CPACK_NUGET_<compName>_PACKAGE_TITLE - - A human-friendly title of the package, typically used in UI displays - as on nuget.org_ and the Package Manager in Visual Studio. If not - specified, the package ID is used. - - * Mandatory : NO - * Default : - - :variable:`CPACK_COMPONENT_<compName>_DISPLAY_NAME`, - - ``CPACK_COMPONENT_GROUP_<groupName>_DISPLAY_NAME`` - -.. variable:: CPACK_NUGET_PACKAGE_OWNERS - CPACK_NUGET_<compName>_PACKAGE_OWNERS - - A comma-separated list of the package creators using profile names - on nuget.org_. This is often the same list as in authors, - and is ignored when uploading the package to nuget.org_. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_HOMEPAGE_URL - CPACK_NUGET_<compName>_PACKAGE_HOMEPAGE_URL - - A URL for the package's home page, often shown in UI displays as well - as nuget.org_. - - * Mandatory : NO - * Default : :variable:`CPACK_PACKAGE_HOMEPAGE_URL` - -.. variable:: CPACK_NUGET_PACKAGE_LICENSEURL - CPACK_NUGET_<compName>_PACKAGE_LICENSEURL - - A URL for the package's license, often shown in UI displays as well - as nuget.org_. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_ICONURL - CPACK_NUGET_<compName>_PACKAGE_ICONURL - - A URL for a 64x64 image with transparency background to use as the - icon for the package in UI display. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION_SUMMARY - CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION_SUMMARY - - A short description of the package for UI display. If omitted, a - truncated version of description is used. - - * Mandatory : NO - * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` - -.. variable:: CPACK_NUGET_PACKAGE_RELEASE_NOTES - CPACK_NUGET_<compName>_PACKAGE_RELEASE_NOTES - - A description of the changes made in this release of the package, - often used in UI like the Updates tab of the Visual Studio Package - Manager in place of the package description. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_COPYRIGHT - CPACK_NUGET_<compName>_PACKAGE_COPYRIGHT - - Copyright details for the package. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_TAGS - CPACK_NUGET_<compName>_PACKAGE_TAGS - - A space-delimited list of tags and keywords that describe the - package and aid discoverability of packages through search and - filtering. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES - CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES - - A list of package dependencies. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES_<dependency>_VERSION - CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<dependency>_VERSION - - A `version specification`_ for the particular dependency, where - ``<dependency>`` is an item of the dependency list (see above) - transformed with ``MAKE_C_IDENTIFIER`` function of :command:`string` - command. - - * Mandatory : NO - * Default : - - -.. variable:: CPACK_NUGET_PACKAGE_DEBUG - - Enable debug messages while executing ``CPackNuGet.cmake``. - - * Mandatory : NO - * Default : OFF - - -.. _nuget.org: http://nuget.org -.. _version specification: https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards - -.. NuGet spec docs https://docs.microsoft.com/en-us/nuget/reference/nuspec - -#]=======================================================================] - # Author: Alex Turbov if(CMAKE_BINARY_DIR) @@ -455,7 +262,7 @@ function(_cpack_nuget_render_spec) # NuGet will name it properly. _cpack_nuget_debug("Rendering `${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec` file...") configure_file( - "${CMAKE_CURRENT_LIST_DIR}/CPack.NuGet.nuspec.in" + "${CMAKE_ROOT}/Modules/CPack.NuGet.nuspec.in" "${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec" @ONLY ) diff --git a/Modules/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 60b3abe16..2de71ee20 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1,965 +1,11 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CPackRPM -# -------- -# -# The built in (binary) CPack RPM generator (Unix only) -# -# Variables specific to CPack RPM generator -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# CPackRPM may be used to create RPM packages using :module:`CPack`. -# CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX`` -# variables used by :module:`CPack`. -# -# CPackRPM has specific features which are controlled by the specifics -# :code:`CPACK_RPM_XXX` variables. -# -# :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have -# **component** specific values. Note however that ``<COMPONENT>`` refers to the -# **grouping name** written in upper case. It may be either a component name or -# a component GROUP name. Usually those variables correspond to RPM spec file -# entities. One may find information about spec files here -# http://www.rpm.org/wiki/Docs -# -# .. note:: -# -# `<COMPONENT>` part of variables is preferred to be in upper case (for e.g. if -# component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format) -# as is with other `CPACK_<COMPONENT>_XXXX` variables. -# For the purposes of back compatibility (CMake/CPack version 3.5 and lower) -# support for same cased component (e.g. `fOo` would be used as -# `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older -# versions of CMake/CPack but is not guaranteed for variables that -# will be added in the future. For the sake of back compatibility same cased -# component variables also override upper cased versions where both are -# present. -# -# Here are some CPackRPM wiki resources that are here for historic reasons and -# are no longer maintained but may still prove useful: -# -# - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration -# - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#rpm-unix-only -# -# List of CPackRPM specific variables: -# -# .. variable:: CPACK_RPM_COMPONENT_INSTALL -# -# Enable component packaging for CPackRPM -# -# * Mandatory : NO -# * Default : OFF -# -# If enabled (ON) multiple packages are generated. By default a single package -# containing files of all components is generated. -# -# .. variable:: CPACK_RPM_PACKAGE_SUMMARY -# CPACK_RPM_<component>_PACKAGE_SUMMARY -# -# The RPM package summary. -# -# * Mandatory : YES -# * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` -# -# .. variable:: CPACK_RPM_PACKAGE_NAME -# CPACK_RPM_<component>_PACKAGE_NAME -# -# The RPM package name. -# -# * Mandatory : YES -# * Default : :variable:`CPACK_PACKAGE_NAME` -# -# .. variable:: CPACK_RPM_FILE_NAME -# CPACK_RPM_<component>_FILE_NAME -# -# Package file name. -# -# * Mandatory : YES -# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces -# replaced by '-' -# -# This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package -# file name by itself. -# Alternatively provided package file name must end with ``.rpm`` suffix. -# -# .. note:: -# -# By using user provided spec file, rpm macro extensions such as for -# generating debuginfo packages or by simply using multiple components more -# than one rpm file may be generated, either from a single spec file or from -# multiple spec files (each component execution produces it's own spec file). -# In such cases duplicate file names may occur as a result of this variable -# setting or spec file content structure. Duplicate files get overwritten -# and it is up to the packager to set the variables in a manner that will -# prevent such errors. -# -# .. variable:: CPACK_RPM_MAIN_COMPONENT -# -# Main component that is packaged without component suffix. -# -# * Mandatory : NO -# * Default : - -# -# This variable can be set to any component or group name so that component or -# group rpm package is generated without component suffix in filename and -# package name. -# -# .. variable:: CPACK_RPM_PACKAGE_EPOCH -# -# The RPM package epoch -# -# * Mandatory : No -# * Default : - -# -# Optional number that should be incremented when changing versioning schemas -# or fixing mistakes in the version numbers of older packages. -# -# .. variable:: CPACK_RPM_PACKAGE_VERSION -# -# The RPM package version. -# -# * Mandatory : YES -# * Default : :variable:`CPACK_PACKAGE_VERSION` -# -# .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE -# CPACK_RPM_<component>_PACKAGE_ARCHITECTURE -# -# The RPM package architecture. -# -# * Mandatory : YES -# * Default : Native architecture output by ``uname -m`` -# -# This may be set to ``noarch`` if you know you are building a noarch package. -# -# .. variable:: CPACK_RPM_PACKAGE_RELEASE -# -# The RPM package release. -# -# * Mandatory : YES -# * Default : 1 -# -# This is the numbering of the RPM package itself, i.e. the version of the -# packaging and not the version of the content (see -# :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if -# the previous packaging was buggy and/or you want to put here a fancy Linux -# distro specific numbering. -# -# .. note:: -# -# This is the string that goes into the RPM ``Release:`` field. Some distros -# (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number. -# ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`. -# -# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST -# -# The dist tag that is added RPM ``Release:`` field. -# -# * Mandatory : NO -# * Default : OFF -# -# This is the reported ``%{dist}`` tag from the current distribution or empty -# ``%{dist}`` if RPM macro is not set. If this variable is set then RPM -# ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``. -# -# .. variable:: CPACK_RPM_PACKAGE_LICENSE -# -# The RPM package license policy. -# -# * Mandatory : YES -# * Default : "unknown" -# -# .. variable:: CPACK_RPM_PACKAGE_GROUP -# CPACK_RPM_<component>_PACKAGE_GROUP -# -# The RPM package group. -# -# * Mandatory : YES -# * Default : "unknown" -# -# .. variable:: CPACK_RPM_PACKAGE_VENDOR -# -# The RPM package vendor. -# -# * Mandatory : YES -# * Default : CPACK_PACKAGE_VENDOR if set or "unknown" -# -# .. variable:: CPACK_RPM_PACKAGE_URL -# CPACK_RPM_<component>_PACKAGE_URL -# -# The projects URL. -# -# * Mandatory : NO -# * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL` -# -# .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION -# CPACK_RPM_<component>_PACKAGE_DESCRIPTION -# -# RPM package description. -# -# * Mandatory : YES -# * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component -# based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` -# if set or "no package description available" -# -# .. variable:: CPACK_RPM_COMPRESSION_TYPE -# -# RPM compression type. -# -# * Mandatory : NO -# * Default : - -# -# May be used to override RPM compression type to be used to build the -# RPM. For example some Linux distribution now default to lzma or xz -# compression whereas older cannot use such RPM. Using this one can enforce -# compression type to be used. -# -# Possible values are: -# -# - lzma -# - xz -# - bzip2 -# - gzip -# -# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ -# CPACK_RPM_<component>_PACKAGE_AUTOREQ -# -# RPM spec autoreq field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to enable (1, yes) or disable (0, no) automatic shared libraries -# dependency detection. Dependencies are added to requires list. -# -# .. note:: -# -# By default automatic dependency detection is enabled by rpm generator. -# -# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV -# CPACK_RPM_<component>_PACKAGE_AUTOPROV -# -# RPM spec autoprov field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to enable (1, yes) or disable (0, no) automatic listing of shared -# libraries that are provided by the package. Shared libraries are added to -# provides list. -# -# .. note:: -# -# By default automatic provides detection is enabled by rpm generator. -# -# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV -# CPACK_RPM_<component>_PACKAGE_AUTOREQPROV -# -# RPM spec autoreqprov field. -# -# * Mandatory : NO -# * Default : - -# -# Variable enables/disables autoreq and autoprov at the same time. -# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV` -# for more details. -# -# .. note:: -# -# By default automatic detection feature is enabled by rpm. -# -# .. variable:: CPACK_RPM_PACKAGE_REQUIRES -# CPACK_RPM_<component>_PACKAGE_REQUIRES -# -# RPM spec requires field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM dependencies (requires). Note that you must enclose -# the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8") -# -# The required package list of an RPM file could be printed with:: -# -# rpm -qp --requires file.rpm -# -# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS -# CPACK_RPM_<component>_PACKAGE_CONFLICTS -# -# RPM spec conflicts field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set negative RPM dependencies (conflicts). Note that you must -# enclose the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2") -# -# The conflicting package list of an RPM file could be printed with:: -# -# rpm -qp --conflicts file.rpm -# -# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE -# CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE -# -# RPM spec requires(pre) field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM preinstall dependencies (requires(pre)). Note that -# you must enclose the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts") -# -# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST -# CPACK_RPM_<component>_PACKAGE_REQUIRES_POST -# -# RPM spec requires(post) field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM postinstall dependencies (requires(post)). Note that -# you must enclose the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts") -# -# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN -# CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN -# -# RPM spec requires(postun) field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM postuninstall dependencies (requires(postun)). Note -# that you must enclose the complete requires string between quotes, for -# example:: -# -# set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts") -# -# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN -# CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN -# -# RPM spec requires(preun) field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM preuninstall dependencies (requires(preun)). Note that -# you must enclose the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts") -# -# .. variable:: CPACK_RPM_PACKAGE_SUGGESTS -# CPACK_RPM_<component>_PACKAGE_SUGGESTS -# -# RPM spec suggest field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set weak RPM dependencies (suggests). Note that you must -# enclose the complete requires string between quotes. -# -# .. variable:: CPACK_RPM_PACKAGE_PROVIDES -# CPACK_RPM_<component>_PACKAGE_PROVIDES -# -# RPM spec provides field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM dependencies (provides). The provided package list -# of an RPM file could be printed with:: -# -# rpm -qp --provides file.rpm -# -# .. variable:: CPACK_RPM_PACKAGE_OBSOLETES -# CPACK_RPM_<component>_PACKAGE_OBSOLETES -# -# RPM spec obsoletes field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set RPM packages that are obsoleted by this one. -# -# .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE -# -# build a relocatable RPM. -# -# * Mandatory : NO -# * Default : CPACK_PACKAGE_RELOCATABLE -# -# If this variable is set to TRUE or ON CPackRPM will try -# to build a relocatable RPM package. A relocatable RPM may -# be installed using:: -# -# rpm --prefix or --relocate -# -# in order to install it at an alternate place see rpm(8). Note that -# currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If -# :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but -# if there is file installed with absolute path you'll get unexpected behavior. -# -# .. variable:: CPACK_RPM_SPEC_INSTALL_POST -# -# Deprecated - use :variable:`CPACK_RPM_SPEC_MORE_DEFINE` instead. -# -# * Mandatory : NO -# * Default : - -# * Deprecated: YES -# -# May be used to override the ``__spec_install_post`` section within the -# generated spec file. This affects the install step during package creation, -# not during package installation. For adding operations to be performed -# during package installation, use -# :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead. -# -# .. variable:: CPACK_RPM_SPEC_MORE_DEFINE -# -# RPM extended spec definitions lines. -# -# * Mandatory : NO -# * Default : - -# -# May be used to add any ``%define`` lines to the generated spec file. An -# example of its use is to prevent stripping of executables (but note that -# this may also disable other default post install processing):: -# -# set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") -# -# .. variable:: CPACK_RPM_PACKAGE_DEBUG -# -# Toggle CPackRPM debug output. -# -# * Mandatory : NO -# * Default : - -# -# May be set when invoking cpack in order to trace debug information -# during CPack RPM run. For example you may launch CPack like this:: -# -# cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM -# -# .. variable:: CPACK_RPM_USER_BINARY_SPECFILE -# CPACK_RPM_<componentName>_USER_BINARY_SPECFILE -# -# A user provided spec file. -# -# * Mandatory : NO -# * Default : - -# -# May be set by the user in order to specify a USER binary spec file -# to be used by CPackRPM instead of generating the file. -# The specified file will be processed by configure_file( @ONLY). -# -# .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE -# -# Spec file template. -# -# * Mandatory : NO -# * Default : - -# -# If set CPack will generate a template for USER specified binary -# spec file and stop with an error. For example launch CPack like this:: -# -# cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM -# -# The user may then use this file in order to hand-craft is own -# binary spec file which may be used with -# :variable:`CPACK_RPM_USER_BINARY_SPECFILE`. -# -# .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE -# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE -# -# Path to file containing pre (un)install script. -# -# * Mandatory : NO -# * Default : - -# -# May be used to embed a pre (un)installation script in the spec file. -# The referred script file (or both) will be read and directly -# put after the ``%pre`` or ``%preun`` section -# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install -# script for each component can be overridden with -# ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and -# ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``. -# One may verify which scriptlet has been included with:: -# -# rpm -qp --scripts package.rpm -# -# .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE -# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE -# -# Path to file containing post (un)install script. -# -# * Mandatory : NO -# * Default : - -# -# May be used to embed a post (un)installation script in the spec file. -# The referred script file (or both) will be read and directly -# put after the ``%post`` or ``%postun`` section. -# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install -# script for each component can be overridden with -# ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and -# ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``. -# One may verify which scriptlet has been included with:: -# -# rpm -qp --scripts package.rpm -# -# .. variable:: CPACK_RPM_USER_FILELIST -# CPACK_RPM_<COMPONENT>_USER_FILELIST -# -# * Mandatory : NO -# * Default : - -# -# May be used to explicitly specify ``%(<directive>)`` file line -# in the spec file. Like ``%config(noreplace)`` or any other directive -# that be found in the ``%files`` section. You can have multiple directives -# per line, as in ``%attr(600,root,root) %config(noreplace)``. Since -# CPackRPM is generating the list of files (and directories) the user -# specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will -# be removed from the generated list. If referring to directories do -# not add a trailing slash. -# -# .. variable:: CPACK_RPM_CHANGELOG_FILE -# -# RPM changelog file. -# -# * Mandatory : NO -# * Default : - -# -# May be used to embed a changelog in the spec file. -# The referred file will be read and directly put after the ``%changelog`` -# section. -# -# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST -# -# list of path to be excluded. -# -# * Mandatory : NO -# * Default : /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib -# /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal -# /usr/share/doc -# -# May be used to exclude path (directories or files) from the auto-generated -# list of paths discovered by CPack RPM. The default value contains a -# reasonable set of values if the variable is not defined by the user. If the -# variable is defined by the user then CPackRPM will NOT any of the default -# path. If you want to add some path to the default list then you can use -# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable. -# -# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION -# -# additional list of path to be excluded. -# -# * Mandatory : NO -# * Default : - -# -# May be used to add more exclude path (directories or files) from the initial -# default list of excluded paths. See -# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`. -# -# .. variable:: CPACK_RPM_RELOCATION_PATHS -# -# Packages relocation paths list. -# -# * Mandatory : NO -# * Default : - -# -# May be used to specify more than one relocation path per relocatable RPM. -# Variable contains a list of relocation paths that if relative are prefixed -# by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the -# value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version -# is not provided. -# Variable is not component based as its content can be used to set a different -# path prefix for e.g. binary dir and documentation dir at the same time. -# Only prefixes that are required by a certain component are added to that -# component - component must contain at least one file/directory/symbolic link -# with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation -# path to be added. Package will not contain any relocation paths if there are -# no files/directories/symbolic links on any of the provided prefix locations. -# Packages that either do not contain any relocation paths or contain -# files/directories/symbolic links that are outside relocation paths print -# out an ``AUTHOR_WARNING`` that RPM will be partially relocatable. -# -# .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX -# -# Per component relocation path install prefix. -# -# * Mandatory : NO -# * Default : CPACK_PACKAGING_INSTALL_PREFIX -# -# May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX` -# for relocatable RPM packages. -# -# .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION -# CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION -# -# Removal of default install prefix from relocation paths list. -# -# * Mandatory : NO -# * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX -# are treated as one of relocation paths -# -# May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX -# from relocatable RPM prefix paths. -# -# .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS -# -# * Mandatory : NO -# * Default : - -# -# May be used to set additional man dirs that could potentially be compressed -# by brp-compress RPM macro. Variable content must be a list of regular -# expressions that point to directories containing man files or to man files -# directly. Note that in order to compress man pages a path must also be -# present in brp-compress RPM script and that brp-compress script must be -# added to RPM configuration by the operating system. -# -# Regular expressions that are added by default were taken from brp-compress -# RPM macro: -# -# - /usr/man/man.* -# - /usr/man/.*/man.* -# - /usr/info.* -# - /usr/share/man/man.* -# - /usr/share/man/.*/man.* -# - /usr/share/info.* -# - /usr/kerberos/man.* -# - /usr/X11R6/man/man.* -# - /usr/lib/perl5/man/man.* -# - /usr/share/doc/.*/man/man.* -# - /usr/lib/.*/man/man.* -# -# .. variable:: CPACK_RPM_DEFAULT_USER -# CPACK_RPM_<compName>_DEFAULT_USER -# -# default user ownership of RPM content -# -# * Mandatory : NO -# * Default : root -# -# Value should be user name and not UID. -# Note that <compName> must be in upper-case. -# -# .. variable:: CPACK_RPM_DEFAULT_GROUP -# CPACK_RPM_<compName>_DEFAULT_GROUP -# -# default group ownership of RPM content -# -# * Mandatory : NO -# * Default : root -# -# Value should be group name and not GID. -# Note that <compName> must be in upper-case. -# -# .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS -# CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS -# -# default permissions used for packaged files -# -# * Mandatory : NO -# * Default : - (system default) -# -# Accepted values are lists with ``PERMISSIONS``. Valid permissions -# are: -# -# - OWNER_READ -# - OWNER_WRITE -# - OWNER_EXECUTE -# - GROUP_READ -# - GROUP_WRITE -# - GROUP_EXECUTE -# - WORLD_READ -# - WORLD_WRITE -# - WORLD_EXECUTE -# -# Note that <compName> must be in upper-case. -# -# .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS -# CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS -# -# default permissions used for packaged directories -# -# * Mandatory : NO -# * Default : - (system default) -# -# Accepted values are lists with PERMISSIONS. Valid permissions -# are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`. -# Note that <compName> must be in upper-case. -# -# .. variable:: CPACK_RPM_INSTALL_WITH_EXEC -# -# force execute permissions on programs and shared libraries -# -# * Mandatory : NO -# * Default : - (system default) -# -# Force set owner, group and world execute permissions on programs and shared -# libraries. This can be used for creating valid rpm packages on systems such -# as Debian where shared libraries do not have execute permissions set. -# -# .. note:: -# -# Programs and shared libraries without execute permissions are ignored during -# separation of debug symbols from the binary for debuginfo packages. -# -# Packaging of Symbolic Links -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# CPackRPM supports packaging of symbolic links:: -# -# execute_process(COMMAND ${CMAKE_COMMAND} -# -E create_symlink <relative_path_location> <symlink_name>) -# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name> -# DESTINATION <symlink_location> COMPONENT libraries) -# -# Symbolic links will be optimized (paths will be shortened if possible) -# before being added to the package or if multiple relocation paths are -# detected, a post install symlink relocation script will be generated. -# -# Symbolic links may point to locations that are not packaged by the same -# package (either a different component or even not packaged at all) but -# those locations will be treated as if they were a part of the package -# while determining if symlink should be either created or present in a -# post install script - depending on relocation paths. -# -# Symbolic links that point to locations outside packaging path produce a -# warning and are treated as non relocatable permanent symbolic links. -# -# Currently there are a few limitations though: -# -# * For component based packaging component interdependency is not checked -# when processing symbolic links. Symbolic links pointing to content of -# a different component are treated the same way as if pointing to location -# that will not be packaged. -# -# * Symbolic links pointing to a location through one or more intermediate -# symbolic links will not be handled differently - if the intermediate -# symbolic link(s) is also on a relocatable path, relocating it during -# package installation may cause initial symbolic link to point to an -# invalid location. -# -# Packaging of debug information -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# Debuginfo packages contain debug symbols and sources for debugging packaged -# binaries. -# -# Debuginfo RPM packaging has it's own set of variables: -# -# .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE -# CPACK_RPM_<component>_DEBUGINFO_PACKAGE -# -# Enable generation of debuginfo RPM package(s). -# -# * Mandatory : NO -# * Default : OFF -# -# .. note:: -# -# Binaries must contain debug symbols before packaging so use either ``Debug`` -# or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value. -# -# .. note:: -# -# Packages generated from packages without binary files, with binary files but -# without execute permissions or without debug symbols will cause packaging -# termination. -# -# .. variable:: CPACK_BUILD_SOURCE_DIRS -# -# Provides locations of root directories of source files from which binaries -# were built. -# -# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set -# * Default : - -# -# .. note:: -# -# For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to -# point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths. -# -# .. note:: -# -# Sources with path prefixes that do not fall under any location provided with -# :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package. -# -# .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX -# CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX -# -# Prefix of location where sources will be placed during package installation. -# -# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set -# * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and -# for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>" -# -# .. note:: -# -# Each source path prefix is additionally suffixed by ``src_<index>`` where -# index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS` -# variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>`` -# replacement path. -# Limitation is that replaced path part must be shorter or of equal -# length than the length of its replacement. If that is not the case either -# :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to -# a shorter path or source directories must be placed on a longer path. -# -# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS -# -# Directories containing sources that should be excluded from debuginfo packages. -# -# * Mandatory : NO -# * Default : "/usr /usr/src /usr/src/debug" -# -# Listed paths are owned by other RPM packages and should therefore not be -# deleted on debuginfo package uninstallation. -# -# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION -# -# Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS` -# for exclusion. -# -# * Mandatory : NO -# * Default : - -# -# .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE -# -# Create a single debuginfo package even if components packaging is set. -# -# * Mandatory : NO -# * Default : OFF -# -# When this variable is enabled it produces a single debuginfo package even if -# component packaging is enabled. -# -# When using this feature in combination with components packaging and there is -# more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT` -# to be set. -# -# .. note:: -# -# If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables -# is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to -# ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set. -# -# .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME -# CPACK_RPM_<component>_DEBUGINFO_FILE_NAME -# -# Debuginfo package file name. -# -# * Mandatory : NO -# * Default : rpmbuild tool generated package file name -# -# Alternatively provided debuginfo package file name must end with ``.rpm`` -# suffix and should differ from file names of other generated packages. -# -# Variable may contain ``@cpack_component@`` placeholder which will be -# replaced by component name if component packaging is enabled otherwise it -# deletes the placeholder. -# -# Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set -# filename generation to default. -# -# .. note:: -# -# :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package -# file name - disabled by default but can be enabled by setting the variable to -# ``RPM-DEFAULT``. -# -# Packaging of sources (SRPM) -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES` -# variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable -# to provide directory containing CMakeLists.txt and source files. -# -# For CMake projects SRPM package would be produced by executing:: -# -# cpack -G RPM --config ./CPackSourceConfig.cmake -# -# .. note:: -# -# Produced SRPM package is expected to be built with :manual:`cmake(1)` executable -# and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be -# located in root source directory and must be able to generate binary rpm -# packages by executing ``cpack -G`` command. The two executables as well as -# rpmbuild must also be present when generating binary rpm packages from the -# produced SRPM package. -# -# Once the SRPM package is generated it can be used to generate binary packages -# by creating a directory structure for rpm generation and executing rpmbuild -# tool:: -# -# mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} -# rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name> -# -# Generated packages will be located in build_dir/RPMS directory or its sub -# directories. -# -# .. note:: -# -# SRPM package internally uses CPack/RPM generator to generate binary packages -# so CMakeScripts.txt can decide during the SRPM to binary rpm generation step -# what content the package(s) should have as well as how they should be packaged -# (monolithic or components). CMake can decide this for e.g. by reading environment -# variables set by the package manager before starting the process of generating -# binary rpm packages. This way a single SRPM package can be used to produce -# different binary rpm packages on different platforms depending on the platform's -# packaging rules. -# -# Source RPM packaging has it's own set of variables: -# -# .. variable:: CPACK_RPM_PACKAGE_SOURCES -# -# Should the content be packaged as a source rpm (default is binary rpm). -# -# * Mandatory : NO -# * Default : OFF -# -# .. note:: -# -# For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set -# to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake -# generated files. -# -# .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS -# -# Additional command-line parameters provided to :manual:`cmake(1)` executable. -# -# * Mandatory : NO -# * Default : - -# -# .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX -# -# Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX` -# variable for producing binary RPM packages. -# -# * Mandatory : YES -# * Default : "/" -# -# .. VARIABLE:: CPACK_RPM_BUILDREQUIRES -# -# List of source rpm build dependencies. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set source RPM build dependencies (BuildRequires). Note that -# you must enclose the complete build requirements string between quotes, for -# example:: -# -# set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8") - # Author: Eric Noulard with the help of Alexander Neundorf. +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + function(get_file_permissions FILE RETURN_VAR) execute_process(COMMAND ls -l ${FILE} OUTPUT_VARIABLE permissions_ @@ -1445,7 +491,7 @@ function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXE list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT) list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT) else() - # location pointed to is ouside WDR so it should be treated as a permanent symlink + # location pointed to is outside WDR so it should be treated as a permanent symlink set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}") unset(SYMLINK_RELOCATIONS) @@ -2482,7 +1528,7 @@ ${TMP_DEBUGINFO_ADDITIONAL_SOURCES} %build mkdir cpack_rpm_build_dir cd cpack_rpm_build_dir -cmake ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME} +'${CMAKE_COMMAND}' ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME} make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option ) set(TMP_RPM_INSTALL @@ -2822,3 +1868,5 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT endfunction() cpack_rpm_generate_package() + +cmake_policy(POP) diff --git a/Modules/Internal/CPack/CPackWIX.cmake b/Modules/Internal/CPack/CPackWIX.cmake new file mode 100644 index 000000000..d1875f23c --- /dev/null +++ b/Modules/Internal/CPack/CPackWIX.cmake @@ -0,0 +1,20 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +if(NOT CPACK_WIX_ROOT) + string(REPLACE "\\" "/" CPACK_WIX_ROOT "$ENV{WIX}") +endif() + +find_program(CPACK_WIX_CANDLE_EXECUTABLE candle + PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") + +if(NOT CPACK_WIX_CANDLE_EXECUTABLE) + message(FATAL_ERROR "Could not find the WiX candle executable.") +endif() + +find_program(CPACK_WIX_LIGHT_EXECUTABLE light + PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") + +if(NOT CPACK_WIX_LIGHT_EXECUTABLE) + message(FATAL_ERROR "Could not find the WiX light executable.") +endif() diff --git a/Modules/CPackZIP.cmake b/Modules/Internal/CPack/CPackZIP.cmake index 376520c12..f619de400 100644 --- a/Modules/CPackZIP.cmake +++ b/Modules/Internal/CPack/CPackZIP.cmake @@ -28,4 +28,3 @@ if(NOT ZIP_EXECUTABLE) set(CPACK_ZIP_NEED_QUOTES FALSE) endif() endif() - diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 9001888da..f75ae7836 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -847,7 +847,7 @@ Section "Uninstall" @CPACK_NSIS_DELETE_ICONS@ @CPACK_NSIS_DELETE_ICONS_EXTRA@ - ;Delete empty start menu parent diretories + ;Delete empty start menu parent directories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" startMenuDeleteLoop: @@ -866,7 +866,7 @@ Section "Uninstall" Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" @CPACK_NSIS_DELETE_ICONS_EXTRA@ - ;Delete empty start menu parent diretories + ;Delete empty start menu parent directories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" secondStartMenuDeleteLoop: diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake index f739ab1ef..9ed1e01f9 100644 --- a/Modules/Platform/Android-Clang.cmake +++ b/Modules/Platform/Android-Clang.cmake @@ -40,5 +40,6 @@ macro(__android_compiler_clang lang) endif() if(NOT CMAKE_${lang}_COMPILER_TARGET) set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}") endif() endmacro() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index e623902f4..bb42eedde 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -18,6 +18,9 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1) return() endif() +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + # If the user provided CMAKE_SYSROOT for us, extract information from it. set(_ANDROID_SYSROOT_NDK "") set(_ANDROID_SYSROOT_API "") @@ -371,3 +374,5 @@ endif() # Report the chosen architecture. message(STATUS "Android: Targeting API '${CMAKE_SYSTEM_VERSION}' with architecture '${CMAKE_ANDROID_ARCH}', ABI '${CMAKE_ANDROID_ARCH_ABI}', and processor '${CMAKE_SYSTEM_PROCESSOR}'") + +cmake_policy(POP) diff --git a/Modules/Platform/Apple-Intel.cmake b/Modules/Platform/Apple-Intel.cmake index 2d4f7e591..a854be996 100644 --- a/Modules/Platform/Apple-Intel.cmake +++ b/Modules/Platform/Apple-Intel.cmake @@ -10,6 +10,9 @@ macro(__apple_compiler_intel lang) set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") endif() diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake index bf61d7b9d..9b384df8a 100644 --- a/Modules/Platform/GHS-MULTI-Initialize.cmake +++ b/Modules/Platform/GHS-MULTI-Initialize.cmake @@ -1,40 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +#Setup Green Hills MULTI specific compilation information -#Setup Greenhills MULTI specific compilation information - -if (NOT GHS_INT_DIRECTORY) - #Assume the C:/ghs/int#### directory that is latest is preferred - set(GHS_EXPECTED_ROOT "C:/ghs") - if (EXISTS ${GHS_EXPECTED_ROOT}) - FILE(GLOB GHS_CANDIDATE_INT_DIRS RELATIVE - ${GHS_EXPECTED_ROOT} ${GHS_EXPECTED_ROOT}/*) - string(REGEX MATCHALL "int[0-9][0-9][0-9][0-9a-z]" GHS_CANDIDATE_INT_DIRS - ${GHS_CANDIDATE_INT_DIRS}) - if (GHS_CANDIDATE_INT_DIRS) - list(SORT GHS_CANDIDATE_INT_DIRS) - list(GET GHS_CANDIDATE_INT_DIRS -1 GHS_INT_DIRECTORY) - string(CONCAT GHS_INT_DIRECTORY ${GHS_EXPECTED_ROOT} "/" - ${GHS_INT_DIRECTORY}) +set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") +mark_as_advanced(GHS_OS_ROOT) + +set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory") +mark_as_advanced(GHS_OS_DIR) + +#set GHS_OS_DIR if not set by user +if ( NOT GHS_OS_DIR ) + if (EXISTS ${GHS_OS_ROOT}) + + #get all directories in root directory + FILE(GLOB GHS_CANDIDATE_OS_DIRS + LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*) + FILE(GLOB GHS_CANDIDATE_OS_FILES + LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*) + if ( GHS_CANDIDATE_OS_FILES ) + list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES}) endif () - endif () - #Try to look for known registry values - if (NOT GHS_INT_DIRECTORY) - find_path(GHS_INT_DIRECTORY INTEGRITY.ld PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GreenHillsSoftware6433c345;InstallLocation]" #int1122 - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GreenHillsSoftware289b6625;InstallLocation]" #int1104 - ) - endif () + #filter based on platform name + if (GHS_TARGET_PLATFORM STREQUAL "integrity") + list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z].*") + endif () + + if (GHS_CANDIDATE_OS_DIRS) + list(SORT GHS_CANDIDATE_OS_DIRS) + list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR) + string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR}) + endif() - set(GHS_INT_DIRECTORY ${GHS_INT_DIRECTORY} CACHE PATH - "Path to integrity directory") + set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE) + endif () endif () -set(GHS_OS_DIR ${GHS_INT_DIRECTORY} CACHE PATH "OS directory") -set(GHS_PRIMARY_TARGET "arm_integrity.tgt" CACHE STRING "target for compilation") -set(GHS_BSP_NAME "simarm" CACHE STRING "BSP name") +set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") + set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization") mark_as_advanced(GHS_CUSTOMIZATION) set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons") diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake index e8c3b657b..fac29a8fa 100644 --- a/Modules/Platform/GNU.cmake +++ b/Modules/Platform/GNU.cmake @@ -8,6 +8,33 @@ set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") +# Debian policy requires that shared libraries be installed without +# executable permission. Fedora policy requires that shared libraries +# be installed with the executable permission. Since the native tools +# create shared libraries with execute permission in the first place a +# reasonable policy seems to be to install with execute permission by +# default. In order to support debian packages we provide an option +# here. The option default is based on the current distribution, but +# packagers can set it explicitly on the command line. +if(DEFINED CMAKE_INSTALL_SO_NO_EXE) + # Store the decision variable in the cache. This preserves any + # setting the user provides on the command line. + set(CMAKE_INSTALL_SO_NO_EXE "${CMAKE_INSTALL_SO_NO_EXE}" CACHE INTERNAL + "Install .so files without execute permission.") +else() + # Store the decision variable as an internal cache entry to avoid + # checking the platform every time. This option is advanced enough + # that only package maintainers should need to adjust it. They are + # capable of providing a setting on the command line. + if(EXISTS "/etc/debian_version") + set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL + "Install .so files without execute permission.") + else() + set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL + "Install .so files without execute permission.") + endif() +endif() + set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-gnu[a-z0-9_]*") include(Platform/UnixPaths) diff --git a/Modules/Platform/Generic-ADSP-C.cmake b/Modules/Platform/Generic-ADSP-C.cmake index de1cee298..c8597cda7 100644 --- a/Modules/Platform/Generic-ADSP-C.cmake +++ b/Modules/Platform/Generic-ADSP-C.cmake @@ -9,6 +9,9 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " ") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " ") +set(CMAKE_C_LINKER_WRAPPER_FLAG "-flags-link" " ") +set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") + 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>") @@ -17,4 +20,3 @@ set(CMAKE_C_LINK_EXECUTABLE set(CMAKE_C_CREATE_SHARED_LIBRARY) set(CMAKE_C_CREATE_MODULE_LIBRARY) - diff --git a/Modules/Platform/Generic-ADSP-CXX.cmake b/Modules/Platform/Generic-ADSP-CXX.cmake index 0cde8f2e6..d76bb66bd 100644 --- a/Modules/Platform/Generic-ADSP-CXX.cmake +++ b/Modules/Platform/Generic-ADSP-CXX.cmake @@ -7,6 +7,9 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " ") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ") string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " ") +set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-flags-link" " ") +set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",") + 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>") @@ -15,4 +18,3 @@ set(CMAKE_CXX_LINK_EXECUTABLE set(CMAKE_CXX_CREATE_SHARED_LIBRARY) set(CMAKE_CXX_CREATE_MODULE_LIBRARY) - diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake index 4b3912af3..aef4abf17 100644 --- a/Modules/Platform/Generic-SDCC-C.cmake +++ b/Modules/Platform/Generic-SDCC-C.cmake @@ -37,6 +37,8 @@ if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT) set (CMAKE_EXE_LINKER_FLAGS_INIT --model-small) endif() +set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl" ",") + # compile a C file into an object file set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") @@ -51,4 +53,3 @@ set(CMAKE_C_CREATE_STATIC_LIBRARY # not supported by sdcc set(CMAKE_C_CREATE_SHARED_LIBRARY "") set(CMAKE_C_CREATE_MODULE_LIBRARY "") - diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index ee9aac26a..f712e2b5f 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -30,6 +30,9 @@ macro(__linux_compiler_intel lang) # executables that use dlopen but do not set ENABLE_EXPORTS. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) if(XIAR) diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index f8e1c9e56..48b936eb6 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -76,6 +76,8 @@ macro(__embarcadero_language lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string. set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) + set (CMAKE_${lang}_LINKER_WRAPPER_FLAG "-l") + # compile a source file into an object file # place <DEFINES> outside the response file because Borland refuses # to parse quotes from the response file. diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index ba31001ea..96b1760ab 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -11,7 +11,7 @@ set(__WINDOWS_INTEL 1) include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - string(REPLACE "<CMAKE_LINKER> /lib" "lib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") + string(REPLACE "<CMAKE_LINKER> /lib" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") foreach(rule CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) string(REPLACE "<CMAKE_LINKER>" "xilink" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") endforeach() diff --git a/Modules/Platform/WindowsPhone-Clang-C.cmake b/Modules/Platform/WindowsPhone-Clang-C.cmake new file mode 100644 index 000000000..6e38572cd --- /dev/null +++ b/Modules/Platform/WindowsPhone-Clang-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-C) diff --git a/Modules/Platform/WindowsPhone-Clang-CXX.cmake b/Modules/Platform/WindowsPhone-Clang-CXX.cmake new file mode 100644 index 000000000..bf47978c4 --- /dev/null +++ b/Modules/Platform/WindowsPhone-Clang-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-CXX) diff --git a/Modules/Platform/WindowsPhone-GNU-C.cmake b/Modules/Platform/WindowsPhone-GNU-C.cmake new file mode 100644 index 000000000..ff6acd56d --- /dev/null +++ b/Modules/Platform/WindowsPhone-GNU-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-C) diff --git a/Modules/Platform/WindowsPhone-GNU-CXX.cmake b/Modules/Platform/WindowsPhone-GNU-CXX.cmake new file mode 100644 index 000000000..6adab6af3 --- /dev/null +++ b/Modules/Platform/WindowsPhone-GNU-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-CXX) diff --git a/Modules/Platform/WindowsStore-Clang-C.cmake b/Modules/Platform/WindowsStore-Clang-C.cmake new file mode 100644 index 000000000..6e38572cd --- /dev/null +++ b/Modules/Platform/WindowsStore-Clang-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-C) diff --git a/Modules/Platform/WindowsStore-Clang-CXX.cmake b/Modules/Platform/WindowsStore-Clang-CXX.cmake new file mode 100644 index 000000000..bf47978c4 --- /dev/null +++ b/Modules/Platform/WindowsStore-Clang-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-CXX) diff --git a/Modules/Platform/WindowsStore-GNU-C.cmake b/Modules/Platform/WindowsStore-GNU-C.cmake new file mode 100644 index 000000000..ff6acd56d --- /dev/null +++ b/Modules/Platform/WindowsStore-GNU-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-C) diff --git a/Modules/Platform/WindowsStore-GNU-CXX.cmake b/Modules/Platform/WindowsStore-GNU-CXX.cmake new file mode 100644 index 000000000..6adab6af3 --- /dev/null +++ b/Modules/Platform/WindowsStore-GNU-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-CXX) diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index 772a6150e..8a37884b7 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -12,7 +12,7 @@ # Sets the variable named ${var} to the number of physical cores # available on the machine if the information can be determined. # Otherwise it is set to 0. Currently this functionality is implemented -# for AIX, cygwin, FreeBSD, HPUX, IRIX, Linux, Mac OS X, QNX, Sun and +# for AIX, cygwin, FreeBSD, HPUX, IRIX, Linux, macOS, QNX, Sun and # Windows. # # This function is guaranteed to return a positive integer (>=1) if it diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 492842b2a..82fbc4bbc 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -30,9 +30,10 @@ Defines the following command for use with ``SWIG``: .. note:: - The variable ``SWIG_MODULE_<name>_REAL_NAME`` will be set to the name - of the swig module target library. This variable is useless if variable - ``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``. + This command creates a target with the specified ``<name>`` when + policy :policy:`CMP0078` is set to ``NEW``. Otherwise, the legacy + behavior will choose a different target name and store it in the + ``SWIG_MODULE_<name>_REAL_NAME`` variable. .. note:: @@ -117,6 +118,13 @@ ensure generated files will receive the required settings. :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and :prop_sf:`COMPILE_OPTIONS`. +``USE_TARGET_INCLUDE_DIRECTORIES`` + If set to ``TRUE``, contents of target property + :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler. + If set to ``FALSE`` target property :prop_tgt:`INCLUDE_DIRECTORIES` will be + ignored. If not set, target property ``SWIG_USE_TARGET_INCLUDE_DIRECTORIES`` + will be considered. + ``GENERATED_INCLUDE_DIRECTORIES``, ``GENERATED_COMPILE_DEFINITIONS`` and ``GENERATED_COMPILE_OPTIONS`` Add custom flags to the C/C++ generated source. They will fill, respectively, properties :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and @@ -149,6 +157,13 @@ input files. set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2) set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb) +``SWIG_USE_TARGET_INCLUDE_DIRECTORIES`` + If set to ``TRUE``, contents of target property + :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler. + If set to ``FALSE`` or not defined, target property + :prop_tgt:`INCLUDE_DIRECTORIES` will be ignored. This behavior can be + overridden by specifying source property ``USE_TARGET_INCLUDE_DIRECTORIES``. + ``SWIG_GENERATED_INCLUDE_DIRECTORIES``, ``SWIG_GENERATED_COMPILE_DEFINITIONS`` and ``SWIG_GENERATED_COMPILE_OPTIONS`` These properties will populate, respectively, properties :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and @@ -183,13 +198,6 @@ information about support files generated by ``SWIG`` interface compilation. Some variables can be set to customize the behavior of ``swig_add_library`` as well as ``SWIG``: -``UseSWIG_TARGET_NAME_PREFERENCE`` - Specify target name strategy. - - * Set to ``LEGACY`` or undefined: legacy strategy is applied. Variable - ``SWIG_MODULE_<name>_REAL_NAME`` must be used to get real target name. - * Set to ``STANDARD``: target name matches specified name. - ``UseSWIG_MODULE_VERSION`` Specify different behaviors for ``UseSWIG`` module. @@ -211,8 +219,13 @@ as well as ``SWIG``: Specify extra dependencies for the generated module for ``<name>``. #]=======================================================================] - +cmake_policy(GET CMP0078 target_name_policy) cmake_policy (VERSION 3.12) +if (target_name_policy) + # respect user choice regarding CMP0078 policy + cmake_policy(SET CMP0078 ${target_name_policy}) +endif() +unset(target_name_policy) set(SWIG_CXX_EXTENSION "cxx") set(SWIG_EXTRA_LIBRARIES "") @@ -221,6 +234,8 @@ set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py") set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java") set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs") +set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake") + ## ## PRIVATE functions ## @@ -347,6 +362,14 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() set (property "$<TARGET_PROPERTY:${target_name},SWIG_INCLUDE_DIRECTORIES>") list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-I>>") + set (property "$<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>") + get_source_file_property(use_target_include_dirs "${infile}" USE_TARGET_INCLUDE_DIRECTORIES) + if (use_target_include_dirs) + list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>") + elseif(use_target_include_dirs STREQUAL "NOTFOUND") + # not defined at source level, rely on target level + list (APPEND swig_source_file_flags "$<$<AND:$<BOOL:$<TARGET_PROPERTY:${target_name},SWIG_USE_TARGET_INCLUDE_DIRECTORIES>>,$<BOOL:${property}>>:-I$<JOIN:${property},$<SEMICOLON>-I>>") + endif() set (property "$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_DEFINITIONS>") list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-D>>") @@ -423,9 +446,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) if (UseSWIG_MODULE_VERSION VERSION_GREATER 1) # as part of custom command, start by removing old generated files # to ensure obsolete files do not stay - set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}") + set (swig_file_outdir "${workingdir}/${swig_source_file_name_we}.files") + set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=CLEAN -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}") + set (swig_copy_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=COPY -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}") else() + set (swig_file_outdir "${outdir}") unset (swig_cleanup_command) + unset (swig_copy_command) endif() # IMPLICIT_DEPENDS below can not handle situations where a dependent file is @@ -455,16 +482,17 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" "${swig_source_file_flags}" - -outdir "${outdir}" + -outdir "${swig_file_outdir}" ${swig_special_flags} ${swig_extra_flags} "${swig_include_dirs}" -o "${swig_generated_file_fullname}" "${swig_source_file_fullname}" + ${swig_copy_command} MAIN_DEPENDENCY "${swig_source_file_fullname}" DEPENDS ${swig_dependencies} IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}" - COMMENT "Swig source" + COMMENT "Swig compile ${infile} for ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" COMMAND_EXPAND_LISTS) set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} PROPERTIES GENERATED 1) @@ -528,10 +556,22 @@ function(SWIG_ADD_LIBRARY name) unset(_SAM_TYPE) endif() - if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE) - set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY) - elseif (NOT UseSWIG_TARGET_NAME_PREFERENCE MATCHES "^(LEGACY|STANDARD)$") - message (FATAL_ERROR "UseSWIG_TARGET_NAME_PREFERENCE: ${UseSWIG_TARGET_NAME_PREFERENCE}: invalid value. 'LEGACY' or 'STANDARD' is expected.") + cmake_policy(GET CMP0078 target_name_policy) + if (target_name_policy STREQUAL "NEW") + set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD) + else() + if (NOT target_name_policy) + message(AUTHOR_WARNING + "Policy CMP0078 is not set. " + "Run \"cmake --help-policy CMP0078\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + ) + endif() + if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE) + set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY) + elseif (NOT UseSWIG_TARGET_NAME_PREFERENCE MATCHES "^(LEGACY|STANDARD)$") + message (FATAL_ERROR "UseSWIG_TARGET_NAME_PREFERENCE: ${UseSWIG_TARGET_NAME_PREFERENCE}: invalid value. 'LEGACY' or 'STANDARD' is expected.") + endif() endif() if (NOT DEFINED UseSWIG_MODULE_VERSION) diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake new file mode 100644 index 000000000..4a03900b7 --- /dev/null +++ b/Modules/UseSWIG/ManageSupportFiles.cmake @@ -0,0 +1,31 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +if (ACTION STREQUAL "CLEAN") + # Collect current list of generated files + file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + + if (files) + # clean-up the output directory + ## compute full paths + list (TRANSFORM files PREPEND "${SUPPORT_FILES_OUTPUT_DIRECTORY}/") + ## remove generated files from the output directory + file (REMOVE ${files}) + + # clean-up working directory + file (REMOVE_RECURSE "${SUPPORT_FILES_WORKING_DIRECTORY}") + endif() + + file (MAKE_DIRECTORY "${SUPPORT_FILES_WORKING_DIRECTORY}") +endif() + +if (ACTION STREQUAL "COPY") + # Collect current list of generated files + file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + + if (files) + # copy files to the output directory + file (COPY ${files} DESTINATION "${SUPPORT_FILES_OUTPUT_DIRECTORY}") + endif() +endif() |