summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/BundleUtilities.cmake61
-rw-r--r--Modules/CMakeCUDAInformation.cmake3
-rw-r--r--Modules/CMakeDependentOption.cmake5
-rw-r--r--Modules/CMakeDetermineCSharpCompiler.cmake1
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake22
-rw-r--r--Modules/CMakeDetermineSwiftCompiler.cmake2
-rw-r--r--Modules/CMakeFindBinUtils.cmake64
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake12
-rw-r--r--Modules/CMakeRCInformation.cmake11
-rw-r--r--Modules/CMakeSwiftInformation.cmake37
-rw-r--r--Modules/CPack.cmake23
-rw-r--r--Modules/CheckCXXSymbolExists.cmake39
-rw-r--r--Modules/CheckSymbolExists.cmake36
-rw-r--r--Modules/Compiler/Clang.cmake2
-rw-r--r--Modules/Compiler/GNU-CXX-FeatureTests.cmake4
-rw-r--r--Modules/Compiler/GNU.cmake8
-rw-r--r--Modules/Compiler/IAR-C.cmake2
-rw-r--r--Modules/Compiler/Intel-Fortran.cmake2
-rw-r--r--Modules/Compiler/Intel.cmake7
-rw-r--r--Modules/Compiler/NVIDIA-CUDA.cmake1
-rw-r--r--Modules/Compiler/XL.cmake2
-rw-r--r--Modules/CompilerId/VS-10.vcxproj.in1
-rw-r--r--Modules/ExternalProject.cmake70
-rw-r--r--Modules/FindBZip2.cmake4
-rw-r--r--Modules/FindBacktrace.cmake2
-rw-r--r--Modules/FindBoost.cmake3
-rw-r--r--Modules/FindCUDA.cmake12
-rw-r--r--Modules/FindCUDA/run_nvcc.cmake3
-rw-r--r--Modules/FindGTest.cmake8
-rw-r--r--Modules/FindLAPACK.cmake22
-rw-r--r--Modules/FindLibLZMA.cmake45
-rw-r--r--Modules/FindMPI.cmake8
-rw-r--r--Modules/FindMatlab.cmake260
-rw-r--r--Modules/FindOpenACC.cmake32
-rw-r--r--Modules/FindPNG.cmake4
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake4
-rw-r--r--Modules/FindPkgConfig.cmake7
-rw-r--r--Modules/FindProtobuf.cmake25
-rw-r--r--Modules/FindPython.cmake101
-rw-r--r--Modules/FindPython/Support.cmake2304
-rw-r--r--Modules/FindPython2.cmake44
-rw-r--r--Modules/FindPython3.cmake85
-rw-r--r--Modules/FindPythonInterp.cmake9
-rw-r--r--Modules/FindQt4.cmake2
-rw-r--r--Modules/FindVulkan.cmake2
-rw-r--r--Modules/GNUInstallDirs.cmake3
-rw-r--r--Modules/GetPrerequisites.cmake10
-rw-r--r--Modules/Internal/CPack/CPack.DS_Store.in (renamed from Modules/CPack.DS_Store.in)bin12292 -> 12292 bytes
-rw-r--r--Modules/Internal/CPack/CPack.Description.plist.in (renamed from Modules/CPack.Description.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.Info.plist.in (renamed from Modules/CPack.Info.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.NuGet.nuspec.in (renamed from Modules/CPack.NuGet.nuspec.in)0
-rw-r--r--[-rwxr-xr-x]Modules/Internal/CPack/CPack.OSXScriptLauncher.in (renamed from Modules/CPack.OSXScriptLauncher.in)bin29592 -> 29592 bytes
-rw-r--r--Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in (renamed from Modules/CPack.OSXScriptLauncher.rsrc.in)bin362 -> 362 bytes
-rw-r--r--Modules/Internal/CPack/CPack.OSXX11.Info.plist.in (renamed from Modules/CPack.OSXX11.Info.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.OSXX11.main.scpt.in (renamed from Modules/CPack.OSXX11.main.scpt.in)bin1870 -> 1870 bytes
-rwxr-xr-xModules/Internal/CPack/CPack.RuntimeScript.in (renamed from Modules/CPack.RuntimeScript.in)0
-rwxr-xr-xModules/Internal/CPack/CPack.STGZ_Header.sh.in (renamed from Modules/CPack.STGZ_Header.sh.in)27
-rw-r--r--Modules/Internal/CPack/CPack.VolumeIcon.icns.in (renamed from Modules/CPack.VolumeIcon.icns.in)bin45739 -> 45739 bytes
-rw-r--r--Modules/Internal/CPack/CPack.background.png.in (renamed from Modules/CPack.background.png.in)bin44108 -> 44108 bytes
-rw-r--r--Modules/Internal/CPack/CPack.distribution.dist.in (renamed from Modules/CPack.distribution.dist.in)0
-rw-r--r--Modules/Internal/CPack/CPackDeb.cmake2
-rw-r--r--Modules/Internal/CPack/CPackNuGet.cmake2
-rw-r--r--Modules/Internal/CPack/NSIS.InstallOptions.ini.in (renamed from Modules/NSIS.InstallOptions.ini.in)0
-rw-r--r--Modules/Internal/CPack/NSIS.template.in (renamed from Modules/NSIS.template.in)0
-rw-r--r--Modules/Internal/CPack/WIX.template.in (renamed from Modules/WIX.template.in)0
-rw-r--r--Modules/Platform/AIX-GNU.cmake23
-rw-r--r--Modules/Platform/AIX-XL.cmake39
-rw-r--r--Modules/Platform/AIX.cmake2
-rwxr-xr-xModules/Platform/AIX/ExportImportList53
-rw-r--r--Modules/Platform/Android-Clang.cmake3
-rw-r--r--Modules/Platform/Android-Common.cmake44
-rw-r--r--Modules/Platform/Android-Determine.cmake58
-rw-r--r--Modules/Platform/Android-Initialize.cmake9
-rw-r--r--Modules/Platform/Android/Determine-Compiler-NDK.cmake58
-rw-r--r--Modules/Platform/Android/Determine-Compiler-Standalone.cmake1
-rw-r--r--Modules/Platform/Android/Determine-Compiler.cmake2
-rw-r--r--Modules/Platform/Android/abi-common.cmake2
-rw-r--r--Modules/Platform/Apple-XL-C.cmake1
-rw-r--r--Modules/Platform/Apple-XL-CXX.cmake1
-rw-r--r--Modules/Platform/Linux-XL-C.cmake1
-rw-r--r--Modules/Platform/Linux-XL-CXX.cmake1
-rw-r--r--Modules/Platform/Linux-XL-Fortran.cmake1
-rw-r--r--Modules/Platform/SunOS-Clang-C.cmake1
-rw-r--r--Modules/Platform/SunOS-Clang-CXX.cmake1
-rw-r--r--Modules/Platform/Windows-Clang.cmake33
-rw-r--r--Modules/Platform/Windows-Embarcadero.cmake7
-rw-r--r--Modules/Platform/Windows-MSVC.cmake9
-rw-r--r--Modules/Platform/Windows-OpenWatcom.cmake2
-rw-r--r--Modules/ProcessorCount.cmake10
89 files changed, 2548 insertions, 1259 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index f94fc5c..2f3b9e1 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -243,11 +243,13 @@ if(DEFINED CMAKE_GENERATOR)
endif()
endif()
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
# The functions defined in this file depend on the get_prerequisites function
# (and possibly others) found in:
#
-get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake")
function(get_bundle_main_executable bundle result_var)
@@ -280,7 +282,7 @@ function(get_bundle_main_executable bundle result_var)
endif()
endforeach()
- if(NOT "${bundle_executable}" STREQUAL "")
+ if(NOT bundle_executable STREQUAL "")
if(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}")
set(result "${bundle}/Contents/MacOS/${bundle_executable}")
else()
@@ -600,17 +602,9 @@ function(get_bundle_keys app libs dirs keys_var)
set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${lib} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
@@ -627,7 +621,7 @@ function(get_bundle_keys app libs dirs keys_var)
foreach(exe ${exes})
# Main executable is scanned first above:
#
- if(NOT "${exe}" STREQUAL "${executable}")
+ if(NOT exe STREQUAL executable)
# Add the exe itself to the keys:
#
set_bundle_key_values(${keys_var} "${exe}" "${exe}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
@@ -643,17 +637,9 @@ function(get_bundle_keys app libs dirs keys_var)
# Add each prerequisite to the keys:
#
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${exe} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
@@ -665,7 +651,7 @@ function(get_bundle_keys app libs dirs keys_var)
# preserve library symlink structure
foreach(key ${${keys_var}})
- if("${${key}_COPYFLAG}" STREQUAL 1)
+ if("${${key}_COPYFLAG}" STREQUAL "1")
if(IS_SYMLINK "${${key}_RESOLVED_ITEM}")
get_filename_component(target "${${key}_RESOLVED_ITEM}" REALPATH)
set_bundle_key_values(${keys_var} "${exe}" "${target}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
@@ -682,7 +668,7 @@ function(get_bundle_keys app libs dirs keys_var)
get_filename_component(resolved_item_compare "${resolved_item_compare}" NAME)
get_filename_component(resolved_embedded_item_compare "${resolved_embedded_item_compare}" NAME)
- if(NOT "${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(NOT resolved_item_compare STREQUAL resolved_embedded_item_compare)
set(${key}_COPYFLAG "2")
set(${key}_RESOLVED_ITEM "${${targetkey}_RESOLVED_EMBEDDED_ITEM}")
endif()
@@ -716,7 +702,7 @@ function(link_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not linking...")
else()
get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY)
@@ -738,7 +724,7 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
@@ -761,7 +747,7 @@ function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_ite
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
if(BU_COPY_FULL_FRAMEWORK_CONTENTS)
@@ -841,12 +827,12 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
string(LENGTH "${resolved_embedded_item}" resolved_embedded_item_length)
set(path_too_short 0)
set(is_embedded 0)
- if(${resolved_embedded_item_length} LESS ${exe_dotapp_dir_length})
+ if(resolved_embedded_item_length LESS exe_dotapp_dir_length)
set(path_too_short 1)
endif()
if(NOT path_too_short)
string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring)
- if("${exe_dotapp_dir}/" STREQUAL "${item_substring}")
+ if("${exe_dotapp_dir}/" STREQUAL item_substring)
set(is_embedded 1)
endif()
endif()
@@ -1032,18 +1018,9 @@ function(verify_bundle_prerequisites bundle result_var info_var)
message(STATUS "executable file ${count}: ${f}")
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${f} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
-
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_item_rpaths(${f} _main_exe_rpaths)
get_prerequisites("${f}" prereqs 1 1 "${exepath}" "${_main_exe_rpaths}")
@@ -1063,11 +1040,11 @@ function(verify_bundle_prerequisites bundle result_var info_var)
gp_file_type("${f}" "${p}" p_type)
if(APPLE)
- if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
+ if(NOT p_type STREQUAL "embedded" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
else()
- if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
+ if(NOT p_type STREQUAL "local" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
endif()
@@ -1142,3 +1119,5 @@ function(verify_app app)
message(FATAL_ERROR "error: verify_app failed")
endif()
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake
index 43ae989..b0d80d1 100644
--- a/Modules/CMakeCUDAInformation.cmake
+++ b/Modules/CMakeCUDAInformation.cmake
@@ -171,7 +171,8 @@ if(NOT CMAKE_CUDA_LINK_EXECUTABLE)
"<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
endif()
-if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
+if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
+ CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
else()
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake
index 6046d85..99d5070 100644
--- a/Modules/CMakeDependentOption.cmake
+++ b/Modules/CMakeDependentOption.cmake
@@ -12,7 +12,7 @@ conditions are true. When the option is not presented a default value
is used, but any value set by the user is preserved for when the
option is presented again. Example invocation:
-::
+.. code-block:: cmake
CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON
"USE_BAR;NOT USE_ZOT" OFF)
@@ -21,7 +21,8 @@ If USE_BAR is true and USE_ZOT is false, this provides an option
called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to
OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for
the USE_FOO option is saved so that when the option is re-enabled it
-retains its old value.
+retains its old value. Each element in the fourth parameter is
+evaluated as an if-condition, so :ref:`Condition Syntax` can be used.
#]=======================================================================]
macro(CMAKE_DEPENDENT_OPTION option doc default depends force)
diff --git a/Modules/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake
index dab9414..da860a8 100644
--- a/Modules/CMakeDetermineCSharpCompiler.cmake
+++ b/Modules/CMakeDetermineCSharpCompiler.cmake
@@ -18,7 +18,6 @@ if(NOT CMAKE_CSharp_COMPILER_ID_RUN)
set(CMAKE_CSharp_COMPILER_ID_RUN 1)
# Try to identify the compiler.
- set(CMAKE_CSharp_COMPILER_ID_STRINGS_PARAMETERS ENCODING UTF-16LE)
set(CMAKE_CSharp_COMPILER_ID)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CSharp CSFLAGS CMakeCSharpCompilerId.cs)
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 02bc14b..40658ea 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -347,8 +347,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
set(id_compile "CudaCompile")
set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]])
- string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
- string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
+ if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR)
+ set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>")
+ string(CONCAT id_Import_props "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.props\" />")
+ string(CONCAT id_Import_targets "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.targets\" />")
+ else()
+ string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
+ string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
+ endif()
if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform></CudaCompile>")
endif()
@@ -640,10 +646,14 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(ARCHITECTURE_ID)
set(SIMULATE_ID)
set(SIMULATE_VERSION)
- file(STRINGS ${file}
- CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 38
- ${CMAKE_${lang}_COMPILER_ID_STRINGS_PARAMETERS}
- REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]")
+ foreach(encoding "" "ENCODING;UTF-16LE" "ENCODING;UTF-16BE")
+ file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS
+ LIMIT_COUNT 38 ${encoding}
+ REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]")
+ if(NOT CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "")
+ break()
+ endif()
+ endforeach()
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.
diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake
index 2fcf7b0..9aafe48 100644
--- a/Modules/CMakeDetermineSwiftCompiler.cmake
+++ b/Modules/CMakeDetermineSwiftCompiler.cmake
@@ -53,7 +53,7 @@ if(NOT CMAKE_Swift_COMPILER_ID_RUN)
list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple)
set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler")
- set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift")
+ set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwift[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift")
set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2)
endif()
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index 0e84116..01f9dae 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -69,10 +69,15 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
OR (CMAKE_GENERATOR MATCHES "Visual Studio"
AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android"))
- find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")
+ find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm llvm-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link")
+ endif()
+
+ find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- list(APPEND _CMAKE_TOOL_VARS CMAKE_LINKER CMAKE_MT)
+ list(APPEND _CMAKE_TOOL_VARS LINKER MT)
# in all other cases search for ar, ranlib, etc.
else()
@@ -84,28 +89,48 @@ else()
endif()
if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang)
- set(LLVM_OBJDUMP "llvm-objdump")
- set(LLVM_LLD "ld.lld")
- set(LLVM_RANLIB "llvm-ranlib")
- set(LLVM_AR "llvm-ar")
+ set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-ar")
+ set(_CMAKE_ADDITIONAL_RANLIB_NAMES "llvm-ranlib")
+ set(_CMAKE_ADDITIONAL_STRIP_NAMES "llvm-strip")
+ set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld")
+ set(_CMAKE_ADDITIONAL_NM_NAMES "llvm-nm")
+ set(_CMAKE_ADDITIONAL_OBJDUMP_NAMES "llvm-objdump")
+ set(_CMAKE_ADDITIONAL_OBJCOPY_NAMES "llvm-objcopy")
+ set(_CMAKE_ADDITIONAL_READELF_NAMES "llvm-readelf")
+ set(_CMAKE_ADDITIONAL_DLLTOOL_NAMES "llvm-dlltool")
+ set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line")
endif()
- find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${LLVM_AR} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${LLVM_RANLIB} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_RANLIB)
set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
endif()
- find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${LLVM_LLD} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${LLVM_OBJDUMP} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
-
- list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
-
+ find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_READELF NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_DLLTOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_ADDR2LINE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+
+ list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE)
+
+
+ unset(_CMAKE_ADDITIONAL_AR_NAMES)
+ unset(_CMAKE_ADDITIONAL_RANLIB_NAMES)
+ unset(_CMAKE_ADDITIONAL_STRIP_NAMES)
+ unset(_CMAKE_ADDITIONAL_LINKER_NAMES)
+ unset(_CMAKE_ADDITIONAL_NM_NAMES)
+ unset(_CMAKE_ADDITIONAL_OBJDUMP_NAMES)
+ unset(_CMAKE_ADDITIONAL_OBJCOPY_NAMES)
+ unset(_CMAKE_ADDITIONAL_READELF_NAMES)
+ unset(_CMAKE_ADDITIONAL_DLLTOOL_NAMES)
+ unset(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES)
endif()
if(CMAKE_PLATFORM_HAS_INSTALLNAME)
@@ -115,15 +140,16 @@ if(CMAKE_PLATFORM_HAS_INSTALLNAME)
message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
endif()
- list(APPEND _CMAKE_TOOL_VARS CMAKE_INSTALL_NAME_TOOL)
+ list(APPEND _CMAKE_TOOL_VARS 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)
+ get_property(_CMAKE_TOOL_CACHED CACHE CMAKE_${var} PROPERTY TYPE)
if(_CMAKE_TOOL_CACHED)
- mark_as_advanced(${var})
+ mark_as_advanced(CMAKE_${var})
endif()
+ unset(_CMAKE_ADDITIONAL_${var}_NAMES)
endforeach()
unset(_CMAKE_TOOL_VARS)
unset(_CMAKE_TOOL_CACHED)
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 30659eb..0465515 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -47,6 +47,18 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
endif()
separate_arguments(args NATIVE_COMMAND "${line}")
list(GET args 0 cmd)
+ else()
+ #check to see if the link line is comma-separated instead of space separated
+ string(REGEX REPLACE "," " " line "${line}")
+ if("${line}" MATCHES "${linker_regex}" AND
+ NOT "${line}" MATCHES "${linker_exclude_regex}")
+ separate_arguments(args NATIVE_COMMAND "${line}")
+ list(GET args 0 cmd)
+ if("${cmd}" MATCHES "exec:")
+ # ibm xl sometimes has 'exec: ' in-front of the linker
+ list(GET args 1 cmd)
+ endif()
+ endif()
endif()
set(is_msvc 0)
if("${cmd}" MATCHES "${linker_regex}")
diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake
index 7bf6567..7c3a5ab 100644
--- a/Modules/CMakeRCInformation.cmake
+++ b/Modules/CMakeRCInformation.cmake
@@ -17,6 +17,17 @@ set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
+# This should be included before the _INIT variables are
+# used to initialize the cache. Since the rule variables
+# have if blocks on them, users can still define them here.
+# But, it should still be after the platform file so changes can
+# be made to those values.
+if(CMAKE_USER_MAKE_RULES_OVERRIDE)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
+endif()
+
set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}")
cmake_initialize_per_config_variable(CMAKE_RC_FLAGS "Flags for Windows Resource Compiler")
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index f6510b9..4f1d4f0 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -18,16 +18,25 @@ if(CMAKE_Swift_COMPILER_ID)
endif()
set(CMAKE_INCLUDE_FLAG_Swift "-I ")
-if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
+if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
+elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
endif()
set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ")
-set(CMAKE_Swift_COMPILER_ARG1 -frontend)
+set(CMAKE_Swift_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-tools-directory ")
+# NOTE(compnerd) the `-sdk` support is not yet ready in the compiler; when that
+# is fully working, we should be able to enable this.
+# set(CMAKE_Swift_COMPILE_OPTIONS_SYSROOT "-sdk ")
+# NOTE(compnerd) do not setup `-frontend` as we use the compiler as the driver
+# during the link phase and use that to drive the compilation
+set(CMAKE_Swift_COMPILER_ARG1 "")
set(CMAKE_Swift_DEFINE_FLAG -D)
set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ")
set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "")
+set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l")
set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
@@ -47,6 +56,8 @@ set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
+cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags")
+
# NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step
if(NOT CMAKE_Swift_COMPILE_OBJECT)
set(CMAKE_Swift_COMPILE_OBJECT ":")
@@ -56,12 +67,12 @@ if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$")
cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
endif()
+if(CMAKE_SYSTEM_NAME STREQUAL Windows)
+ set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:<TARGET_IMPLIB>")
+endif()
+
if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY)
- if(CMAKE_Swift_COMPILER_TARGET)
- set(CMAKE_Swift_CREATE_SHARED_LIBRARY "${CMAKE_Swift_COMPILER} -target <CMAKE_Swift_COMPILER_TARGET> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> <LINK_LIBRARIES>")
- else()
- set(CMAKE_Swift_CREATE_SHARED_LIBRARY "${CMAKE_Swift_COMPILER} -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> <LINK_LIBRARIES>")
- endif()
+ set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
endif()
if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
@@ -69,19 +80,11 @@ if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
endif()
if(NOT CMAKE_Swift_LINK_EXECUTABLE)
- if(CMAKE_Swift_COMPILER_TARGET)
- set(CMAKE_Swift_LINK_EXECUTABLE "${CMAKE_Swift_COMPILER} -target <CMAKE_Swift_COMPILER_TARGET> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
- else()
- set(CMAKE_Swift_LINK_EXECUTABLE "${CMAKE_Swift_COMPILER} -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
- endif()
+ set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
endif()
if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY)
- if(CMAKE_Swift_COMPILER_TARGET)
- set(CMAKE_Swift_CREATE_STATIC_LIBRARY "${CMAKE_Swift_COMPILER} -target <CMAKE_Swift_COMPILER_TARGET> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
- else()
- set(CMAKE_Swift_CREATE_STATIC_LIBRARY "${CMAKE_Swift_COMPILER} -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
- endif()
+ set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
set(CMAKE_Swift_ARCHIVE_FINISH "")
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index c9008db..1809846 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -301,6 +301,13 @@ The following variables are for advanced uses of CPack:
project. Defaults to the value of :variable:`CMAKE_GENERATOR`. Few users
will want to change this setting.
+.. variable:: CPACK_INSTALL_CMAKE_CONFIGURATIONS
+
+ Specify the project configurations to be packaged (e.g. ``Debug``, ``Release``,
+ etc.). When the CMake project uses a multi-configuration generator such as Xcode
+ or Visual Studio, this option can be used to specify what configurations
+ to include in the package.
+
.. variable:: CPACK_INSTALL_CMAKE_PROJECTS
List of four values that specify what project to install. The four values
@@ -325,7 +332,21 @@ The following variables are for advanced uses of CPack:
.. variable:: CPACK_INSTALL_COMMANDS
- Extra commands to install components.
+ Extra commands to install components. The environment variable
+ ``CMAKE_INSTALL_PREFIX`` is set to the temporary install directory
+ during execution.
+
+.. variable:: CPACK_INSTALL_SCRIPTS
+
+ Extra CMake scripts executed by CPack during its local staging
+ installation, which is done right before packaging the files.
+ The scripts are not called by a standalone install (e.g.: ``make install``).
+ For every script, the following variables will be set:
+ :variable:`CMAKE_CURRENT_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR`
+ and :variable:`CMAKE_INSTALL_PREFIX` (which is set to the staging install
+ directory). The singular form ``CMAKE_INSTALL_SCRIPT`` is supported as
+ an alternative variable for historical reasons, but its value is ignored if
+ ``CMAKE_INSTALL_SCRIPTS`` is set and a warning will be issued.
.. variable:: CPACK_INSTALLED_DIRECTORIES
diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake
index 2cccd09..5c9079d 100644
--- a/Modules/CheckCXXSymbolExists.cmake
+++ b/Modules/CheckCXXSymbolExists.cmake
@@ -5,26 +5,38 @@
CheckCXXSymbolExists
--------------------
-Check if a symbol exists as a function, variable, or macro in C++
+Check if a symbol exists as a function, variable, or macro in ``C++``.
-.. command:: CHECK_CXX_SYMBOL_EXISTS
+.. command:: check_cxx_symbol_exists
.. code-block:: cmake
- CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>)
+ check_cxx_symbol_exists(<symbol> <files> <variable>)
Check that the ``<symbol>`` is available after including given header
``<files>`` and store the result in a ``<variable>``. Specify the list of
files in one argument as a semicolon-separated list.
- ``CHECK_CXX_SYMBOL_EXISTS()`` can be used to check in C++ files, as
- opposed to ``CHECK_SYMBOL_EXISTS()``, which works only for ``C``.
+ ``check_cxx_symbol_exists()`` can be used to check for symbols as seen by
+ the C++ compiler, as opposed to :command:`check_symbol_exists`, which always
+ uses the ``C`` compiler.
If the header files define the symbol as a macro it is considered
available and assumed to work. If the header files declare the symbol
as a function or variable then the symbol must also be available for
- linking. If the symbol is a type or enum value it will not be
- recognized (consider using :module:`CheckTypeSize`
- or :module:`CheckCXXSourceCompiles`).
+ linking. If the symbol is a type, enum value, or C++ template it will
+ not be recognized: consider using the :module:`CheckTypeSize`
+ or :module:`CheckCXXSourceCompiles` module instead.
+
+.. note::
+
+ This command is unreliable when ``<symbol>`` is (potentially) an overloaded
+ function. Since there is no reliable way to predict whether a given function
+ in the system environment may be defined as an overloaded function or may be
+ an overloaded function on other systems or will become so in the future, it
+ is generally advised to use the :module:`CheckCXXSourceCompiles` module for
+ checking any function symbol (unless somehow you surely know the checked
+ function is not overloaded on other systems or will not be so in the
+ future).
The following variables may be set before calling this macro to modify
the way the check is run:
@@ -43,6 +55,17 @@ the way the check is run:
command. See policy :policy:`CMP0075`.
``CMAKE_REQUIRED_QUIET``
execute quietly without messages.
+
+For example:
+
+.. code-block:: cmake
+
+ include(CheckCXXSymbolExists)
+
+ # Check for macro SEEK_SET
+ check_cxx_symbol_exists(SEEK_SET "cstdio" HAVE_SEEK_SET)
+ # Check for function std::fopen
+ check_cxx_symbol_exists(std::fopen "cstdio" HAVE_STD_FOPEN)
#]=======================================================================]
include_guard(GLOBAL)
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index b9ef808..1053383 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -45,6 +45,17 @@ the way the check is run:
command. See policy :policy:`CMP0075`.
``CMAKE_REQUIRED_QUIET``
execute quietly without messages.
+
+For example:
+
+.. code-block:: cmake
+
+ include(CheckSymbolExists)
+
+ # Check for macro SEEK_SET
+ check_symbol_exists(SEEK_SET "stdio.h" HAVE_SEEK_SET)
+ # Check for function fopen
+ check_symbol_exists(fopen "stdio.h" HAVE_FOPEN)
#]=======================================================================]
include_guard(GLOBAL)
@@ -88,8 +99,28 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE)
string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
"#include <${FILE}>\n")
endforeach()
- string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
- "\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n")
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+int main(int argc, char** argv)
+{
+ (void)argv;")
+ set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];")
+ if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$")
+ # The SYMBOL has a legal macro name. Test whether it exists as a macro.
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+#ifndef ${SYMBOL}
+ ${_CSE_CHECK_NON_MACRO}
+#else
+ (void)argc;
+ return 0;
+#endif")
+ else()
+ # The SYMBOL cannot be a macro (e.g., a template function).
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+ ${_CSE_CHECK_NON_MACRO}")
+ endif()
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+}")
+ unset(_CSE_CHECK_NON_MACRO)
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
"${SOURCEFILE}" @ONLY)
@@ -128,6 +159,7 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE)
"${OUTPUT}\nFile ${SOURCEFILE}:\n"
"${CMAKE_CONFIGURABLE_FILE_CONTENT}\n")
endif()
+ unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
endif()
endmacro()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index c3f13f3..45c33fb 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -96,5 +96,7 @@ else()
set(CMAKE_${lang}_ARCHIVE_FINISH_IPO
"\"${__ranlib}\" <TARGET>"
)
+
+ set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
endmacro()
endif()
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
index d18adaf..45c5470 100644
--- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -18,18 +18,18 @@ set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}")
-set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
# GNU 4.3 supports binary literals as an extension, but may warn about
# use of extensions prior to GNU 4.9
# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones
set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}")
-# The feature below is documented as available in GNU 4.8 (by implementing an
+# The features below are documented as available in GNU 4.8 (by implementing an
# earlier draft of the standard paper), but that version of the compiler
# does not set __cplusplus to a value greater than 201103L until GNU 4.9:
# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
# So, CMake only reports availability for it with GNU 4.9 or later.
set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
# Introduced in GCC 4.8.1
set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 6b1bd3a..e0ff174 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -11,6 +11,9 @@ set(__COMPILER_GNU 1)
include(Compiler/CMakeCommonCompilerMacros)
include(Internal/CMakeCheckCompilerFlag)
+set(__pch_header_C "c-header")
+set(__pch_header_CXX "c++-header")
+
macro(__compiler_gnu lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
@@ -104,4 +107,9 @@ macro(__compiler_gnu lang)
unset(_COMPILER_ARGS)
endif()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+
+ set(CMAKE_PCH_EXTENSION .gch)
+ set(CMAKE_PCH_PROLOGUE "#pragma GCC system_header")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -include <PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -x ${__pch_header_${lang}} -include <PCH_HEADER>)
endmacro()
diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake
index 18a4a75..e03ce3f 100644
--- a/Modules/Compiler/IAR-C.cmake
+++ b/Modules/Compiler/IAR-C.cmake
@@ -15,7 +15,7 @@ if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e)
-elseif()
+else()
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e)
endif()
diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake
index 5275ddf..156b533 100644
--- a/Modules/Compiler/Intel-Fortran.cmake
+++ b/Modules/Compiler/Intel-Fortran.cmake
@@ -8,6 +8,8 @@ set(CMAKE_Fortran_MODDIR_FLAG "-module ")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
+set(CMAKE_Fortran_COMPILE_WITH_DEFINES 1)
+
set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index f2f16e0..d895ed0 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -32,5 +32,12 @@ else()
unset(_COMPILER_ARGS)
endif()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+
+ # Precompile Headers
+ set(CMAKE_PCH_EXTENSION .pchi)
+ set(CMAKE_LINK_PCH ON)
+ set(CMAKE_PCH_EPILOGUE "#pragma hdrstop")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -Wno-pch-messages -pch-use <PCH_FILE> -include <PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -Wno-pch-messages -pch-create <PCH_FILE> -include <PCH_HEADER>)
endmacro()
endif()
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake
index c0ccb71..b59deda 100644
--- a/Modules/Compiler/NVIDIA-CUDA.cmake
+++ b/Modules/Compiler/NVIDIA-CUDA.cmake
@@ -1,3 +1,4 @@
+set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake
index a9cec11..fc71ab4 100644
--- a/Modules/Compiler/XL.cmake
+++ b/Modules/Compiler/XL.cmake
@@ -18,6 +18,8 @@ macro(__compiler_xl lang)
set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=")
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=")
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj")
+
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index 32c4ffc..d742274 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -14,6 +14,7 @@
@id_system_version@
@id_WindowsTargetPlatformVersion@
@id_WindowsSDKDesktopARMSupport@
+ @id_CudaToolkitCustomDir@
</PropertyGroup>
@id_toolset_version_props@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 20b37d2..e55ed46 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -261,7 +261,9 @@ External Project Definition
``GIT_SUBMODULES <module>...``
Specific git submodules that should also be updated. If this option is
- not provided, all git submodules will be updated.
+ not provided, all git submodules will be updated. When :policy:`CMP0097`
+ is set to ``NEW`` if this value is set to an empty string then no submodules
+ are initialized or updated.
``GIT_SHALLOW <bool>``
When this option is enabled, the ``git clone`` operation will be given
@@ -1016,6 +1018,9 @@ function(_ep_parse_arguments f name ns args)
endif()
else()
set(key "${arg}")
+ if(key MATCHES GIT)
+ get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
+ endif()
endif()
endforeach()
endfunction()
@@ -1060,7 +1065,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -1074,7 +1079,7 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git
message(FATAL_ERROR "Tag for git checkout should not be empty.")
endif()
- set(git_clone_options)
+ set(git_clone_options "--no-checkout")
if(git_shallow)
if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
list(APPEND git_clone_options "--depth 1 --no-single-branch")
@@ -1145,11 +1150,14 @@ if(error_code)
message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
endif()
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
+set(init_submodules ${init_submodules})
+if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
+endif()
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -1226,7 +1234,7 @@ endif()
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules git_repository work_dir)
if("${git_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for git checkout should not be empty.")
endif()
@@ -1383,11 +1391,14 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
endif()
endif()
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
+ set(init_submodules ${init_submodules})
+ if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
+ endif()
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -1972,7 +1983,7 @@ endif()
set(stderr_log "${logbase}-err.log")
endif()
set(code "
-cmake_minimum_required(VERSION 3.13)
+cmake_minimum_required(VERSION 3.15)
${code_cygpath_make}
set(command \"${command}\")
set(log_merged \"${log_merged}\")
@@ -2420,7 +2431,15 @@ function(_ep_add_download_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
if(NOT git_remote_name)
@@ -2458,7 +2477,7 @@ function(_ep_add_download_command name)
# The script will delete the source directory and then call git clone.
#
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
- ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
)
set(comment "Performing download step (git clone) for '${name}'")
@@ -2723,9 +2742,18 @@ function(_ep_add_update_command name)
if(NOT git_remote_name)
set(git_remote_name "origin")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
+
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" ${git_repository} ${work_dir}
)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)
@@ -3138,6 +3166,10 @@ endfunction()
function(ExternalProject_Add name)
+ cmake_policy(GET CMP0097 _EP_CMP0097
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+
_ep_get_configuration_subdir_suffix(cfgdir)
# Add a custom target for the external project.
diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake
index 309b971..98ab72c 100644
--- a/Modules/FindBZip2.cmake
+++ b/Modules/FindBZip2.cmake
@@ -45,8 +45,8 @@ set(_BZIP2_PATHS PATHS
find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include)
if (NOT BZIP2_LIBRARIES)
- find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
- find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
+ find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 libbz2 libbzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
+ find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d libbz2d libbzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
SELECT_LIBRARY_CONFIGURATIONS(BZIP2)
diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake
index cf1632a..3d8ce88 100644
--- a/Modules/FindBacktrace.cmake
+++ b/Modules/FindBacktrace.cmake
@@ -74,7 +74,7 @@ else()
if(Backtrace_INCLUDE_DIR)
# OpenBSD has libbacktrace renamed to libexecinfo
find_library(Backtrace_LIBRARY "execinfo")
- elseif() # respect user wishes
+ else() # respect user wishes
set(_Backtrace_HEADER_TRY "backtrace.h")
find_path(Backtrace_INCLUDE_DIR ${_Backtrace_HEADER_TRY})
find_library(Backtrace_LIBRARY "backtrace")
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 078000f..744d2c7 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -2000,7 +2000,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
endif()
else()
set(Boost_${UPPERCOMPONENT}_HEADER ON)
- message(WARNING "No header defined for ${COMPONENT}; skipping header check")
+ message(WARNING "No header defined for ${COMPONENT}; skipping header check "
+ "(note: header-only libraries have no designated component)")
endif()
#
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 3315505..b6859aa 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -375,6 +375,11 @@ The script defines the following variables::
CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library.
Only available for CUDA version 3.2+.
Windows only.
+ CUDA_nvToolsExt_LIBRARY
+ -- NVIDA CUDA Tools Extension library.
+ Available for CUDA version 5+.
+ CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library.
+ Available for CUDA version 5+.
#]=======================================================================]
@@ -642,6 +647,8 @@ macro(cuda_unset_include_and_libraries)
unset(CUDA_npps_LIBRARY CACHE)
unset(CUDA_nvcuvenc_LIBRARY CACHE)
unset(CUDA_nvcuvid_LIBRARY CACHE)
+ unset(CUDA_nvToolsExt_LIBRARY CACHE)
+ unset(CUDA_OpenCL_LIBRARY CACHE)
unset(CUDA_GPU_DETECT_OUTPUT CACHE)
endmacro()
@@ -973,6 +980,11 @@ if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2")
find_cuda_helper_libs(cublas_device)
endif()
+if(NOT CUDA_VERSION VERSION_LESS "5.0")
+ find_cuda_helper_libs(nvToolsExt)
+ find_cuda_helper_libs(OpenCL)
+endif()
+
if(NOT CUDA_VERSION VERSION_LESS "9.0")
# In CUDA 9.0 NPP was nppi was removed
find_cuda_helper_libs(nppc)
diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake
index 6fc2439..af15d55 100644
--- a/Modules/FindCUDA/run_nvcc.cmake
+++ b/Modules/FindCUDA/run_nvcc.cmake
@@ -75,7 +75,8 @@ set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
@CUDA_NVCC_FLAGS_CONFIG@
set(nvcc_flags @nvcc_flags@) # list
-set(CUDA_NVCC_INCLUDE_DIRS "@CUDA_NVCC_INCLUDE_DIRS@") # list (needs to be in quotes to handle spaces properly).
+set(CUDA_NVCC_INCLUDE_DIRS [==[@CUDA_NVCC_INCLUDE_DIRS@]==]) # list (needs to be in lua quotes to address backslashes)
+string(REPLACE "\\" "/" CUDA_NVCC_INCLUDE_DIRS "${CUDA_NVCC_INCLUDE_DIRS}")
set(CUDA_NVCC_COMPILE_DEFINITIONS [==[@CUDA_NVCC_COMPILE_DEFINITIONS@]==]) # list (needs to be in lua quotes see #16510 ).
set(format_flag "@format_flag@") # string
set(cuda_language_flag @cuda_language_flag@) # list
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index b0175fe..e015a98 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -160,6 +160,10 @@ if(MSVC)
msvc/gtest-md/Release
msvc/x64/Debug
msvc/x64/Release
+ msvc/2010/gtest-md/Win32-Debug
+ msvc/2010/gtest-md/Win32-Release
+ msvc/2010/gtest-md/x64-Debug
+ msvc/2010/gtest-md/x64-Release
)
elseif(GTEST_MSVC_SEARCH STREQUAL "MT")
list(APPEND _gtest_libpath_suffixes
@@ -167,6 +171,10 @@ if(MSVC)
msvc/gtest/Release
msvc/x64/Debug
msvc/x64/Release
+ msvc/2010/gtest/Win32-Debug
+ msvc/2010/gtest/Win32-Release
+ msvc/2010/gtest/x64-Debug
+ msvc/2010/gtest/x64-Release
)
endif()
endif()
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index c9c3cce..844d36d 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -173,11 +173,15 @@ if(_libraries_work)
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endif()
-if(_libraries_work)
- set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
-else()
- set(${LIBRARIES} FALSE)
-endif()
+ if(_libraries_work)
+ if("${_list}" STREQUAL "")
+ set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ else()
+ set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
+ endif()
+ else()
+ set(${LIBRARIES} FALSE)
+ endif()
endmacro()
@@ -206,6 +210,7 @@ if(BLAS_FOUND)
#intel lapack
if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
+ if(NOT LAPACK_LIBRARIES)
if (NOT WIN32)
set(LAPACK_mkl_LM "-lm")
set(LAPACK_mkl_LDL "-ldl")
@@ -280,6 +285,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
unset(LAPACK_mkl_LM)
unset(LAPACK_mkl_LDL)
endif ()
+ endif()
endif()
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
@@ -426,5 +432,11 @@ else()
endif()
endif()
+# On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines)
+# we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above.
+if (LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ set(LAPACK_LIBRARIES "")
+endif()
+
cmake_pop_check_state()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index fc97655..200d6bf 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -42,7 +42,14 @@ This module will set the following variables in your project:
#]=======================================================================]
find_path(LIBLZMA_INCLUDE_DIR lzma.h )
-find_library(LIBLZMA_LIBRARY NAMES lzma liblzma)
+if(NOT LIBLZMA_LIBRARY)
+ find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma PATH_SUFFIXES lib)
+ find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad PATH_SUFFIXES lib)
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(LIBLZMA)
+else()
+ file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY)
+endif()
if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+")
@@ -62,9 +69,17 @@ if (LIBLZMA_LIBRARY)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY})
+ elseif(LIBLZMA_LIBRARY_RELEASE)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE})
+ elseif(LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG})
+ endif()
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+ unset(LIBLZMA_LIBRARY_check)
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
@@ -85,7 +100,25 @@ if (LIBLZMA_FOUND)
add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
- IMPORTED_LINK_INTERFACE_LANGUAGES C
- IMPORTED_LOCATION ${LIBLZMA_LIBRARY})
+ IMPORTED_LINK_INTERFACE_LANGUAGES C)
+
+ if(LIBLZMA_LIBRARY_RELEASE)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}")
+ endif()
+
+ if(LIBLZMA_LIBRARY_DEBUG)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION "${LIBLZMA_LIBRARY}")
+ endif()
endif()
endif ()
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 2b9b20c..2779032 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -310,11 +310,15 @@ foreach (LANG IN ITEMS C CXX Fortran)
set(_MPI_${LANG}_COMPILER_NAMES "")
foreach (id IN ITEMS GNU Intel MSVC PGI XL)
if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id)
- list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX})
+ foreach(_COMPILER_NAME IN LISTS _MPI_${id}_${LANG}_COMPILER_NAMES)
+ list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_COMPILER_NAME}${MPI_EXECUTABLE_SUFFIX})
+ endforeach()
endif()
unset(_MPI_${id}_${LANG}_COMPILER_NAMES)
endforeach()
- list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX})
+ foreach(_COMPILER_NAME IN LISTS _MPI_${LANG}_GENERIC_COMPILER_NAMES)
+ list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_COMPILER_NAME}${MPI_EXECUTABLE_SUFFIX})
+ endforeach()
unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES)
endforeach()
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 3547642..c8cae2e 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -224,6 +224,9 @@ Reference
this list.
#]=======================================================================]
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}")
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
@@ -395,7 +398,7 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio
)
- if(${resultMatlab} EQUAL 0)
+ if(resultMatlab EQUAL 0)
string(
REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)"
@@ -606,15 +609,25 @@ function(matlab_get_mex_suffix matlab_root mex_suffix)
set(devnull INPUT_FILE NUL)
endif()
+ if(WIN32)
+ # this environment variable is used to determine the arch on Windows
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ENV{MATLAB_ARCH} "win64")
+ else()
+ set(ENV{MATLAB_ARCH} "win32")
+ endif()
+ endif()
+
# this is the preferred way. If this does not work properly (eg. MCR on Windows), then we use our own knowledge
execute_process(
COMMAND ${Matlab_MEXEXTENSIONS_PROG}
OUTPUT_VARIABLE _matlab_mex_extension
- #RESULT_VARIABLE _matlab_mex_extension_call
ERROR_VARIABLE _matlab_mex_extension_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
${devnull})
+ unset(ENV{MATLAB_ARCH})
- if(NOT "${_matlab_mex_extension_error}" STREQUAL "")
+ if(_matlab_mex_extension_error)
if(WIN32)
# this is only for intel architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -627,7 +640,7 @@ function(matlab_get_mex_suffix matlab_root mex_suffix)
string(STRIP "${_matlab_mex_extension}" _matlab_mex_extension)
if(MATLAB_FIND_DEBUG)
- message(STATUS "[MATLAB] '${Matlab_MEXEXTENSIONS_PROG}' : returned '${_matlab_mex_extension_call}', determined extension '${_matlab_mex_extension}' and error string is '${_matlab_mex_extension_error}'")
+ message(STATUS "[MATLAB] '${Matlab_MEXEXTENSIONS_PROG}' : determined extension '${_matlab_mex_extension}' and error string is '${_matlab_mex_extension_error}'")
endif()
unset(Matlab_MEXEXTENSIONS_PROG CACHE)
@@ -700,7 +713,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
${devnull}
)
- if("${_matlab_result_version_call}" MATCHES "timeout")
+ if(_matlab_result_version_call MATCHES "timeout")
if(MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Unable to determine the version of Matlab."
" Matlab call timed out after 120 seconds.")
@@ -885,6 +898,7 @@ endfunction()
[DOCUMENTATION file.txt]
[LINK_TO target1 target2 ...]
[R2017b | R2018a]
+ [EXCLUDE_FROM_ALL]
[...]
)
@@ -914,6 +928,10 @@ endfunction()
``MODULE`` or ``SHARED`` may be given to specify the type of library to be
created. ``EXECUTABLE`` may be given to create an executable instead of
a library. If no type is given explicitly, the type is ``SHARED``.
+ ``EXCLUDE_FROM_ALL``
+ This option has the same meaning as for :prop_tgt:`EXCLUDE_FROM_ALL` and
+ is forwarded to :command:`add_library` or :command:`add_executable`
+ commands.
The documentation file is not processed and should be in the following
format:
@@ -940,7 +958,7 @@ function(matlab_add_mex)
endif()
- set(options EXECUTABLE MODULE SHARED R2017b R2018a)
+ set(options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL)
set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
set(multiValueArgs LINK_TO SRC)
@@ -955,14 +973,14 @@ function(matlab_add_mex)
set(${prefix}_OUTPUT_NAME ${${prefix}_NAME})
endif()
- if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file
# TODO: check the file extensions in ${${prefix}_SRC} to see if they're C or C++ files
# Currently, the C and C++ versions of the version files are identical, so this doesn't matter.
set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c")
#set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp")
endif()
- if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro
if(${${prefix}_R2018a})
set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2018a")
else()
@@ -970,8 +988,14 @@ function(matlab_add_mex)
endif()
endif()
+ set(_option_EXCLUDE_FROM_ALL)
+ if(${prefix}_EXCLUDE_FROM_ALL)
+ set(_option_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
+ endif()
+
if(${prefix}_EXECUTABLE)
add_executable(${${prefix}_NAME}
+ ${_option_EXCLUDE_FROM_ALL}
${${prefix}_SRC}
${MEX_VERSION_FILE}
${${prefix}_DOCUMENTATION}
@@ -985,6 +1009,7 @@ function(matlab_add_mex)
add_library(${${prefix}_NAME}
${type}
+ ${_option_EXCLUDE_FROM_ALL}
${${prefix}_SRC}
${MEX_VERSION_FILE}
${${prefix}_DOCUMENTATION}
@@ -1023,18 +1048,13 @@ function(matlab_add_mex)
if (MSVC)
set(_link_flags "${_link_flags} /EXPORT:mexFunction")
- if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
set(_link_flags "${_link_flags} /EXPORT:mexfilerequiredapiversion")
endif()
- if(Matlab_HAS_CPP_API)
- set(_link_flags "${_link_flags} /EXPORT:mexCreateMexFunction /EXPORT:mexDestroyMexFunction /EXPORT:mexFunctionAdapter")
- #TODO: Is this necessary?
- endif()
-
set_property(TARGET ${${prefix}_NAME} APPEND PROPERTY LINK_FLAGS ${_link_flags})
- endif() # TODO: what if there's a different compiler on Windows?
+ endif() # No other compiler currently supported on Windows.
set_target_properties(${${prefix}_NAME}
PROPERTIES
@@ -1042,18 +1062,18 @@ function(matlab_add_mex)
else()
- if(${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For versions prior to 9.1 (R2016b)
+ if(Matlab_VERSION_STRING VERSION_LESS "9.1") # For versions prior to 9.1 (R2016b)
set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/mexFunction.map)
else() # For 9.1 (R2016b) and newer
set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/c_exportsmexfileversion.map)
endif()
- if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.5") # For 9.5 (R2018b) (and newer?)
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.5") # For 9.5 (R2018b) (and newer?)
target_compile_options(${${prefix}_NAME} PRIVATE "-fvisibility=default")
# This one is weird, it might be a bug in <mex.h> for R2018b. When compiling with
# -fvisibility=hidden, the symbol `mexFunction` cannot be exported. Reading the
# source code for <mex.h>, it seems that the preprocessor macro `MW_NEEDS_VERSION_H`
- # needs to be defined for `__attribute__ ((visibility("default")))` to be added
+ # needs to be defined for `__attribute__((visibility("default")))` to be added
# in front of the declaration of `mexFunction`. In previous versions of MATLAB this
# was not the case, there `DLL_EXPORT_SYM` needed to be defined.
# Adding `-fvisibility=hidden` to the `mex` command causes the build to fail.
@@ -1089,11 +1109,13 @@ function(matlab_add_mex)
set(_link_flags "${_link_flags} -Wl,${_export_flag_name},${_file}")
endforeach()
+ # The `mex` command doesn't add this define. It is specified here in order
+ # to export the symbol in case the client code decides to hide its symbols
set_target_properties(${${prefix}_NAME}
PROPERTIES
- DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__ ((visibility (\"default\")))"
+ DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__((visibility(\"default\")))"
LINK_FLAGS "${_link_flags}"
- ) # The `mex` command doesn't add this define. Is it necessary?
+ )
endif()
@@ -1112,14 +1134,14 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
# set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version")
#endif()
- if(NOT ${matlab_known_version} STREQUAL "NOTFOUND")
+ if(NOT matlab_known_version STREQUAL "NOTFOUND")
# the version is known, we just return it
set(${matlab_final_version} ${matlab_known_version} PARENT_SCOPE)
set(Matlab_VERSION_STRING_INTERNAL ${matlab_known_version} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
return()
endif()
- if("${matlab_or_mcr}" STREQUAL "UNKNOWN")
+ if(matlab_or_mcr STREQUAL "UNKNOWN")
if(MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Determining Matlab or MCR")
endif()
@@ -1134,10 +1156,10 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
# default fallback to Matlab
set(matlab_or_mcr "MATLAB")
- if(NOT "${CMAKE_MATCH_1}" STREQUAL "")
+ if(NOT CMAKE_MATCH_1 STREQUAL "")
string(TOLOWER "${CMAKE_MATCH_1}" product_reg_match)
- if("${product_reg_match}" STREQUAL "matlab runtime")
+ if(product_reg_match STREQUAL "matlab runtime")
set(matlab_or_mcr "MCR")
endif()
endif()
@@ -1151,7 +1173,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
# UNKNOWN is the default behaviour in case we
# - have an erroneous matlab_root
# - have an initial 'UNKNOWN'
- if("${matlab_or_mcr}" STREQUAL "MATLAB" OR "${matlab_or_mcr}" STREQUAL "UNKNOWN")
+ if(matlab_or_mcr STREQUAL "MATLAB" OR matlab_or_mcr STREQUAL "UNKNOWN")
# MATLAB versions
set(_matlab_current_program ${Matlab_MAIN_PROGRAM})
@@ -1203,7 +1225,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
- if(${list_of_all_versions_length} GREATER 0)
+ if(list_of_all_versions_length GREATER 0)
list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
else()
set(_matlab_version_tmp "unknown")
@@ -1213,7 +1235,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
# warning, just in case several versions found (should not happen)
- if((${list_of_all_versions_length} GREATER 1) AND MATLAB_FIND_DEBUG)
+ if((list_of_all_versions_length GREATER 1) AND MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})")
endif()
@@ -1233,10 +1255,8 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
${versioninfo_string}
)
- if(NOT "${version_reg_match}" STREQUAL "")
- if("${CMAKE_MATCH_1}" MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*")
- set(_matlab_version_tmp "${CMAKE_MATCH_1}")
- endif()
+ if(CMAKE_MATCH_1 MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*")
+ set(_matlab_version_tmp "${CMAKE_MATCH_1}")
endif()
endif()
set(${matlab_final_version} "${_matlab_version_tmp}" PARENT_SCOPE)
@@ -1442,14 +1462,28 @@ list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
set(Matlab_VERSION_STRING "NOTFOUND")
set(Matlab_Or_MCR "UNKNOWN")
if(_numbers_of_matlab_roots GREATER 0)
- list(GET _matlab_possible_roots 0 Matlab_Or_MCR)
- list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING)
- list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR)
-
- # adding a warning in case of ambiguity
- if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
- " If this is not the desired behaviour, provide the -DMatlab_ROOT_DIR=... on the command line")
+ if(Matlab_FIND_VERSION_EXACT)
+ list(FIND _matlab_possible_roots ${Matlab_FIND_VERSION} _list_index)
+ if(_list_index LESS 0)
+ set(_list_index 1)
+ endif()
+
+ math(EXPR _matlab_or_mcr_index "${_list_index} - 1")
+ math(EXPR _matlab_root_dir_index "${_list_index} + 1")
+
+ list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR)
+ list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR)
+ else()
+ list(GET _matlab_possible_roots 0 Matlab_Or_MCR)
+ list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR)
+
+ # adding a warning in case of ambiguity
+ if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
+ " If this is not the desired behaviour, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line")
+ endif()
endif()
endif()
@@ -1503,7 +1537,9 @@ if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}")
endif()
-if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # MATLAB 9.4 (R2018a) and newer have a new C++ API
+# MATLAB 9.4 (R2018a) and newer have a new C++ API
+# This API pulls additional required libraries.
+if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4")
set(Matlab_HAS_CPP_API 1)
endif()
@@ -1589,6 +1625,10 @@ endfunction()
set(_matlab_required_variables)
+# Order is as follow:
+# - unconditionally required libraries/headers first
+# - then library components
+# - then program components
# the MEX library/header are required
find_path(
@@ -1614,38 +1654,6 @@ list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION)
# the matlab root is required
list(APPEND _matlab_required_variables Matlab_ROOT_DIR)
-# component Mex Compiler
-list(FIND Matlab_FIND_COMPONENTS MEX_COMPILER _matlab_find_mex_compiler)
-if(_matlab_find_mex_compiler GREATER -1)
- find_program(
- Matlab_MEX_COMPILER
- "mex"
- PATHS ${Matlab_BINARIES_DIR}
- DOC "Matlab MEX compiler"
- NO_DEFAULT_PATH
- )
- if(Matlab_MEX_COMPILER)
- set(Matlab_MEX_COMPILER_FOUND TRUE)
- endif()
-endif()
-unset(_matlab_find_mex_compiler)
-
-# component Matlab program
-list(FIND Matlab_FIND_COMPONENTS MAIN_PROGRAM _matlab_find_matlab_program)
-if(_matlab_find_matlab_program GREATER -1)
- find_program(
- Matlab_MAIN_PROGRAM
- matlab
- PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
- DOC "Matlab main program"
- NO_DEFAULT_PATH
- )
- if(Matlab_MAIN_PROGRAM)
- set(Matlab_MAIN_PROGRAM_FOUND TRUE)
- endif()
-endif()
-unset(_matlab_find_matlab_program)
-
# The MX library is required
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
@@ -1659,9 +1667,40 @@ if(Matlab_MX_LIBRARY)
set(Matlab_MX_LIBRARY_FOUND TRUE)
endif()
+if(Matlab_HAS_CPP_API)
+
+ # The MatlabEngine library is required for R2018a+
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_ENGINE_LIBRARY
+ MatlabEngine
+ PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabEngine Library"
+ NO_DEFAULT_PATH
+ )
+ list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
+ if(Matlab_ENGINE_LIBRARY)
+ set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
+ endif()
+
+ # The MatlabDataArray library is required for R2018a+
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_DATAARRAY_LIBRARY
+ MatlabDataArray
+ PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabDataArray Library"
+ NO_DEFAULT_PATH
+ )
+ list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
+ if(Matlab_DATAARRAY_LIBRARY)
+ set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
+ endif()
+
+endif()
+
# Component ENG library
-list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
-if(_matlab_find_eng GREATER -1)
+if("ENG_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_ENG_LIBRARY
@@ -1673,11 +1712,9 @@ if(_matlab_find_eng GREATER -1)
set(Matlab_ENG_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_eng)
# Component MAT library
-list(FIND Matlab_FIND_COMPONENTS MAT_LIBRARY _matlab_find_mat)
-if(_matlab_find_mat GREATER -1)
+if("MAT_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_MAT_LIBRARY
@@ -1689,11 +1726,9 @@ if(_matlab_find_mat GREATER -1)
set(Matlab_MAT_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_mat)
# Component Simulink
-list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink)
-if(_matlab_find_simulink GREATER -1)
+if("SIMULINK" IN_LIST Matlab_FIND_COMPONENTS)
find_path(
Matlab_SIMULINK_INCLUDE_DIR
simstruc.h
@@ -1705,58 +1740,49 @@ if(_matlab_find_simulink GREATER -1)
list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}")
endif()
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)
+# component Matlab program
+if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS)
find_program(
- Matlab_MCC_COMPILER
- "mcc"
- PATHS ${Matlab_BINARIES_DIR}
- DOC "Matlab MCC compiler"
+ Matlab_MAIN_PROGRAM
+ matlab
+ PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
+ DOC "Matlab main program"
NO_DEFAULT_PATH
)
- if(Matlab_MCC_COMPILER)
- set(Matlab_MCC_COMPILER_FOUND TRUE)
+ if(Matlab_MAIN_PROGRAM)
+ set(Matlab_MAIN_PROGRAM_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_mcc_compiler)
-
-if(Matlab_HAS_CPP_API)
- # The MatlabEngine library is required for R2018a+
- _Matlab_find_library(
- ${_matlab_lib_prefix_for_search}
- Matlab_ENGINE_LIBRARY
- MatlabEngine
- PATHS ${_matlab_lib_dir_for_search}
- DOC "MatlabEngine Library"
+# component Mex Compiler
+if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MEX_COMPILER
+ "mex"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MEX compiler"
NO_DEFAULT_PATH
)
- list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
- if(Matlab_ENGINE_LIBRARY)
- set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
+ if(Matlab_MEX_COMPILER)
+ set(Matlab_MEX_COMPILER_FOUND TRUE)
endif()
+endif()
- # The MatlabDataArray library is required for R2018a+
- _Matlab_find_library(
- ${_matlab_lib_prefix_for_search}
- Matlab_DATAARRAY_LIBRARY
- MatlabDataArray
- PATHS ${_matlab_lib_dir_for_search}
- DOC "MatlabDataArray Library"
+# component MCC Compiler
+if("MCC_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MCC_COMPILER
+ "mcc"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MCC compiler"
NO_DEFAULT_PATH
)
- list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
- if(Matlab_DATAARRAY_LIBRARY)
- set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
+ if(Matlab_MCC_COMPILER)
+ set(Matlab_MCC_COMPILER_FOUND TRUE)
endif()
-
endif()
-unset(_matlab_lib_dir_for_search)
-
set(Matlab_LIBRARIES
${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY}
${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}
@@ -1792,3 +1818,5 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
Matlab_MEX_EXTENSION
)
endif()
+
+cmake_policy(POP)
diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake
index dc8321d..743e0e2 100644
--- a/Modules/FindOpenACC.cmake
+++ b/Modules/FindOpenACC.cmake
@@ -22,6 +22,14 @@ project, where ``<lang>`` is one of C, CXX, or Fortran:
Variable indicating if OpenACC support for ``<lang>`` was detected.
``OpenACC_<lang>_FLAGS``
OpenACC compiler flags for ``<lang>``, separated by spaces.
+``OpenACC_<lang>_OPTIONS``
+ OpenACC compiler flags for ``<lang>``, as a list. Suitable for usage
+ with target_compile_options or target_link_options.
+
+Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+
+``OpenACC::OpenACC_<lang>``
+ Target for using OpenACC from ``<lang>``.
The module will also try to provide the OpenACC version variables:
@@ -60,9 +68,7 @@ int main(){
set(OpenACC_Fortran_TEST_SOURCE
"
program test
-#ifdef _OPENACC
- return 0;
-#else
+#ifndef _OPENACC
breaks_on_purpose
#endif
endprogram test
@@ -241,6 +247,9 @@ foreach (LANG IN ITEMS C CXX Fortran)
if(NOT DEFINED OpenACC_${LANG}_FLAGS)
_OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS)
endif()
+ if(NOT DEFINED OpenACC_${LANG}_OPTIONS)
+ separate_arguments(OpenACC_${LANG}_OPTIONS NATIVE_COMMAND "${OpenACC_${LANG}_FLAGS}")
+ endif()
_OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE)
_OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}")
@@ -251,6 +260,23 @@ foreach (LANG IN ITEMS C CXX Fortran)
endif()
endforeach()
+foreach (LANG IN ITEMS C CXX Fortran)
+ if(OpenACC_${LANG}_FOUND AND NOT TARGET OpenACC::OpenACC_${LANG})
+ add_library(OpenACC::OpenACC_${LANG} INTERFACE IMPORTED)
+ endif()
+ if(OpenACC_${LANG}_LIBRARIES)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${OpenACC_${LANG}_LIBRARIES}")
+ endif()
+ if(OpenACC_${LANG}_FLAGS)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ unset(_OpenACC_${LANG}_OPTIONS)
+ endif()
+endforeach()
+
unset(OpenACC_C_CXX_TEST_SOURCE)
unset(OpenACC_Fortran_TEST_SOURCE)
unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE)
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index a7908c5..bd400c7 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -69,8 +69,8 @@ if(ZLIB_FOUND)
unset(_PNG_VERSION_SUFFIX_MIN)
endif ()
foreach(v IN LISTS _PNG_VERSION_SUFFIXES)
- list(APPEND PNG_NAMES png${v} libpng${v})
- list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d)
+ list(APPEND PNG_NAMES png${v} libpng${v} libpng${v}_static)
+ list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d libpng${v}_staticd)
endforeach()
unset(_PNG_VERSION_SUFFIXES)
# For compatibility with versions prior to this multi-config search, honor
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
index 1722d6a..a2999fc 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -264,14 +264,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
if(${_NAME}_${comp}_FOUND)
if(NOT DEFINED FOUND_COMPONENTS_MSG)
- set(FOUND_COMPONENTS_MSG "found components: ")
+ set(FOUND_COMPONENTS_MSG "found components:")
endif()
string(APPEND FOUND_COMPONENTS_MSG " ${comp}")
else()
if(NOT DEFINED MISSING_COMPONENTS_MSG)
- set(MISSING_COMPONENTS_MSG "missing components: ")
+ set(MISSING_COMPONENTS_MSG "missing components:")
endif()
string(APPEND MISSING_COMPONENTS_MSG " ${comp}")
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index e05d5c8..4c9af91 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -363,6 +363,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
_pkgconfig_unset(${_prefix}_PREFIX)
_pkgconfig_unset(${_prefix}_INCLUDEDIR)
_pkgconfig_unset(${_prefix}_LIBDIR)
+ _pkgconfig_unset(${_prefix}_MODULE_NAME)
_pkgconfig_unset(${_prefix}_LIBS)
_pkgconfig_unset(${_prefix}_LIBS_L)
_pkgconfig_unset(${_prefix}_LIBS_PATHS)
@@ -480,6 +481,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR)
_pkgconfig_set("${_pkg_check_prefix}_${variable}" "${${_pkg_check_prefix}_${variable}}")
endforeach ()
+ _pkgconfig_set("${_pkg_check_prefix}_MODULE_NAME" "${_pkg_check_modules_pkg}")
if (NOT ${_is_silent})
message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
@@ -664,6 +666,10 @@ endmacro()
[IMPORTED_TARGET [GLOBAL]]
<moduleSpec> [<moduleSpec>...])
+ If a module is found, the ``<prefix>_MODULE_NAME`` variable will contain the
+ name of the matching module. This variable can be used if you need to run
+ :command:`pkg_get_variable`.
+
Example:
.. code-block:: cmake
@@ -688,6 +694,7 @@ macro(pkg_search_module _prefix _module0)
if (${_prefix}_FOUND)
set(_pkg_modules_found 1)
+ break()
endif()
endforeach()
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 76bc873..2d45965 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -521,6 +521,16 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotobuf PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_LIBRARY_DEBUG}")
endif()
+ if (Protobuf_VERSION VERSION_GREATER_EQUAL "3.6")
+ set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
+ INTERFACE_COMPILE_FEATURES cxx_std_11
+ )
+ endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
@@ -549,6 +559,11 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_LITE_LIBRARY_DEBUG}")
endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
@@ -577,6 +592,16 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotoc PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_PROTOC_LIBRARY_DEBUG}")
endif()
+ if (Protobuf_VERSION VERSION_GREATER_EQUAL "3.6")
+ set_property(TARGET protobuf::libprotoc APPEND PROPERTY
+ INTERFACE_COMPILE_FEATURES cxx_std_11
+ )
+ endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotoc APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotoc APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index e2f3bf3..3cc08a1 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -137,6 +137,51 @@ Hints
* If set to TRUE, search **only** for static libraries.
* If set to FALSE, search **only** for shared libraries.
+``Python_FIND_ABI``
+ This variable defines which ABIs, as defined in
+ `PEP 3149 <https://www.python.org/dev/peps/pep-3149/>`_, should be searched.
+
+ .. note::
+
+ This hint will be honored only when searched for ``Python`` version 3.
+
+ .. note::
+
+ If ``Python_FIND_ABI`` is not defined, any ABI will be searched.
+
+ The ``Python_FIND_ABI`` variable is a 3-tuple specifying, in that order,
+ ``pydebug`` (``d``), ``pymalloc`` (``m``) and ``unicode`` (``u``) flags.
+ Each element can be set to one of the following:
+
+ * ``ON``: Corresponding flag is selected.
+ * ``OFF``: Corresponding flag is not selected.
+ * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched.
+
+ From this 3-tuple, various ABIs will be searched starting from the most
+ specialized to the most general. Moreover, ``debug`` versions will be
+ searched **after** ``non-debug`` ones.
+
+ For example, if we have::
+
+ set (Python_FIND_ABI "ON" "ANY" "ANY")
+
+ The following flags combinations will be appended, in that order, to the
+ artifact names: ``dmu``, ``dm``, ``du``, and ``d``.
+
+ And to search any possible ABIs::
+
+ set (Python_FIND_ABI "ANY" "ANY" "ANY")
+
+ The following combinations, in that order, will be used: ``mu``, ``m``,
+ ``u``, ``<empty>``, ``dmu``, ``dm``, ``du`` and ``d``.
+
+ .. note::
+
+ This hint is useful only on ``POSIX`` systems. So, on ``Windows`` systems,
+ when ``Python_FIND_ABI`` is defined, ``Python`` distributions from
+ `python.org <https://www.python.org/>`_ will be found only if value for
+ each flag is ``OFF`` or ``ANY``.
+
``Python_FIND_STRATEGY``
This variable defines how lookup will be done.
The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the
@@ -192,6 +237,50 @@ Hints
``NEVER`` to select preferably the interpreter from the virtual
environment.
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python_EXECUTABLE``
+ The path to the interpreter.
+
+``Python_COMPILER``
+ The path to the compiler.
+
+``Python_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python_LIBRARIES``, ``Python_LIBRAY_DIRS`` and
+ ``Python_RUNTIME_LIBRARY_DIRS``.
+
+``Python_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python_INCLUDE_DIRS``.
+
+``Python_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
Commands
^^^^^^^^
@@ -224,6 +313,14 @@ else()
set (_Python_REQUIRED_VERSIONS 3 2)
set (_Python_REQUIRED_VERSION_LAST 2)
+ unset (_Python_INPUT_VARS)
+ foreach (_Python_ITEM IN ITEMS Python_EXECUTABLE Python_COMPILER Python_LIBRARY
+ Python_INCLUDE_DIR Python_NumPy_INCLUDE_DIR)
+ if (NOT DEFINED ${_Python_ITEM})
+ list (APPEND _Python_INPUT_VARS ${_Python_ITEM})
+ endif()
+ endforeach()
+
foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS)
set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR})
include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
@@ -231,6 +328,10 @@ else()
_Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST)
break()
endif()
+ # clean-up INPUT variables not set by the user
+ foreach (_Python_ITEM IN LISTS _Python_INPUT_VARS)
+ unset (${_Python_ITEM})
+ endforeach()
# clean-up some CACHE variables to ensure look-up restart from scratch
foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS)
unset (${_Python_ITEM} CACHE)
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 590c7af..b67d563 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -96,71 +96,347 @@ function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS _PYTHON_VERSION)
PARENT_SCOPE)
endfunction()
-function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES _PYTHON_VERSION _PYTHON_TYPE)
- set (path_suffixes)
- if (_PYTHON_TYPE STREQUAL "LIBRARY")
+function (_PYTHON_GET_ABIFLAGS _PGABIFLAGS)
+ set (abiflags)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 0 pydebug)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 1 pymalloc)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 2 unicode)
+
+ if (pymalloc STREQUAL "ANY" AND unicode STREQUAL "ANY")
+ set (abiflags "mu" "m" "u" "")
+ elseif (pymalloc STREQUAL "ANY" AND unicode STREQUAL "ON")
+ set (abiflags "mu" "u")
+ elseif (pymalloc STREQUAL "ANY" AND unicode STREQUAL "OFF")
+ set (abiflags "m" "")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ANY")
+ set (abiflags "mu" "m")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ON")
+ set (abiflags "mu")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "OFF")
+ set (abiflags "m")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ANY")
+ set (abiflags "u" "")
+ elseif (pymalloc STREQUAL "OFF" AND unicode STREQUAL "ON")
+ set (abiflags "u")
+ endif()
+
+ if (pydebug STREQUAL "ON")
+ if (abiflags)
+ list (TRANSFORM abiflags PREPEND "d")
+ else()
+ set (abiflags "d")
+ endif()
+ elseif (pydebug STREQUAL "ANY")
+ if (abiflags)
+ set (flags "${abiflags}")
+ list (TRANSFORM flags PREPEND "d")
+ list (APPEND abiflags "${flags}")
+ else()
+ set (abiflags "" "d")
+ endif()
+ endif()
+
+ set (${_PGABIFLAGS} "${abiflags}" PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES)
+ cmake_parse_arguments (PARSE_ARGV 1 _PGPS "LIBRARY;INCLUDE" "VERSION" "")
+
+ if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS)
+ set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}")
+ else()
+ set (abi "mu" "m" "u" "")
+ endif()
+
+ set (path_suffixes)
+ if (_PGPS_LIBRARY)
if (CMAKE_LIBRARY_ARCHITECTURE)
list (APPEND path_suffixes lib/${CMAKE_LIBRARY_ARCHITECTURE})
endif()
list (APPEND path_suffixes lib libs)
if (CMAKE_LIBRARY_ARCHITECTURE)
- list (APPEND path_suffixes lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}mu-${CMAKE_LIBRARY_ARCHITECTURE}
- lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}m-${CMAKE_LIBRARY_ARCHITECTURE}
- lib/python${_PYTHON_VERSION}/config-${CMAKE_MATCH_1}u-${CMAKE_LIBRARY_ARCHITECTURE}
- lib/python${_PYTHON_VERSION}/config-${CMAKE_MATCH_1}-${CMAKE_LIBRARY_ARCHITECTURE})
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ list (TRANSFORM suffixes APPEND "-${CMAKE_LIBRARY_ARCHITECTURE}")
+ else()
+ set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}-${CMAKE_LIBRARY_ARCHITECTURE}")
+ endif()
+ list (APPEND path_suffixes ${suffixes})
endif()
- list (APPEND path_suffixes lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}mu
- lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}m
- lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}u
- lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}
- lib/python${_PYTHON_VERSION}/config)
-
- elseif (_PYTHON_TYPE STREQUAL "INCLUDE")
- list (APPEND path_suffixes include/python${_PYTHON_VERSION}mu
- include/python${_PYTHON_VERSION}m
- include/python${_PYTHON_VERSION}u
- include/python${_PYTHON_VERSION}
- include)
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ else()
+ set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ endif()
+ list (APPEND path_suffixes ${suffixes})
+ elseif (_PGPS_INCLUDE)
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "include/python${_PGPS_VERSION}")
+ else()
+ set (suffixes "include/python${_PGPS_VERSION}")
+ endif()
+ list (APPEND path_suffixes ${suffixes} include)
endif()
set (${_PYTHON_PGPS_PATH_SUFFIXES} ${path_suffixes} PARENT_SCOPE)
endfunction()
-function (_PYTHON_GET_LIB_NAMES _PYTHON_PGLN_NAMES _PYTHON_VERSION)
- string (REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PYTHON_VERSION})
+function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES)
+ cmake_parse_arguments (PARSE_ARGV 1 _PGN "POSIX;EXECUTABLE;CONFIG;LIBRARY;WIN32;DEBUG" "VERSION" "")
+
+ set (names)
+
+ if (_PGN_WIN32)
+ string (REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PGN_VERSION})
+
+ set (name python${_PYTHON_VERSION_NO_DOTS})
+ if (_PGN_DEBUG)
+ string (APPEND name "_d")
+ endif()
+
+ list (APPEND names "${name}")
+ endif()
+
+ if (_PGN_POSIX)
+ if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS)
+ set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}")
+ else()
+ if (_PGN_EXECUTABLE OR _PGN_CONFIG)
+ set (abi "")
+ else()
+ set (abi "mu" "m" "u" "")
+ endif()
+ endif()
+
+ if (abi)
+ if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ set (abinames "${abi}")
+ list (TRANSFORM abinames PREPEND "${CMAKE_LIBRARY_ARCHITECTURE}-python${_PGN_VERSION}")
+ list (TRANSFORM abinames APPEND "-config")
+ list (APPEND names ${abinames})
+ endif()
+ set (abinames "${abi}")
+ list (TRANSFORM abinames PREPEND "python${_PGN_VERSION}")
+ if (_PGN_CONFIG)
+ list (TRANSFORM abinames APPEND "-config")
+ endif()
+ list (APPEND names ${abinames})
+ else()
+ if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ set (abinames "${CMAKE_LIBRARY_ARCHITECTURE}-python${_PGN_VERSION}")
+ endif()
+ list (APPEND abinames "python${_PGN_VERSION}")
+ if (_PGN_CONFIG)
+ list (TRANSFORM abinames APPEND "-config")
+ endif()
+ list (APPEND names ${abinames})
+ endif()
+ endif()
+
+ set (${_PYTHON_PGN_NAMES} ${names} PARENT_SCOPE)
+endfunction()
- if (ARGC EQUAL 3 AND ARGV2 STREQUAL "DEBUG")
- set (${_PYTHON_PGLN_NAMES} python${_PYTHON_VERSION_NO_DOTS}_d PARENT_SCOPE)
+function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
+ unset (${_PYTHON_PGCV_VALUE} PARENT_SCOPE)
+
+ if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS)$")
+ return()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ set (config_flag "--${NAME}")
+ string (TOLOWER "${config_flag}" config_flag)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" ${config_flag}
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ else()
+ if (NAME STREQUAL "INCLUDES")
+ # do some clean-up
+ string (REGEX MATCHALL "(-I|-iwithsysroot)[ ]*[^ ]+" _values "${_values}")
+ string (REGEX REPLACE "(-I|-iwithsysroot)[ ]*" "" _values "${_values}")
+ list (REMOVE_DUPLICATES _values)
+ endif()
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING)
+ if (NAME STREQUAL "PREFIX")
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.PREFIX,sysconfig.EXEC_PREFIX,sysconfig.BASE_EXEC_PREFIX]))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ else()
+ list (REMOVE_DUPLICATES _values)
+ endif()
+ elseif (NAME STREQUAL "INCLUDES")
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.get_python_inc(plat_specific=True),sysconfig.get_python_inc(plat_specific=False)]))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ endif()
+ else()
+ set (config_flag "${NAME}")
+ if (NAME STREQUAL "CONFIGDIR")
+ set (config_flag "LIBPL")
+ endif()
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_config_var('${config_flag}'))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ endif()
+ endif()
+ endif()
+
+ if (config_flag STREQUAL "ABIFLAGS")
+ set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE)
+ return()
+ endif()
+
+ if (NOT _values OR _values STREQUAL "None")
+ return()
+ endif()
+
+ if (NAME STREQUAL "LIBS")
+ # do some clean-up
+ string (REGEX MATCHALL "-(l|framework)[ ]*[^ ]+" _values "${_values}")
+ # remove elements relative to python library itself
+ list (FILTER _values EXCLUDE REGEX "-lpython")
+ list (REMOVE_DUPLICATES _values)
+ endif()
+
+ set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_VERSION)
+ cmake_parse_arguments (PARSE_ARGV 0 _PGV "LIBRARY;INCLUDE" "PREFIX" "")
+
+ unset (${_PGV_PREFIX}VERSION PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_MAJOR PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_MINOR PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_PATCH PARENT_SCOPE)
+ unset (${_PGV_PREFIX}ABI PARENT_SCOPE)
+
+ if (_PGV_LIBRARY)
+ # retrieve version and abi from library name
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ # extract version from library name
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)")
+ set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}ABI "" PARENT_SCOPE)
+ elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)")
+ set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}ABI "${CMAKE_MATCH_3}" PARENT_SCOPE)
+ endif()
+ endif()
else()
- set (${_PYTHON_PGLN_NAMES} python${_PYTHON_VERSION_NO_DOTS}
- python${_PYTHON_VERSION}mu
- python${_PYTHON_VERSION}m
- python${_PYTHON_VERSION}u
- python${_PYTHON_VERSION}
- PARENT_SCOPE)
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # retrieve version from header file
+ file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" version
+ REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
+ string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
+ version "${version}")
+ string (REGEX MATCHALL "[0-9]+" versions "${version}")
+ list (GET versions 0 version_major)
+ list (GET versions 1 version_minor)
+ list (GET versions 2 version_patch)
+
+ set (${_PGV_PREFIX}VERSION "${version_major}.${version_minor}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MAJOR ${version_major} PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR ${version_minor} PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_PATCH ${version_patch} PARENT_SCOPE)
+
+ # compute ABI flags
+ if (version_major VERSION_GREATER 2)
+ file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)")
+ set (abi)
+ if (config MATCHES "#[ ]*define[ ]+MS_WIN32")
+ # ABI not used on Windows
+ set (abi "")
+ else()
+ if (config MATCHES "#[ ]*define[ ]+Py_DEBUG[ ]+1")
+ string (APPEND abi "d")
+ endif()
+ if (config MATCHES "#[ ]*define[ ]+WITH_PYMALLOC[ ]+1")
+ string (APPEND abi "m")
+ endif()
+ if (config MATCHES "#[ ]*define[ ]+Py_UNICODE_SIZE[ ]+4")
+ string (APPEND abi "u")
+ endif()
+ set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE)
+ endif()
+ else()
+ # ABI not supported
+ set (${_PGV_PREFIX}ABI "" PARENT_SCOPE)
+ endif()
+ endif()
endif()
endfunction()
function (_PYTHON_VALIDATE_INTERPRETER)
- if (NOT ${_PYTHON_PREFIX}_EXECUTABLE)
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
return()
endif()
- cmake_parse_arguments (_PVI "EXACT" "" "" ${ARGN})
+ cmake_parse_arguments (PARSE_ARGV 0 _PVI "EXACT;CHECK_EXISTS" "" "")
if (_PVI_UNPARSED_ARGUMENTS)
set (expected_version ${_PVI_UNPARSED_ARGUMENTS})
else()
unset (expected_version)
endif()
- get_filename_component (python_name "${${_PYTHON_PREFIX}_EXECUTABLE}" NAME)
+ if (_PVI_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ # interpreter does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+
+ # validate ABI compatibility
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE abi
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (result)
+ # assume ABI is not supported
+ set (abi "")
+ endif()
+ if (NOT abi IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+ endif()
+
+ get_filename_component (python_name "${_${_PYTHON_PREFIX}_EXECUTABLE}" NAME)
- if (expected_version AND NOT python_name STREQUAL "python${expected_version}${CMAKE_EXECUTABLE_SUFFIX}")
+ if (expected_version AND NOT python_name STREQUAL "python${expected_version}${abi}${CMAKE_EXECUTABLE_SUFFIX}")
# executable found must have a specific version
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
"import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))"
RESULT_VARIABLE result
OUTPUT_VARIABLE version
@@ -168,14 +444,14 @@ function (_PYTHON_VALIDATE_INTERPRETER)
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (result OR (_PVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version))
# interpreter not usable or has wrong major version
- set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE)
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
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
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
"import sys; sys.stdout.write(str(sys.version_info[0]))"
RESULT_VARIABLE result
OUTPUT_VARIABLE version
@@ -183,7 +459,7 @@ function (_PYTHON_VALIDATE_INTERPRETER)
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)
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
return()
endif()
endif()
@@ -192,7 +468,7 @@ function (_PYTHON_VALIDATE_INTERPRETER)
if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
AND NOT CMAKE_CROSSCOMPILING)
# In this case, interpreter must have same architecture as environment
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
"import sys, struct; sys.stdout.write(str(struct.calcsize(\"P\")))"
RESULT_VARIABLE result
OUTPUT_VARIABLE size
@@ -200,7 +476,7 @@ function (_PYTHON_VALIDATE_INTERPRETER)
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (result OR NOT size EQUAL CMAKE_SIZEOF_VOID_P)
# interpreter not usable or has wrong architecture
- set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE)
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
return()
endif()
endif()
@@ -208,11 +484,11 @@ endfunction()
function (_PYTHON_VALIDATE_COMPILER expected_version)
- if (NOT ${_PYTHON_PREFIX}_COMPILER)
+ if (NOT _${_PYTHON_PREFIX}_COMPILER)
return()
endif()
- cmake_parse_arguments (_PVC "EXACT" "" "" ${ARGN})
+ cmake_parse_arguments (_PVC "EXACT;CHECK_EXISTS" "" "" ${ARGN})
if (_PVC_UNPARSED_ARGUMENTS)
set (major_version FALSE)
set (expected_version ${_PVC_UNPARSED_ARGUMENTS})
@@ -222,6 +498,12 @@ function (_PYTHON_VALIDATE_COMPILER expected_version)
set (_PVC_EXACT TRUE)
endif()
+ if (_PVC_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_COMPILER}")
+ # Compiler does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND")
+ return()
+ endif()
+
# retrieve python environment version from compiler
set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
if (major_version)
@@ -230,7 +512,7 @@ function (_PYTHON_VALIDATE_COMPILER expected_version)
else()
file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))\n")
endif()
- execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py"
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py"
WORKING_DIRECTORY "${working_dir}"
OUTPUT_QUIET
ERROR_QUIET
@@ -244,7 +526,98 @@ function (_PYTHON_VALIDATE_COMPILER expected_version)
if (result OR (_PVC_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version))
# Compiler not usable or has wrong version
- set (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE)
+ set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND")
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_LIBRARY)
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ return()
+ endif()
+
+ cmake_parse_arguments (PARSE_ARGV 0 _PVL "EXACT;CHECK_EXISTS" "" "")
+ if (_PVL_UNPARSED_ARGUMENTS)
+ set (expected_version ${_PVL_UNPARSED_ARGUMENTS})
+ else()
+ unset (expected_version)
+ endif()
+
+ if (_PVL_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+ # library does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ if (WIN32)
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND")
+ endif()
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ return()
+ endif()
+
+ # retrieve version and abi from library name
+ _python_get_version (LIBRARY PREFIX lib_)
+
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT lib_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ else()
+ if (expected_version)
+ if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL expected_version) OR (lib_VERSION VERSION_LESS expected_version))
+ # library has wrong version
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+ else()
+ if (NOT lib_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ # library has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ if (WIN32)
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND")
+ endif()
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_INCLUDE_DIR)
+ if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ return()
+ endif()
+
+ cmake_parse_arguments (PARSE_ARGV 0 _PVID "EXACT;CHECK_EXISTS" "" "")
+ if (_PVID_UNPARSED_ARGUMENTS)
+ set (expected_version ${_PVID_UNPARSED_ARGUMENTS})
+ else()
+ unset (expected_version)
+ endif()
+
+ if (_PVID_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ # include file does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ return()
+ endif()
+
+ # retrieve version from header file
+ _python_get_version (INCLUDE PREFIX inc_)
+
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT inc_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ else()
+ if (expected_version)
+ if ((_PVID_EXACT AND NOT inc_VERSION VERSION_EQUAL expected_version) OR (inc_VERSION VERSION_LESS expected_version))
+ # include dir has wrong version
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+ else()
+ if (NOT inc_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ # include dir has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+ endif()
endif()
endfunction()
@@ -267,8 +640,7 @@ endfunction()
function (_PYTHON_SET_LIBRARY_DIRS _PYTHON_SLD_RESULT)
unset (_PYTHON_DIRS)
- set (_PYTHON_LIBS ${ARGV})
- list (REMOVE_AT _PYTHON_LIBS 0)
+ set (_PYTHON_LIBS ${ARGN})
foreach (_PYTHON_LIB IN LISTS _PYTHON_LIBS)
if (${_PYTHON_LIB})
get_filename_component (_PYTHON_DIR "${${_PYTHON_LIB}}" DIRECTORY)
@@ -298,7 +670,7 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development")
list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
-foreach (_${_PYTHON_PREFIX}_COMPONENT IN LISTS ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development NumPy)
set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE)
endforeach()
unset (_${_PYTHON_PREFIX}_FIND_VERSIONS)
@@ -321,6 +693,28 @@ if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1)
endif()
endif()
+# Set ABIs to search
+## default: search any ABI
+if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS 3)
+ # ABI not supported
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ set (_${_PYTHON_PREFIX}_ABIFLAGS "")
+else()
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ unset (_${_PYTHON_PREFIX}_ABIFLAGS)
+ if (DEFINED ${_PYTHON_PREFIX}_FIND_ABI)
+ # normalization
+ string (TOUPPER "${${_PYTHON_PREFIX}_FIND_ABI}" _${_PYTHON_PREFIX}_FIND_ABI)
+ list (TRANSFORM _${_PYTHON_PREFIX}_FIND_ABI REPLACE "^(TRUE|Y(ES)?|1)$" "ON")
+ list (TRANSFORM _${_PYTHON_PREFIX}_FIND_ABI REPLACE "^(FALSE|N(O)?|0)$" "OFF")
+ if (NOT _${_PYTHON_PREFIX}_FIND_ABI MATCHES "^(ON|OFF|ANY);(ON|OFF|ANY);(ON|OFF|ANY)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_ABI}: invalid value for '${_PYTHON_PREFIX}_FIND_ABI'. Ignore it")
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ endif()
+ _python_get_abiflags (_${_PYTHON_PREFIX}_ABIFLAGS)
+ endif()
+endif()
+
# Define lookup strategy
if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW")
set (_${_PYTHON_PREFIX}_FIND_STRATEGY "LOCATION")
@@ -426,311 +820,374 @@ else()
endif()
+# Compute search signature
+# This signature will be used to check validity of cached variables on new search
+set (_${_PYTHON_PREFIX}_SIGNATURE "${${_PYTHON_PREFIX}_ROOT_DIR}:${${_PYTHON_PREFIX}_FIND_STRATEGY}:${${_PYTHON_PREFIX}_FIND_VIRTUALENV}")
+if (NOT WIN32)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_USE_STATIC_LIBS}:")
+endif()
+if (CMAKE_HOST_APPLE)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_FRAMEWORK}")
+endif()
+if (CMAKE_HOST_WIN32)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_REGISTRY}")
+endif()
+
+
unset (_${_PYTHON_PREFIX}_REQUIRED_VARS)
unset (_${_PYTHON_PREFIX}_CACHED_VARS)
# first step, search for the interpreter
if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
- list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_EXECUTABLE)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_EXECUTABLE)
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter)
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE)
endif()
- set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+ if (DEFINED ${_PYTHON_PREFIX}_EXECUTABLE
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_EXECUTABLE}")
+ set (_${_PYTHON_PREFIX}_EXECUTABLE "${${_PYTHON_PREFIX}_EXECUTABLE}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_EXECUTABLE)
+ # compute interpreter signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ if (__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_EXECUTABLE CACHE)
+ unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE)
+ endif()
+ endif()
- if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
- unset (_${_PYTHON_PREFIX}_NAMES)
- unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
- unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
- foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- # build all executable names
- list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_VERSION})
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ unset (_${_PYTHON_PREFIX}_NAMES)
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
- # Framework Paths
- _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
- list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # build all executable names
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE)
+ list (APPEND _${_PYTHON_PREFIX}_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
- # Registry Paths
- _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
- list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}
- [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
- endforeach()
- list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
- while (TRUE)
- # Virtual environments handling
- if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ENV VIRTUAL_ENV
- PATH_SUFFIXES bin Scripts
- NO_CMAKE_PATH
- NO_CMAKE_ENVIRONMENT_PATH
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
+ # Registry Paths
+ _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
+ endforeach()
+ list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
- _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
+ while (TRUE)
+ # Virtual environments handling
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ENV VIRTUAL_ENV
+ PATH_SUFFIXES bin Scripts
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ break()
+ endif()
endif()
- if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
- break()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endif()
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
endif()
- endif()
- # Apple frameworks handling
- if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
+ # try using HINTS
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
- PATH_SUFFIXES bin
- NO_CMAKE_PATH
- NO_CMAKE_ENVIRONMENT_PATH
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
_python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
break()
endif()
- endif()
- # Windows registry
- if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
+ # try using standard paths
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
NAMES ${_${_PYTHON_PREFIX}_NAMES}
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
_python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
break()
endif()
- endif()
- # try using HINTS and standard paths
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
- _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
- endif()
-
- # Apple frameworks handling
- if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- NAMES_PER_DIR
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
- PATH_SUFFIXES bin
- NO_DEFAULT_PATH)
- _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
endif()
- endif()
- # Windows registry
- if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
- NAMES_PER_DIR
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_DEFAULT_PATH)
- _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
endif()
- endif()
- break()
- endwhile()
- else()
- # look-up for various versions and locations
- foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- set (_${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_VERSION}
- python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
- python)
+ break()
+ endwhile()
+ else()
+ # look-up for various versions and locations
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE)
+ list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+ python)
+
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+
+ # Virtual environments handling
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ENV VIRTUAL_ENV
+ PATH_SUFFIXES bin Scripts
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ continue()
+ endif()
+ endif()
- _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
- _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
- # Virtual environments handling
- if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ENV VIRTUAL_ENV
- PATH_SUFFIXES bin Scripts
- NO_CMAKE_PATH
- NO_CMAKE_ENVIRONMENT_PATH
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ [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()
_python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_EXECUTABLE)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
break()
endif()
- if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
- continue()
- endif()
- endif()
- # Apple frameworks handling
- if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- 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 (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
+ # try using HINTS
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
NAMES ${_${_PYTHON_PREFIX}_NAMES}
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- [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()
- _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
- endif()
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ # 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.
+ if (CMAKE_HOST_WIN32)
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ python
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
+ else()
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES})
+ endif()
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
- # try using HINTS
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
- endif()
- # 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.
- if (CMAKE_HOST_WIN32)
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES python${_${_PYTHON_PREFIX}_VERSION}
- python
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
- else()
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES python${_${_PYTHON_PREFIX}_VERSION})
- endif()
- _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
- endif()
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
- # Apple frameworks handling
- if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- NAMES_PER_DIR
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
- PATH_SUFFIXES bin
- NO_DEFAULT_PATH)
- endif()
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ endif()
- # Windows registry
- if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES ${_${_PYTHON_PREFIX}_NAMES}
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
- NAMES_PER_DIR
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
- PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_DEFAULT_PATH)
- endif()
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endforeach()
- _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- break()
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE AND
+ NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ # No specific version found. Retry with generic names and 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()
- endforeach()
-
- if (NOT ${_PYTHON_PREFIX}_EXECUTABLE AND
- NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
- # No specific version found. Retry with generic names and 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()
endif()
+ set (${_PYTHON_PREFIX}_EXECUTABLE "${_${_PYTHON_PREFIX}_EXECUTABLE}")
+
# retrieve exact version of executable found
- if (${_PYTHON_PREFIX}_EXECUTABLE)
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
"import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
OUTPUT_VARIABLE ${_PYTHON_PREFIX}_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT _${_PYTHON_PREFIX}_RESULT)
+ set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE TRUE)
string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${${_PYTHON_PREFIX}_VERSION}")
list (GET _${_PYTHON_PREFIX}_VERSIONS 0 ${_PYTHON_PREFIX}_VERSION_MAJOR)
list (GET _${_PYTHON_PREFIX}_VERSIONS 1 ${_PYTHON_PREFIX}_VERSION_MINOR)
list (GET _${_PYTHON_PREFIX}_VERSIONS 2 ${_PYTHON_PREFIX}_VERSION_PATCH)
else()
# Interpreter is not usable
- set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE)
+ set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE FALSE)
unset (${_PYTHON_PREFIX}_VERSION)
endif()
endif()
- if (${_PYTHON_PREFIX}_EXECUTABLE
+ if (_${_PYTHON_PREFIX}_EXECUTABLE AND _${_PYTHON_PREFIX}_EXECUTABLE_USABLE
AND ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
set (${_PYTHON_PREFIX}_Interpreter_FOUND TRUE)
- # Use interpreter version for future searches to ensure consistency
+ # Use interpreter version and ABI for future searches to ensure consistency
set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assunme ABI is not supported
+ set (_${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
endif()
if (${_PYTHON_PREFIX}_Interpreter_FOUND)
+ # compute and save interpreter signature
+ string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ set (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}" CACHE INTERNAL "")
+
if (NOT CMAKE_SIZEOF_VOID_P)
# determine interpreter architecture
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)"
+ 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)
@@ -746,7 +1203,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
# retrieve interpreter identity
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -V
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -V
RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
OUTPUT_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID
ERROR_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID)
@@ -759,7 +1216,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
string (REGEX REPLACE "^([^ ]+).*" "\\1" ${_PYTHON_PREFIX}_INTERPRETER_ID "${${_PYTHON_PREFIX}_INTERPRETER_ID}")
if (${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "Python")
# try to get a more precise ID
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.copyright)"
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.copyright)"
RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
OUTPUT_VARIABLE ${_PYTHON_PREFIX}_COPYRIGHT
ERROR_QUIET)
@@ -771,144 +1228,169 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
else()
set (${_PYTHON_PREFIX}_INTERPRETER_ID Python)
endif()
- else()
- unset (${_PYTHON_PREFIX}_INTERPRETER_ID)
- endif()
- # retrieve various package installation directories
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))"
+ # retrieve various package installation directories
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))"
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS
- ERROR_QUIET)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- list (GET _${_PYTHON_PREFIX}_LIBPATHS 0 ${_PYTHON_PREFIX}_STDLIB)
- list (GET _${_PYTHON_PREFIX}_LIBPATHS 1 ${_PYTHON_PREFIX}_STDARCH)
- list (GET _${_PYTHON_PREFIX}_LIBPATHS 2 ${_PYTHON_PREFIX}_SITELIB)
- list (GET _${_PYTHON_PREFIX}_LIBPATHS 3 ${_PYTHON_PREFIX}_SITEARCH)
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS
+ ERROR_QUIET)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 0 ${_PYTHON_PREFIX}_STDLIB)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 1 ${_PYTHON_PREFIX}_STDARCH)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 2 ${_PYTHON_PREFIX}_SITELIB)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 3 ${_PYTHON_PREFIX}_SITEARCH)
+ else()
+ unset (${_PYTHON_PREFIX}_STDLIB)
+ unset (${_PYTHON_PREFIX}_STDARCH)
+ unset (${_PYTHON_PREFIX}_SITELIB)
+ unset (${_PYTHON_PREFIX}_SITEARCH)
+ endif()
else()
- unset (${_PYTHON_PREFIX}_STDLIB)
- unset (${_PYTHON_PREFIX}_STDARCH)
- unset (${_PYTHON_PREFIX}_SITELIB)
- unset (${_PYTHON_PREFIX}_SITEARCH)
+ unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE)
+ unset (${_PYTHON_PREFIX}_INTERPRETER_ID)
endif()
- mark_as_advanced (${_PYTHON_PREFIX}_EXECUTABLE)
+ mark_as_advanced (_${_PYTHON_PREFIX}_EXECUTABLE
+ _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE)
endif()
# second step, search for compiler (IronPython)
if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
- list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_COMPILER)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_COMPILER)
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Compiler)
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_COMPILER)
endif()
- # IronPython specific artifacts
- # If IronPython interpreter is found, use its path
- unset (_${_PYTHON_PREFIX}_IRON_ROOT)
- if (${_PYTHON_PREFIX}_Interpreter_FOUND AND ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
- get_filename_component (_${_PYTHON_PREFIX}_IRON_ROOT "${${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY)
+ if (DEFINED ${_PYTHON_PREFIX}_COMPILER
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_COMPILER}")
+ set (_${_PYTHON_PREFIX}_COMPILER "${${_PYTHON_PREFIX}_COMPILER}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_COMPILER)
+ # compute compiler signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}")
+ if (__${_PYTHON_PREFIX}_COMPILER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_COMPILER_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_COMPILER CACHE)
+ unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE)
+ endif()
endif()
- if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
- set (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ if (NOT _${_PYTHON_PREFIX}_COMPILER)
+ # IronPython specific artifacts
+ # If IronPython interpreter is found, use its path
+ unset (_${_PYTHON_PREFIX}_IRON_ROOT)
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND AND ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
+ get_filename_component (_${_PYTHON_PREFIX}_IRON_ROOT "${${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY)
+ endif()
- foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- # Registry Paths
- list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS
- [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
- endforeach()
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ set (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # Registry Paths
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
+ endforeach()
- while (TRUE)
- if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_program (${_PYTHON_PREFIX}_COMPILER
+ while (TRUE)
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+ endif()
+
+ find_program (_${_PYTHON_PREFIX}_COMPILER
NAMES ipyc
HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
_python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_COMPILER)
+ if (_${_PYTHON_PREFIX}_COMPILER)
break()
endif()
- endif()
- find_program (${_PYTHON_PREFIX}_COMPILER
- NAMES ipyc
- HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION})
- if (${_PYTHON_PREFIX}_COMPILER)
- break()
- endif()
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ endif()
- if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
- find_program (${_PYTHON_PREFIX}_COMPILER
- NAMES ipyc
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_DEFAULT_PATH)
- endif()
+ break()
+ endwhile()
+ else()
+ # 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)
+ _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+ endif()
- break()
- endwhile()
- else()
- # 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
+ 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)
_python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_COMPILER)
+ if (_${_PYTHON_PREFIX}_COMPILER)
break()
endif()
- endif()
- find_program (${_PYTHON_PREFIX}_COMPILER
- NAMES ipyc
- HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_COMPILER)
- break()
- endif()
-
- 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)
- _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
- if (${_PYTHON_PREFIX}_COMPILER)
- break()
+ 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)
+ _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
endif()
- endif()
- endforeach()
+ endforeach()
- # no specific version found, re-try in standard paths
- find_program (${_PYTHON_PREFIX}_COMPILER
- NAMES ipyc
- HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
+ # no specific version found, re-try in standard paths
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
+ endif()
endif()
- if (${_PYTHON_PREFIX}_COMPILER)
+ set (${_PYTHON_PREFIX}_COMPILER "${_${_PYTHON_PREFIX}_COMPILER}")
+
+ if (_${_PYTHON_PREFIX}_COMPILER)
# retrieve python environment version from compiler
set (_${_PYTHON_PREFIX}_VERSION_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))\n")
- execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py"
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py"
WORKING_DIRECTORY "${_${_PYTHON_PREFIX}_VERSION_DIR}"
OUTPUT_QUIET
ERROR_QUIET)
@@ -918,6 +1400,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
OUTPUT_VARIABLE _${_PYTHON_PREFIX}_VERSION
ERROR_QUIET)
if (NOT _${_PYTHON_PREFIX}_RESULT)
+ set (_${_PYTHON_PREFIX}_COMPILER_USABLE TRUE)
string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${_${_PYTHON_PREFIX}_VERSION}")
list (GET _${_PYTHON_PREFIX}_VERSIONS 0 _${_PYTHON_PREFIX}_VERSION_MAJOR)
list (GET _${_PYTHON_PREFIX}_VERSIONS 1 _${_PYTHON_PREFIX}_VERSION_MINOR)
@@ -932,12 +1415,12 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
else()
# compiler not usable
- set (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE)
+ set (_${_PYTHON_PREFIX}_COMPILER_USABLE FALSE)
endif()
file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}")
endif()
- if (${_PYTHON_PREFIX}_COMPILER)
+ if (_${_PYTHON_PREFIX}_COMPILER AND _${_PYTHON_PREFIX}_COMPILER_USABLE)
if (${_PYTHON_PREFIX}_Interpreter_FOUND)
# Compiler must be compatible with interpreter
if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
@@ -951,12 +1434,18 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
if (${_PYTHON_PREFIX}_Compiler_FOUND)
+ # compute and save compiler signature
+ string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}")
+ set (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${__${_PYTHON_PREFIX}_COMPILER_SIGNATURE}" CACHE INTERNAL "")
+
set (${_PYTHON_PREFIX}_COMPILER_ID IronPython)
else()
+ unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE)
unset (${_PYTHON_PREFIX}_COMPILER_ID)
endif()
- mark_as_advanced (${_PYTHON_PREFIX}_COMPILER)
+ mark_as_advanced (_${_PYTHON_PREFIX}_COMPILER
+ _${_PYTHON_PREFIX}_COMPILER_SIGNATURE)
endif()
@@ -964,15 +1453,50 @@ endif()
## Development environment is not compatible with IronPython interpreter
if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
AND NOT ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
- list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_LIBRARY
- ${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_LIBRARY_RELEASE
${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
- ${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ _${_PYTHON_PREFIX}_LIBRARY_DEBUG
${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
- ${_PYTHON_PREFIX}_INCLUDE_DIR)
+ _${_PYTHON_PREFIX}_INCLUDE_DIR)
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARY
- ${_PYTHON_PREFIX}_INCLUDE_DIR)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES
+ ${_PYTHON_PREFIX}_INCLUDE_DIRS)
+ endif()
+
+ if (DEFINED _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # compute development signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ if (WIN32 AND NOT DEFINED _${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ set (_${_PYTHON_PREFIX}_LIBRARY_DEBUG "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND" CACHE INTERNAL "")
+ endif()
+ if (NOT DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ set (_${_PYTHON_PREFIX}_INCLUDE_DIR "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND" CACHE INTERNAL "")
+ endif()
+ if (__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE)
+ unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
+ unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
+ unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
+ endif()
+ endif()
+ if (DEFINED ${_PYTHON_PREFIX}_LIBRARY
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}")
+ set (_${_PYTHON_PREFIX}_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_LIBRARY}" CACHE INTERNAL "")
+ unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
+ unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
+ endif()
+ if (DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_INCLUDE_DIR "${${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE INTERNAL "")
endif()
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
@@ -986,360 +1510,282 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
endif()
- # if python interpreter is found, use its location and version to ensure consistency
- # between interpreter and development environment
- unset (_${_PYTHON_PREFIX}_PREFIX)
- unset (_${_PYTHON_PREFIX}_EXEC_PREFIX)
- unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX)
- if (${_PYTHON_PREFIX}_Interpreter_FOUND)
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
- "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.EXEC_PREFIX)"
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_EXEC_PREFIX
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (_${_PYTHON_PREFIX}_RESULT)
- unset (_${_PYTHON_PREFIX}_EXEC_PREFIX)
- endif()
-
- if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "STANDARD")
- execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
- "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.BASE_EXEC_PREFIX)"
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_BASE_EXEC_PREFIX
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (_${_PYTHON_PREFIX}_RESULT)
- unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX)
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # if python interpreter is found, use it to look-up for artifacts
+ # to ensure consistency between interpreter and development environments.
+ # If not, try to locate a compatible config tool
+ if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND OR CMAKE_CROSSCOMPILING)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
endif()
- endif()
- endif()
- set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_EXEC_PREFIX}" "${_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
- if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
- set (_${_PYTHON_PREFIX}_CONFIG_NAMES)
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ set (_${_PYTHON_PREFIX}_CONFIG_NAMES)
- foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- if (DEFINED CMAKE_LIBRARY_ARCHITECTURE)
- list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "${CMAKE_LIBRARY_ARCHITECTURE}-python${_${_PYTHON_PREFIX}_VERSION}-config")
- endif()
- list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "python${_${_PYTHON_PREFIX}_VERSION}-config")
- endforeach()
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG)
+ list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
- find_program (_${_PYTHON_PREFIX}_CONFIG
- NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin)
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ endforeach()
- if (_${_PYTHON_PREFIX}_CONFIG AND 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)
- else()
- string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT)
- if (_${_PYTHON_PREFIX}_RESULT EQUAL -1)
- unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
endif()
- endif()
- endif()
- else()
- foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- # try to use pythonX.Y-config tool
- set (_${_PYTHON_PREFIX}_CONFIG_NAMES)
- if (DEFINED CMAKE_LIBRARY_ARCHITECTURE)
- set (_${_PYTHON_PREFIX}_CONFIG_NAMES "${CMAKE_LIBRARY_ARCHITECTURE}-python${_${_PYTHON_PREFIX}_VERSION}-config")
- endif()
- 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)
- 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()
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES bin)
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
endif()
- string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT)
- if (_${_PYTHON_PREFIX}_RESULT EQUAL -1)
- unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
- continue()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume config tool is not usable
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
endif()
- endif()
- if (_${_PYTHON_PREFIX}_CONFIG)
- break()
- endif()
- endforeach()
- endif()
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume ABI is not supported
+ set (__${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # Wrong ABI
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
- if (_${_PYTHON_PREFIX}_CONFIG)
- # retrieve root install directory
- execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --prefix
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PREFIX
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (_${_PYTHON_PREFIX}_RESULT)
- # python-config is not usable
- unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
- endif()
- endif()
+ if (_${_PYTHON_PREFIX}_CONFIG AND 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)
+ else()
+ string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT)
+ if (_${_PYTHON_PREFIX}_RESULT EQUAL -1)
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
+ endif()
+ else()
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # try to use pythonX.Y-config tool
+ _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG)
- if (_${_PYTHON_PREFIX}_CONFIG)
- set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
- unset (_${_PYTHON_PREFIX}_LIB_DIRS)
- unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES)
- unset (_${_PYTHON_PREFIX}_LIB_NAMES)
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
- # retrieve library
- execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- # retrieve library directory
- string (REGEX MATCHALL "-L[^ ]+" _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_FLAGS}")
- string (REPLACE "-L" "" _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_LIB_DIRS}")
- if (_${_PYTHON_PREFIX}_CONFIG MATCHES "python([0-9.]+)-config")
- _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES ${CMAKE_MATCH_1} LIBRARY)
- endif()
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES bin)
- # retrieve library name
- string (REGEX MATCHALL "-lpython[^ ]+" _${_PYTHON_PREFIX}_LIB_NAMES "${_${_PYTHON_PREFIX}_FLAGS}")
- string (REPLACE "-l" "" _${_PYTHON_PREFIX}_LIB_NAMES "${_${_PYTHON_PREFIX}_LIB_NAMES}")
- list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_LIB_NAMES)
- endif()
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
- execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- list (APPEND _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_CONFIGDIR}")
- endif()
- list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_LIB_DIRS)
- list (APPEND _${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_LIB_DIRS})
-
- if (NOT _${_PYTHON_PREFIX}_LIB_NAMES)
- # config tool do not specify "-l" option (it is the case starting with 3.8)
- # extract version from the config tool name and list all possible lib names
- if (_${_PYTHON_PREFIX}_CONFIG MATCHES "python([0-9.]+)-config")
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${CMAKE_MATCH_1})
- endif()
- endif()
+ unset (_${_PYTHON_PREFIX}_CONFIG_NAMES)
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume config tool is not usable
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
- list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+ if (NOT _${_PYTHON_PREFIX}_CONFIG)
+ continue()
+ endif()
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
-
- # retrieve runtime library
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
- get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
- _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- endif()
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume ABI is not supported
+ set (__${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # Wrong ABI
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ continue()
+ endif()
- # retrieve include directory
- execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --includes
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- # retrieve include directory
- string (REGEX MATCHALL "-I[^ ]+" _${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_FLAGS}")
- string (REPLACE "-I" "" _${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIRS}")
- list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_DIRS)
+ if (_${_PYTHON_PREFIX}_CONFIG AND 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()
- find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
- NAMES Python.h
- HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ break()
+ endif()
+ endforeach()
+ endif()
endif()
endif()
- # Rely on HINTS and standard paths if config tool failed to locate artifacts
- if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR)
- set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
-
- if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
- unset (_${_PYTHON_PREFIX}_LIB_NAMES)
- unset (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG)
- unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
- unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
- unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES)
-
- foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- # library names
- _python_get_lib_names (_${_PYTHON_PREFIX}_VERSION_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION})
- list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
- _python_get_lib_names (_${_PYTHON_PREFIX}_VERSION_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION} DEBUG)
- list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION_NAMES})
-
- # Framework Paths
- _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
- list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
+ # retrieve root install directory
+ _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX)
- # Registry Paths
- _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
- list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ # enforce current ABI
+ _python_get_config_var (_${_PYTHON_PREFIX}_ABIFLAGS ABIFLAGS)
- # Paths suffixes
- _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
- list (APPEND _${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION_PATHS})
- endforeach()
+ set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
- if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
- NO_CMAKE_PATH
- NO_CMAKE_ENVIRONMENT_PATH
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
+ # retrieve library
+ ## compute some paths and artifact names
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_VERSION "${_${_PYTHON_PREFIX}_CONFIG}")
+ else()
+ set (_${_PYTHON_PREFIX}_VERSION "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}")
endif()
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} LIBRARY)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY)
- if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- endif()
+ _python_get_config_var (_${_PYTHON_PREFIX}_CONFIGDIR CONFIGDIR)
+ list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}")
+
+ list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
- # search in HINTS locations
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
+ endif()
- 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_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
- ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES})
-
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- # extract version from library name
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)")
- set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
- elseif (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)")
- set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
- endif()
- endif()
+ # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
- if (WIN32)
- # search for debug library
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- # use library location as a hint
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION} DEBUG)
- get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
- find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
- NAMES_PER_DIR
- 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_PREFIX}_LIB_NAMES_DEBUG}
- 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_PREFIX}_LIB_NAMES_DEBUG}
- NAMES_PER_DIR
- HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES lib libs)
-
- # extract version from library name
- if (${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "python([23])([0-9]+)")
- set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
- elseif (${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "python([23])\\.([0-9]+)")
- set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
- endif()
- endif()
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
endif()
- else()
- foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION})
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_LIB_VERSION} DEBUG)
- _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
- _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
-
- _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ unset (_${_PYTHON_PREFIX}_LIB_NAMES)
+ unset (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG)
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES)
+
+ foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # library names
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY)
+ list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG)
+ list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+
+ # Registry Paths
+ _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+
+ # Paths suffixes
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
+ list (APPEND _${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ endforeach()
if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
@@ -1348,152 +1794,209 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
endif()
# search in HINTS locations
- find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
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 (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()
+ 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
+ # search in all default paths
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES})
+ else()
+ foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG)
- if (WIN32)
- # search for debug library
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- # 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_PREFIX}_LIB_NAMES_DEBUG}
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
- 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_PREFIX}_LIB_NAMES_DEBUG}
- 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_PREFIX}_LIB_NAMES_DEBUG}
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ 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_PREFIX}_LIB_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
- PATH_SUFFIXES lib libs)
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
endif()
- endif()
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
- set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION})
- break()
- endif()
- endforeach()
- endif()
+ # search in HINTS locations
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ 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()
- # retrieve runtime libraries
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION})
- get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
- get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
- _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
- NAMES_PER_DIR
- HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin)
+ 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_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES})
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ break()
+ endif()
+ endforeach()
+ endif()
endif()
- if (${_PYTHON_PREFIX}_LIBRARY_DEBUG)
- _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION} DEBUG)
- get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY)
- get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
- _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
- NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
- NAMES_PER_DIR
- HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin)
+ endif()
+
+ # finalize library version information
+ _python_get_version (LIBRARY PREFIX _${_PYTHON_PREFIX}_)
+
+ set (${_PYTHON_PREFIX}_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "Path to a library." FORCE)
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ # search for debug library
+ # use release library location as a hint
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
+ NO_DEFAULT_PATH)
+ endif()
+
+ # retrieve runtime libraries
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
+ _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin)
+ endif()
+ if (_${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
+ _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin)
+ endif()
+
+ # Don't search for include dir if no library was founded
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
+ _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES)
+
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h
+ HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
endif()
- # Don't search for include dir if no library was founded
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts
+ if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
+ endif()
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()
+ # Use the library's install prefix as a hint
+ if (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ elseif (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ else()
+ # assume library is in a directory under root
+ get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY)
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
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
- if (${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
- list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
- elseif (${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config")
- list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
- elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
- list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
- else()
- # assume library is in a directory under root
- get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${${_${_PYTHON_PREFIX}_LIB}}" DIRECTORY)
- get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY)
- list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
- endif()
- endif()
- endforeach()
- list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_HINTS)
-
_python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
_python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
- _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION} INCLUDE)
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} INCLUDE)
if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
- find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
NAMES Python.h
HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
@@ -1502,10 +2005,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
- find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
NAMES Python.h
HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
@@ -1523,10 +2027,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS)
endif()
- find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
NAMES Python.h
HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
- PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
@@ -1534,31 +2039,37 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
# search header file in standard locations
- find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
NAMES Python.h)
endif()
- if (${_PYTHON_PREFIX}_INCLUDE_DIR)
+ set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR)
# retrieve version from header file
- file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" _${_PYTHON_PREFIX}_VERSION
- REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
- string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
- _${_PYTHON_PREFIX}_VERSION "${_${_PYTHON_PREFIX}_VERSION}")
- string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${_${_PYTHON_PREFIX}_VERSION}")
- list (GET _${_PYTHON_PREFIX}_VERSIONS 0 _${_PYTHON_PREFIX}_VERSION_MAJOR)
- list (GET _${_PYTHON_PREFIX}_VERSIONS 1 _${_PYTHON_PREFIX}_VERSION_MINOR)
- list (GET _${_PYTHON_PREFIX}_VERSIONS 2 _${_PYTHON_PREFIX}_VERSION_PATCH)
-
- if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND)
- # set public version information
- set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION})
- set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR})
- set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR})
- set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH})
+ _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_)
+
+ # update versioning
+ if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION})
+ set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH})
endif()
endif()
+ if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND)
+ # set public version information
+ set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION})
+ set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR})
+ set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH})
+ endif()
+
# define public variables
+ set (${_PYTHON_PREFIX}_LIBRARY_DEBUG "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" CACHE FILEPATH "Path to a library." FORCE)
+
include (${CMAKE_CURRENT_LIST_DIR}/../SelectLibraryConfigurations.cmake)
select_library_configurations (${_PYTHON_PREFIX})
if (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
@@ -1566,14 +2077,13 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
elseif (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}")
else()
- set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "$${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND")
+ set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND")
endif()
_python_set_library_dirs (${_PYTHON_PREFIX}_LIBRARY_DIRS
${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
if (UNIX)
- if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
- OR ${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DIRS ${${_PYTHON_PREFIX}_LIBRARY_DIRS})
endif()
else()
@@ -1581,66 +2091,114 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
endif()
- set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
-
- mark_as_advanced (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
- ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
- ${_PYTHON_PREFIX}_INCLUDE_DIR)
-
- if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
- AND ${_PYTHON_PREFIX}_INCLUDE_DIR)
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR)
if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND)
# development environment must be compatible with interpreter/compiler
- if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}
+ AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
endif()
- elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR
+ AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND
+ (NOT _${_PYTHON_PREFIX}_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS
+ OR NOT _${_PYTHON_PREFIX}_INC_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS))
+ set (${_PYTHON_PREFIX}_Development_FOUND FALSE)
+ endif()
+ endif()
+
+ if (${_PYTHON_PREFIX}_Development_FOUND)
+ # compute and save development signature
+ string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}" CACHE INTERNAL "")
+ else()
+ unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
endif()
# Restore the original find library ordering
if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES)
set (CMAKE_FIND_LIBRARY_SUFFIXES ${_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ _${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
+ _${_PYTHON_PREFIX}_INCLUDE_DIR
+ _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
endif()
if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND)
- list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS)
+ endif()
+
+ if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ # compute numpy signature. Depends on interpreter and development signatures
+ string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE
+ OR NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ unset (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE)
+ unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE)
+ endif()
endif()
- execute_process(
+
+ if (NOT _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ execute_process(
COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_PATH
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- find_path(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
- NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h"
- HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}"
- NO_DEFAULT_PATH)
+
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ find_path (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
+ NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h"
+ HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}"
+ NO_DEFAULT_PATH)
+ endif()
endif()
- if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
- set(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
- set(${_PYTHON_PREFIX}_NumPy_FOUND TRUE)
+
+ set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+
+ if(_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ set_property (CACHE _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR-NOTFOUND")
endif()
- if(${_PYTHON_PREFIX}_NumPy_FOUND)
- execute_process(
+
+ if (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ execute_process (
COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_VERSION)
if (NOT _${_PYTHON_PREFIX}_RESULT)
- set(${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}")
+ set (${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}")
+ else()
+ unset (${_PYTHON_PREFIX}_NumPy_VERSION)
endif()
+
+ # final step: set NumPy founded only if Development component is founded as well
+ set(${_PYTHON_PREFIX}_NumPy_FOUND ${${_PYTHON_PREFIX}_Development_FOUND})
+ else()
+ set (${_PYTHON_PREFIX}_NumPy_FOUND FALSE)
endif()
- # final step: set NumPy founded only if Development component is founded as well
- if (NOT ${_PYTHON_PREFIX}_Development_FOUND)
- set(${_PYTHON_PREFIX}_NumPy_FOUND FALSE)
+
+ if (${_PYTHON_PREFIX}_NumPy_FOUND)
+ # compute and save numpy signature
+ string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${__${_PYTHON_PREFIX}_NUMPY_SIGNATURE}" CACHE INTERNAL "")
+ else()
+ unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE)
endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
endif()
# final validation
@@ -1678,20 +2236,20 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
macro (__PYTHON_IMPORT_LIBRARY __name)
if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
- OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
- OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
+ OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED)
else()
set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC)
endif()
- add_library (${__name} ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED)
+ if (NOT TARGET ${__name})
+ add_library (${__name} ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED)
+ endif()
set_property (TARGET ${__name}
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
- if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
- OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG))
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
# System manage shared libraries in two parts: import and runtime
if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
set_property (TARGET ${__name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
@@ -1725,53 +2283,41 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
endif()
endif()
- if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC")
+ if (_${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC")
# extend link information with dependent libraries
- execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags
- RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
- OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (NOT _${_PYTHON_PREFIX}_RESULT)
- string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}")
- # remove elements relative to python library itself
- list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython")
- foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS)
- list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}")
- endforeach()
+ _python_get_config_var (_${_PYTHON_PREFIX}_LINK_LIBRARIES LIBS)
+ if (_${_PYTHON_PREFIX}_LINK_LIBRARIES)
set_property (TARGET ${__name}
PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES})
endif()
endif()
endmacro()
- if (NOT TARGET ${_PYTHON_PREFIX}::Python)
- __python_import_library (${_PYTHON_PREFIX}::Python)
- endif()
+ __python_import_library (${_PYTHON_PREFIX}::Python)
- if (NOT TARGET ${_PYTHON_PREFIX}::Module)
- if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$")
- # On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python
- # but ALIAS cannot be used because the imported library is not GLOBAL.
- __python_import_library (${_PYTHON_PREFIX}::Module)
- else()
+ if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$")
+ # On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python
+ # but ALIAS cannot be used because the imported library is not GLOBAL.
+ __python_import_library (${_PYTHON_PREFIX}::Module)
+ else()
+ if (NOT TARGET ${_PYTHON_PREFIX}::Module )
add_library (${_PYTHON_PREFIX}::Module INTERFACE IMPORTED)
- set_property (TARGET ${_PYTHON_PREFIX}::Module
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ endif()
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
- # When available, enforce shared library generation with undefined symbols
- if (APPLE)
- set_property (TARGET ${_PYTHON_PREFIX}::Module
- PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
- endif()
- if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
- set_property (TARGET ${_PYTHON_PREFIX}::Module
- PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs")
- endif()
- if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
- set_property (TARGET ${_PYTHON_PREFIX}::Module
- PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok")
- endif()
+ # When available, enforce shared library generation with undefined symbols
+ if (APPLE)
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs")
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok")
endif()
endif()
@@ -1810,7 +2356,7 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
AND NOT TARGET ${_PYTHON_PREFIX}::NumPy AND TARGET ${_PYTHON_PREFIX}::Module)
add_library (${_PYTHON_PREFIX}::NumPy INTERFACE IMPORTED)
set_property (TARGET ${_PYTHON_PREFIX}::NumPy
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS}")
target_link_libraries (${_PYTHON_PREFIX}::NumPy INTERFACE ${_PYTHON_PREFIX}::Module)
endif()
endif()
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 8372ce7..0cecdc6 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -193,6 +193,50 @@ Hints
``NEVER`` to select preferably the interpreter from the virtual
environment.
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python2_EXECUTABLE``
+ The path to the interpreter.
+
+``Python2_COMPILER``
+ The path to the compiler.
+
+``Python2_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python2_LIBRARIES``, ``Python2_LIBRAY_DIRS`` and
+ ``Python2_RUNTIME_LIBRARY_DIRS``.
+
+``Python2_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python2_INCLUDE_DIRS``.
+
+``Python2_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python2_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
Commands
^^^^^^^^
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 2ead5b6..1edb9c9 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -138,6 +138,47 @@ Hints
* If set to TRUE, search **only** for static libraries.
* If set to FALSE, search **only** for shared libraries.
+``Python3_FIND_ABI``
+ This variable defines which ABIs, as defined in
+ `PEP 3149 <https://www.python.org/dev/peps/pep-3149/>`_, should be searched.
+
+ .. note::
+
+ If ``Python3_FIND_ABI`` is not defined, any ABI will be searched.
+
+ The ``Python3_FIND_ABI`` variable is a 3-tuple specifying, in that order,
+ ``pydebug`` (``d``), ``pymalloc`` (``m``) and ``unicode`` (``u``) flags.
+ Each element can be set to one of the following:
+
+ * ``ON``: Corresponding flag is selected.
+ * ``OFF``: Corresponding flag is not selected.
+ * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched.
+
+ From this 3-tuple, various ABIs will be searched starting from the most
+ specialized to the most general. Moreover, ``debug`` versions will be
+ searched **after** ``non-debug`` ones.
+
+ For example, if we have::
+
+ set (Python3_FIND_ABI "ON" "ANY" "ANY")
+
+ The following flags combinations will be appended, in that order, to the
+ artifact names: ``dmu``, ``dm``, ``du``, and ``d``.
+
+ And to search any possible ABIs::
+
+ set (Python3_FIND_ABI "ANY" "ANY" "ANY")
+
+ The following combinations, in that order, will be used: ``mu``, ``m``,
+ ``u``, ``<empty>``, ``dmu``, ``dm``, ``du`` and ``d``.
+
+ .. note::
+
+ This hint is useful only on ``POSIX`` systems. So, on ``Windows`` systems,
+ when ``Python3_FIND_ABI`` is defined, ``Python`` distributions from
+ `python.org <https://www.python.org/>`_ will be found only if value for
+ each flag is ``OFF`` or ``ANY``.
+
``Python3_FIND_STRATEGY``
This variable defines how lookup will be done.
The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the
@@ -193,6 +234,50 @@ Hints
``NEVER`` to select preferably the interpreter from the virtual
environment.
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python3_EXECUTABLE``
+ The path to the interpreter.
+
+``Python3_COMPILER``
+ The path to the compiler.
+
+``Python3_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python3_LIBRARIES``, ``Python3_LIBRAY_DIRS`` and
+ ``Python3_RUNTIME_LIBRARY_DIRS``.
+
+``Python3_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python3_INCLUDE_DIRS``.
+
+``Python3_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python3_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
Commands
^^^^^^^^
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index da33301..ccc7d5b 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -39,6 +39,15 @@ If calling both ``find_package(PythonInterp)`` and
``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
get the currently active Python version by default with a consistent version
of PYTHON_LIBRARIES.
+
+.. note::
+
+ A call to ``find_package(PythonInterp ${V})`` for python version ``V``
+ may find a ``python`` executable with no version suffix. In this case
+ no attempt is made to avoid python executables from other versions.
+ Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython`
+ instead.
+
#]=======================================================================]
unset(_Python_NAMES)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index a145b46..3993968 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -670,7 +670,7 @@ if (QT_QMAKE_EXECUTABLE AND
get_filename_component(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE)
set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
endif()
- elseif()
+ else()
message("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}")
message("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.")
endif()
diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake
index ae8d72d..55da55f 100644
--- a/Modules/FindVulkan.cmake
+++ b/Modules/FindVulkan.cmake
@@ -5,7 +5,7 @@
FindVulkan
----------
-Find Vulkan, which isis a low-overhead, cross-platform 3D graphics
+Find Vulkan, which is a low-overhead, cross-platform 3D graphics
and computing API.
IMPORTED Targets
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index 4db4e18..f95e6e2 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -222,7 +222,8 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set
# updated to the new default, unless the user explicitly changed it.
endif()
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
- AND NOT CMAKE_CROSSCOMPILING)
+ AND NOT CMAKE_CROSSCOMPILING
+ AND NOT EXISTS "/etc/arch-release")
if (EXISTS "/etc/debian_version") # is this a debian system ?
if(CMAKE_LIBRARY_ARCHITECTURE)
if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index 5be4676..57ae446 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -5,6 +5,10 @@
GetPrerequisites
----------------
+.. deprecated:: 3.16
+
+ Use :command:`file(GET_RUNTIME_DEPENDENCIES)` instead.
+
Functions to analyze and list executable file prerequisites.
This module provides functions to list the .dll, .dylib or .so files
@@ -706,7 +710,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
find_program(gp_dumpbin "dumpbin" PATHS ${gp_cmd_paths})
if(gp_dumpbin)
set(gp_tool "dumpbin")
- else() # Try harder. Maybe we're on MinGW
+ elseif(CMAKE_OBJDUMP) # Try harder. Maybe we're on MinGW
+ set(gp_tool "${CMAKE_OBJDUMP}")
+ else()
set(gp_tool "objdump")
endif()
endif()
@@ -723,7 +729,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
if(gp_tool MATCHES "ldd$")
set(gp_cmd_args "")
- set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$")
+ set(gp_regex "^[\t ]*[^\t ]+ =>[\t ]+([^\t\(]+)( \(.+\))?${eol_char}$")
set(gp_regex_error "not found${eol_char}$")
set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$")
set(gp_regex_cmp_count 1)
diff --git a/Modules/CPack.DS_Store.in b/Modules/Internal/CPack/CPack.DS_Store.in
index 5be0eeb..5be0eeb 100644
--- a/Modules/CPack.DS_Store.in
+++ b/Modules/Internal/CPack/CPack.DS_Store.in
Binary files differ
diff --git a/Modules/CPack.Description.plist.in b/Modules/Internal/CPack/CPack.Description.plist.in
index 3d11476..3d11476 100644
--- a/Modules/CPack.Description.plist.in
+++ b/Modules/Internal/CPack/CPack.Description.plist.in
diff --git a/Modules/CPack.Info.plist.in b/Modules/Internal/CPack/CPack.Info.plist.in
index 6e32500..6e32500 100644
--- a/Modules/CPack.Info.plist.in
+++ b/Modules/Internal/CPack/CPack.Info.plist.in
diff --git a/Modules/CPack.NuGet.nuspec.in b/Modules/Internal/CPack/CPack.NuGet.nuspec.in
index b7beb5d..b7beb5d 100644
--- a/Modules/CPack.NuGet.nuspec.in
+++ b/Modules/Internal/CPack/CPack.NuGet.nuspec.in
diff --git a/Modules/CPack.OSXScriptLauncher.in b/Modules/Internal/CPack/CPack.OSXScriptLauncher.in
index c715860..c715860 100755..100644
--- a/Modules/CPack.OSXScriptLauncher.in
+++ b/Modules/Internal/CPack/CPack.OSXScriptLauncher.in
Binary files differ
diff --git a/Modules/CPack.OSXScriptLauncher.rsrc.in b/Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in
index 5f5f17a..5f5f17a 100644
--- a/Modules/CPack.OSXScriptLauncher.rsrc.in
+++ b/Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in
Binary files differ
diff --git a/Modules/CPack.OSXX11.Info.plist.in b/Modules/Internal/CPack/CPack.OSXX11.Info.plist.in
index 23a1483..23a1483 100644
--- a/Modules/CPack.OSXX11.Info.plist.in
+++ b/Modules/Internal/CPack/CPack.OSXX11.Info.plist.in
diff --git a/Modules/CPack.OSXX11.main.scpt.in b/Modules/Internal/CPack/CPack.OSXX11.main.scpt.in
index de30ea1..de30ea1 100644
--- a/Modules/CPack.OSXX11.main.scpt.in
+++ b/Modules/Internal/CPack/CPack.OSXX11.main.scpt.in
Binary files differ
diff --git a/Modules/CPack.RuntimeScript.in b/Modules/Internal/CPack/CPack.RuntimeScript.in
index f27444f..f27444f 100755
--- a/Modules/CPack.RuntimeScript.in
+++ b/Modules/Internal/CPack/CPack.RuntimeScript.in
diff --git a/Modules/CPack.STGZ_Header.sh.in b/Modules/Internal/CPack/CPack.STGZ_Header.sh.in
index 70f63d2..a857aa5 100755
--- a/Modules/CPack.STGZ_Header.sh.in
+++ b/Modules/Internal/CPack/CPack.STGZ_Header.sh.in
@@ -43,10 +43,10 @@ for a in "$@CPACK_AT_SIGN@"; do
cpack_prefix_dir=`cpack_fix_slashes "${cpack_prefix_dir}"`
fi
if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
- cpack_usage
+ cpack_usage
fi
if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
- cpack_version
+ cpack_version
exit 2
fi
if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then
@@ -86,15 +86,19 @@ then
@CPACK_RESOURCE_FILE_LICENSE_CONTENT@
____cpack__here_doc____
echo
- echo "Do you accept the license? [yN]: "
- read line leftover
- case ${line} in
- y* | Y*)
- cpack_license_accepted=TRUE;;
- *)
- echo "License not accepted. Exiting ..."
- exit 1;;
- esac
+ while true
+ do
+ echo "Do you accept the license? [yn]: "
+ read line leftover
+ case ${line} in
+ y* | Y*)
+ cpack_license_accepted=TRUE
+ break;;
+ n* | N* | q* | Q* | e* | E*)
+ echo "License not accepted. Exiting ..."
+ exit 1;;
+ esac
+ done
fi
if [ "x${cpack_include_subdir}x" = "xx" ]
@@ -143,4 +147,3 @@ exit 0
#-----------------------------------------------------------
# Start of TAR.GZ file
#-----------------------------------------------------------;
-
diff --git a/Modules/CPack.VolumeIcon.icns.in b/Modules/Internal/CPack/CPack.VolumeIcon.icns.in
index c59217e..c59217e 100644
--- a/Modules/CPack.VolumeIcon.icns.in
+++ b/Modules/Internal/CPack/CPack.VolumeIcon.icns.in
Binary files differ
diff --git a/Modules/CPack.background.png.in b/Modules/Internal/CPack/CPack.background.png.in
index a32ab37..a32ab37 100644
--- a/Modules/CPack.background.png.in
+++ b/Modules/Internal/CPack/CPack.background.png.in
Binary files differ
diff --git a/Modules/CPack.distribution.dist.in b/Modules/Internal/CPack/CPack.distribution.dist.in
index f20e66c..f20e66c 100644
--- a/Modules/CPack.distribution.dist.in
+++ b/Modules/Internal/CPack/CPack.distribution.dist.in
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake
index 89dc6f0..7791822 100644
--- a/Modules/Internal/CPack/CPackDeb.cmake
+++ b/Modules/Internal/CPack/CPackDeb.cmake
@@ -45,7 +45,7 @@ function(extract_so_info shared_object libname version)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(result EQUAL 0)
- string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
+ string(REGEX MATCH "\\(?SONAME\\)?[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
else()
diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake
index 4b2ce92..82053b2 100644
--- a/Modules/Internal/CPack/CPackNuGet.cmake
+++ b/Modules/Internal/CPack/CPackNuGet.cmake
@@ -262,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_ROOT}/Modules/CPack.NuGet.nuspec.in"
+ "${CMAKE_ROOT}/Modules/Internal/CPack/CPack.NuGet.nuspec.in"
"${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec"
@ONLY
)
diff --git a/Modules/NSIS.InstallOptions.ini.in b/Modules/Internal/CPack/NSIS.InstallOptions.ini.in
index d92d779..d92d779 100644
--- a/Modules/NSIS.InstallOptions.ini.in
+++ b/Modules/Internal/CPack/NSIS.InstallOptions.ini.in
diff --git a/Modules/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in
index f75ae78..f75ae78 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/Internal/CPack/NSIS.template.in
diff --git a/Modules/WIX.template.in b/Modules/Internal/CPack/WIX.template.in
index c4fc83a..c4fc83a 100644
--- a/Modules/WIX.template.in
+++ b/Modules/Internal/CPack/WIX.template.in
diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake
index 0abbb61..61d213a 100644
--- a/Modules/Platform/AIX-GNU.cmake
+++ b/Modules/Platform/AIX-GNU.cmake
@@ -8,23 +8,26 @@ if(__AIX_COMPILER_GNU)
endif()
set(__AIX_COMPILER_GNU 1)
-#
-# By default, runtime linking is enabled. All shared objects specified on the command line
-# will be listed, even if there are no symbols referenced, in the output file.
-string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl")
-
-
macro(__aix_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
- string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-G,-bnoipath")
- set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall")
+ string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
+ set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1)
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 7 OR CMAKE_SYSTEM_VERSION VERSION_LESS 7.1)
unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
endif()
+
+ # Construct the export list ourselves to pass only the object files so
+ # that we export only the symbols actually provided by the sources.
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
+ )
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endmacro()
diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake
index 06a806b..64b0bc1 100644
--- a/Modules/Platform/AIX-XL.cmake
+++ b/Modules/Platform/AIX-XL.cmake
@@ -8,43 +8,24 @@ if(__AIX_COMPILER_XL)
endif()
set(__AIX_COMPILER_XL 1)
-#
-# By default, runtime linking is enabled. All shared objects specified on the command line
-# will be listed, even if there are no symbols referenced, in the output file.
-string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl")
-
-
macro(__aix_compiler_xl lang)
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-bnoipath") # -shared
- set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall")
+ string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
+ set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ")
set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ")
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
- # Find the CreateExportList program that comes with this toolchain.
- find_program(CMAKE_XL_CreateExportList
- NAMES CreateExportList
- DOC "IBM XL CreateExportList tool"
+ # Construct the export list ourselves to pass only the object files so
+ # that we export only the symbols actually provided by the sources.
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
)
- # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones.
- # If we found the tool, we'll use it to create exports, otherwise stick with the regular
- # create shared library compile line.
- if (CMAKE_XL_CreateExportList)
- # The compiler front-end passes all object files, archive files, and shared
- # library files named on the command line to CreateExportList to create a
- # list of all symbols to be exported from the shared library. This causes
- # all archive members to be copied into the shared library whether they are
- # needed or not. Instead we run the tool ourselves to pass only the object
- # files so that we export only the symbols actually provided by the sources.
- set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
- "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
- "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
- )
- endif()
+ set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endmacro()
diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake
index 551a995..03cef51 100644
--- a/Modules/Platform/AIX.cmake
+++ b/Modules/Platform/AIX.cmake
@@ -1,5 +1,7 @@
set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
+set(CMAKE_AIX_IMPORT_FILE_PREFIX "")
+set(CMAKE_AIX_IMPORT_FILE_SUFFIX ".imp")
set(CMAKE_DL_LIBS "-lld")
# RPATH support on AIX is called libpath. By default the runtime
diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList
new file mode 100755
index 0000000..4f67ef5
--- /dev/null
+++ b/Modules/Platform/AIX/ExportImportList
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This script is internal to CMake and meant only to be
+# invoked by CMake-generated build systems on AIX.
+
+usage='usage: ExportImportList -o <out-file> [-l <lib>] [--] <objects>...'
+
+die() {
+ echo "$@" 1>&2; exit 1
+}
+
+# Process command-line arguments.
+out=''
+lib=''
+while test "$#" != 0; do
+ case "$1" in
+ -l) shift; lib="$1" ;;
+ -o) shift; out="$1" ;;
+ --) shift; break ;;
+ -*) die "$usage" ;;
+ *) break ;;
+ esac
+ shift
+done
+test -n "$out" || die "$usage"
+
+# Collect symbols exported from all object files.
+out_tmp="$out.tmp$$"
+trap 'rm -f "$out_tmp"' EXIT INT TERM
+for f in "$@"; do
+ dump -tov -X 32_64 "$f" |
+ awk '
+ BEGIN {
+ V["EXPORTED"]=" export"
+ V["PROTECTED"]=" protected"
+ }
+ /^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED| ) / {
+ if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) {
+ print $NF V[$(NF-1)]
+ }
+ }
+ '
+done > "$out_tmp"
+
+# Generate the export/import file.
+{
+ if test -n "$lib"; then
+ echo "#! $lib"
+ fi
+ sort -u "$out_tmp"
+} > "$out"
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index 9ed1e01..847178f 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -40,6 +40,9 @@ macro(__android_compiler_clang lang)
endif()
if(NOT CMAKE_${lang}_COMPILER_TARGET)
set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
+ endif()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
endif()
endmacro()
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index f8b9346..1affcd0 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -47,7 +47,41 @@ if(CMAKE_ANDROID_NDK)
endif()
if(CMAKE_ANDROID_STL_TYPE)
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_STL_TYPE STREQUAL "system")
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ set(_ANDROID_STL_RTTI 0)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_static")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -static-libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_shared")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "none")
+ set(_ANDROID_STL_RTTI 0)
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ macro(__android_stl lang)
+ # FIXME: Add a way to add project-wide language-specific compile-only flags.
+ set(CMAKE_CXX_COMPILE_OBJECT
+ "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -nostdinc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -nostdlib++")
+ endmacro()
+ else()
+ message(FATAL_ERROR
+ "Android: STL '${CMAKE_ANDROID_STL_TYPE}' not supported by this NDK."
+ )
+ endif()
+ elseif(CMAKE_ANDROID_NDK)
macro(__android_stl_inc lang dir req)
if(EXISTS "${dir}")
@@ -152,6 +186,10 @@ macro(__android_compiler_common lang)
__android_stl(CXX)
endif()
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -latomic -lm")
+ endif()
+
# <ndk>/build/core/definitions.mk appends the sysroot's include directory
# explicitly at the end of the command-line include path so that it
# precedes the toolchain's builtin include directories. This is
@@ -161,7 +199,7 @@ macro(__android_compiler_common lang)
#
# Do not do this for a standalone toolchain because it is already
# tied to a specific API version.
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
if(CMAKE_SYSROOT_COMPILE)
set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
else()
@@ -170,7 +208,7 @@ macro(__android_compiler_common lang)
if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES
"${_cmake_sysroot_compile}/usr/include"
- "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}"
+ "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}"
)
else()
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${_cmake_sysroot_compile}/usr/include")
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index bb42eed..e7c1b48 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -198,32 +198,66 @@ if(NOT CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
message(FATAL_ERROR "Android: The API specified by CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}' is not an integer.")
endif()
+if(CMAKE_ANDROID_NDK)
+ # Identify the host platform.
+ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows")
+ endif()
+ else()
+ message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
+ endif()
+
+ # Look for a unified toolchain/sysroot provided with the NDK.
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}")
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+ endif()
+else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+endif()
+
# https://developer.android.com/ndk/guides/abis.html
set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
-set(_ANDROID_ABI_arm64-v8a_HEADER "aarch64-linux-android")
+set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v7a_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi_PROC "armv5te")
set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_armeabi_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_mips_PROC "mips")
set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips_HEADER "mipsel-linux-android")
+set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
set(_ANDROID_ABI_mips64_PROC "mips64")
set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_mips64_HEADER "mips64el-linux-android")
+set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
set(_ANDROID_ABI_x86_PROC "i686")
set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_HEADER "i686-linux-android")
+set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
set(_ANDROID_ABI_x86_64_PROC "x86_64")
set(_ANDROID_ABI_x86_64_ARCH "x86_64")
-set(_ANDROID_ABI_x86_64_HEADER "x86_64-linux-android")
+set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
@@ -308,7 +342,7 @@ if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_
"does not match architecture '${CMAKE_ANDROID_ARCH}' for the ABI '${CMAKE_ANDROID_ARCH_ABI}'."
)
endif()
-set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_HEADER}")
+set(CMAKE_ANDROID_ARCH_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
@@ -321,7 +355,7 @@ if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESS
endif()
if(CMAKE_ANDROID_NDK AND NOT DEFINED CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
- if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}")
+ if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}")
# Unified headers exist so we use them by default.
set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS 0)
else()
@@ -340,8 +374,10 @@ set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
if(CMAKE_ANDROID_NDK)
string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
- "set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE \"${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}\")\n"
+ "set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n"
"set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n"
)
endif()
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index a434f90..a5d2820 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -17,6 +17,13 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
+set(CMAKE_BUILD_TYPE_INIT Debug)
+
+# Skip sysroot selection if the NDK has a unified toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ return()
+endif()
+
if(NOT CMAKE_SYSROOT)
if(CMAKE_ANDROID_NDK)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
@@ -40,5 +47,3 @@ else()
"Android: No CMAKE_SYSROOT was selected."
)
endif()
-
-set(CMAKE_BUILD_TYPE_INIT Debug)
diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
index 5f2cc52..e009c10 100644
--- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
@@ -1,6 +1,31 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+# In Android NDK r19 and above there is a single clang toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "clang")
+ message(FATAL_ERROR
+ "Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}' "
+ "is not supported by this NDK. It must be 'clang' or not set at all."
+ )
+ endif()
+ message(STATUS "Android: Selected unified Clang toolchain")
+ set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "clang")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ return()
+endif()
+
# In Android NDK releases there is build system toolchain selection logic in
# these files:
#
@@ -195,40 +220,16 @@ if(NOT _ANDROID_TOOL_PREFIX AND "${_ANDROID_TOOL_NAME}" MATCHES "^(.*-)[0-9.]+$"
set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
endif()
-# Identify the host platform.
-if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "darwin-x86_64")
- else()
- set(_ANDROID_HOST_DIR "darwin-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "linux-x86_64")
- else()
- set(_ANDROID_HOST_DIR "linux-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
- set(_ANDROID_HOST_DIR "windows-x86_64")
- else()
- set(_ANDROID_HOST_DIR "windows")
- endif()
-else()
- message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
-endif()
-
# Help CMakeFindBinUtils locate things.
set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}")
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "${_ANDROID_HOST_DIR}")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS_NDK}")
# _ANDROID_TOOL_PREFIX should now match `gcc -dumpmachine`.
string(REGEX REPLACE "-$" "" _ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}")
-set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/${_ANDROID_TOOL_PREFIX}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_C_TOOLCHAIN_MACHINE}")
@@ -238,9 +239,9 @@ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
if(_ANDROID_TOOL_CLANG_NAME)
message(STATUS "Android: Selected Clang toolchain '${_ANDROID_TOOL_CLANG_NAME}' with GCC toolchain '${_ANDROID_TOOL_NAME}'")
- set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang${_ANDROID_HOST_EXT}")
- set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR})
- set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG})
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang++${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
else()
message(STATUS "Android: Selected GCC toolchain '${_ANDROID_TOOL_NAME}'")
@@ -267,4 +268,3 @@ unset(_ANDROID_TOOL_PREFIX)
unset(_ANDROID_TOOL_CLANG_NAME)
unset(_ANDROID_TOOL_CLANG_VERS)
unset(_ANDROID_TOOL_LLVM_NAME)
-unset(_ANDROID_HOST_DIR)
diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
index 4c1ac1f..5095aff 100644
--- a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
@@ -62,5 +62,4 @@ else()
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
endif()
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
index a03ebcc..5c6b97b 100644
--- a/Modules/Platform/Android/Determine-Compiler.cmake
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
@@ -40,7 +40,6 @@ if(CMAKE_ANDROID_NDK)
elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
include(Platform/Android/Determine-Compiler-Standalone)
else()
- set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
set(_ANDROID_TOOL_C_COMPILER "")
set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "")
@@ -65,7 +64,6 @@ macro(__android_determine_compiler lang)
# Save the Android-specific information in CMake${lang}Compiler.cmake.
set(CMAKE_${lang}_COMPILER_CUSTOM_CODE "
-set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG}\")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_MACHINE \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_MACHINE}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\")
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 6bce3c7..b01ef61 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -3,7 +3,7 @@ string(APPEND _ANDROID_ABI_INIT_CFLAGS
" -no-canonical-prefixes"
)
-if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
string(APPEND _ANDROID_ABI_INIT_CFLAGS " -D__ANDROID_API__=${CMAKE_SYSTEM_VERSION}")
endif()
diff --git a/Modules/Platform/Apple-XL-C.cmake b/Modules/Platform/Apple-XL-C.cmake
index 2aeb132..e4fc3dd 100644
--- a/Modules/Platform/Apple-XL-C.cmake
+++ b/Modules/Platform/Apple-XL-C.cmake
@@ -1,4 +1,3 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle")
# Enable shared library versioning.
diff --git a/Modules/Platform/Apple-XL-CXX.cmake b/Modules/Platform/Apple-XL-CXX.cmake
index f8e1906..ea330c8 100644
--- a/Modules/Platform/Apple-XL-CXX.cmake
+++ b/Modules/Platform/Apple-XL-CXX.cmake
@@ -1,4 +1,3 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "-bundle")
# Enable shared library versioning.
diff --git a/Modules/Platform/Linux-XL-C.cmake b/Modules/Platform/Linux-XL-C.cmake
index d595e44..ef0c52b 100644
--- a/Modules/Platform/Linux-XL-C.cmake
+++ b/Modules/Platform/Linux-XL-C.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/Linux-XL-CXX.cmake b/Modules/Platform/Linux-XL-CXX.cmake
index 5ceb255..aa57d6e 100644
--- a/Modules/Platform/Linux-XL-CXX.cmake
+++ b/Modules/Platform/Linux-XL-CXX.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/Linux-XL-Fortran.cmake b/Modules/Platform/Linux-XL-Fortran.cmake
index a878991..d9b4c2d 100644
--- a/Modules/Platform/Linux-XL-Fortran.cmake
+++ b/Modules/Platform/Linux-XL-Fortran.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/SunOS-Clang-C.cmake b/Modules/Platform/SunOS-Clang-C.cmake
new file mode 100644
index 0000000..f06eb8f
--- /dev/null
+++ b/Modules/Platform/SunOS-Clang-C.cmake
@@ -0,0 +1 @@
+include(Platform/SunOS-GNU-C)
diff --git a/Modules/Platform/SunOS-Clang-CXX.cmake b/Modules/Platform/SunOS-Clang-CXX.cmake
new file mode 100644
index 0000000..869182c
--- /dev/null
+++ b/Modules/Platform/SunOS-Clang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/SunOS-GNU-CXX)
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index b317da6..84b3a9b 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -8,6 +8,9 @@ if(__WINDOWS_CLANG)
endif()
set(__WINDOWS_CLANG 1)
+set(__pch_header_C "c-header")
+set(__pch_header_CXX "c++-header")
+
macro(__windows_compiler_clang_gnu lang)
set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l")
@@ -44,15 +47,22 @@ macro(__windows_compiler_clang_gnu lang)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto")
+ set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+ set(CMAKE_${lang}_ARCHIVE_CREATE_IPO "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND_IPO "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_FINISH_IPO "<CMAKE_RANLIB> <TARGET>")
+
# Create archiving rules to support large object file lists for static libraries.
set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
- "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>")
+ "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY})
set(CMAKE_${lang}_LINK_EXECUTABLE
- "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
+ "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt)
@@ -73,6 +83,10 @@ macro(__windows_compiler_clang_gnu lang)
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+ set(CMAKE_PCH_EXTENSION .gch)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -include <PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -x ${__pch_header_${lang}} -include <PCH_HEADER>)
+
unset(__ADDED_FLAGS)
unset(__ADDED_FLAGS_DEBUG)
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
@@ -99,6 +113,21 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
"or clang-cl as both C and C++ compilers.")
endif()
+ if(NOT CMAKE_RC_COMPILER_INIT)
+ # Check if rc is already in the path
+ # This may happen in cases where the user is already in a visual studio environment when CMake is invoked
+ find_program(__RC_COMPILER_PATH NAMES rc)
+
+ # Default to rc if it's available, otherwise fall back to llvm-rc
+ if(__RC_COMPILER_PATH)
+ set(CMAKE_RC_COMPILER_INIT rc)
+ else()
+ set(CMAKE_RC_COMPILER_INIT llvm-rc)
+ endif()
+
+ unset(__RC_COMPILER_PATH CACHE)
+ endif()
+
if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" )
include(Platform/Windows-MSVC)
diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake
index 48b936e..370b56e 100644
--- a/Modules/Platform/Windows-Embarcadero.cmake
+++ b/Modules/Platform/Windows-Embarcadero.cmake
@@ -119,6 +119,13 @@ macro(__embarcadero_language lang)
"tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
)
+ # Precompile Headers
+ if (EMBARCADERO)
+ set(CMAKE_PCH_EXTENSION .pch)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
+ endif()
+
# Initial configuration flags.
string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v")
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 7a83859..6ddcaa3 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -329,6 +329,15 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_LINK_EXECUTABLE
"${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+ set(CMAKE_PCH_EXTENSION .pch)
+ set(CMAKE_LINK_PCH ON)
+ if(MSVC_VERSION GREATER_EQUAL 1910)
+ # VS 2017 or greater
+ set(CMAKE_PCH_PROLOGUE "#pragma system_header")
+ endif()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu<PCH_HEADER> /FI<PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc<PCH_HEADER> /FI<PCH_HEADER>)
+
if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake
index d38d616..76cd28b 100644
--- a/Modules/Platform/Windows-OpenWatcom.cmake
+++ b/Modules/Platform/Windows-OpenWatcom.cmake
@@ -10,7 +10,7 @@ set(__WINDOWS_OPENWATCOM 1)
set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
set(CMAKE_LINK_LIBRARY_FLAG "library ")
-set(CMAKE_LINK_LIBRARY_FILE_FLAG "library")
+set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
if(CMAKE_VERBOSE_MAKEFILE)
set(CMAKE_WCL_QUIET)
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 8c25256..43ec889 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -168,9 +168,13 @@ function(ProcessorCount var)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE psrinfo_output)
- string(REGEX MATCH "([0-9]+) virtual processor" procs "${psrinfo_output}")
- set(count "${CMAKE_MATCH_1}")
- #message("ProcessorCount: trying psrinfo -p -v '${ProcessorCount_cmd_prvinfo}'")
+ string(REGEX MATCHALL "has [0-9]+ virtual processor" procs "${psrinfo_output}")
+ set(count "")
+ foreach(proc ${procs})
+ string(REGEX MATCH "has ([0-9]+) virtual" res ${proc})
+ math(EXPR count "${count} + ${CMAKE_MATCH_1}")
+ endforeach()
+ #message("ProcessorCount: trying '${ProcessorCount_cmd_psrinfo}' -p -v")
else()
# Sun (systems where uname -X emits "NumCPU" in its output):
find_program(ProcessorCount_cmd_uname uname)