diff options
25 files changed, 161 insertions, 57 deletions
diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index e6c7a1c..112db74 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -21,8 +21,7 @@ are intended to be run with ``ninja -f build-<Config>.ninja``. A ``cmake --build . --config <Config>`` will always use ``build-<Config>.ninja`` to build. If no ``--config`` argument is specified, ``cmake --build .`` will -default to ``build-Debug.ninja``, unless a ``build.ninja`` is generated (see -below), in which case that will be used instead. +use ``build.ninja``. Each ``build-<Config>.ninja`` file contains ``<target>`` targets as well as ``<target>:<Config>`` targets, where ``<Config>`` is the same as the diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 0f00f53..b345db0 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -174,32 +174,8 @@ source and build trees and generate a buildsystem: The files are a JSON document with an object as the root: - .. code-block:: json - - { - "version": 1, - "cmakeMinimumRequired": { - "major": 3, - "minor": 19, - "patch": 0 - }, - "configurePresets": [ - { - "name": "default", - "displayName": "Default Config", - "description": "Default build using Ninja generator", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/default", - "cacheVariables": [ - { - "name": "MY_CACHE_VARIABLE", - "type": "BOOL", - "value": "OFF" - } - ] - } - ] - } + .. literalinclude:: presets/example.json + :language: json The root object recognizes the following fields: diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json new file mode 100644 index 0000000..a299a06 --- /dev/null +++ b/Help/manual/presets/example.json @@ -0,0 +1,23 @@ +{ + "version": 1, + "cmakeMinimumRequired": { + "major": 3, + "minor": 19, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "displayName": "Default Config", + "description": "Default build using Ninja generator", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/default", + "cacheVariables": { + "MY_CACHE_VARIABLE": { + "type": "BOOL", + "value": "OFF" + } + } + } + ] +} diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index d2ae9df..ea68594 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -189,6 +189,10 @@ Modules * The :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython` modules gained the capability to manage a version range. +* The :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython` + modules provide, respectively, the variable ``Python3_LINK_OPTIONS``, + ``Python2_LINK_OPTIONS`` and ``Python_LINK_OPTIONS`` for link options. + * The :module:`FindSDL` module now provides: * imported target ``SDL::SDL``, diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 2d13f48..5fc6a3b 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -142,6 +142,9 @@ This module will set the following variables in your project System has the Python development artifacts for Python embedding. ``Python_INCLUDE_DIRS`` The Python include directories. +``Python_LINK_OPTIONS`` + The Python link options. Some configurations require specific link options + for a correct build and execution. ``Python_LIBRARIES`` The Python libraries. ``Python_LIBRARY_DIRS`` diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 41b55ee..7de2d29 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -2990,6 +2990,29 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS ${_PYTHON_PREFIX}_PyPy_VERSION "${${_PYTHON_PREFIX}_PyPy_VERSION}") endif() + unset(${_PYTHON_PREFIX}_LINK_OPTIONS) + if (${_PYTHON_PREFIX}_Development.Embed_FOUND AND APPLE + AND ${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$") + # rpath must be specified if python is part of a framework + unset(_${_PYTHON_PREFIX}_is_prefix) + foreach (_${_PYTHON_PREFIX}_implementation IN LISTS _${_PYTHON_PREFIX}_FIND_IMPLEMENTATIONS) + foreach (_${_PYTHON_PREFIX}_framework IN LISTS _${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_implementation}_FRAMEWORKS) + cmake_path (IS_PREFIX _${_PYTHON_PREFIX}_framework "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" _${_PYTHON_PREFIX}_is_prefix) + if (_${_PYTHON_PREFIX}_is_prefix) + cmake_path (GET _${_PYTHON_PREFIX}_framework PARENT_PATH _${_PYTHON_PREFIX}_framework) + set (${_PYTHON_PREFIX}_LINK_OPTIONS "LINKER:-rpath,${_${_PYTHON_PREFIX}_framework}") + break() + endif() + endforeach() + if (_${_PYTHON_PREFIX}_is_prefix) + break() + endif() + endforeach() + unset(_${_PYTHON_PREFIX}_implementation) + unset(_${_PYTHON_PREFIX}_framework) + unset(_${_PYTHON_PREFIX}_is_prefix) + endif() + if (NOT DEFINED ${_PYTHON_PREFIX}_SOABI) _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) endif() @@ -3202,6 +3225,11 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) endif() endif() + + if (${_PYTHON_PREFIX}_LINK_OPTIONS + AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "SHARED") + set_property (TARGET ${__name} PROPERTY INTERFACE_LINK_OPTIONS "${${_PYTHON_PREFIX}_LINK_OPTIONS}") + endif() endmacro() if (${_PYTHON_PREFIX}_Development.Embed_FOUND) diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 97e376d..9cd22e1 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -134,6 +134,9 @@ This module will set the following variables in your project System has the Python 2 development artifacts for Python embedding. ``Python2_INCLUDE_DIRS`` The Python 2 include directories. +``Python2_LINK_OPTIONS`` + The Python 2 link options. Some configurations require specific link options + for a correct build and execution. ``Python2_LIBRARIES`` The Python 2 libraries. ``Python2_LIBRARY_DIRS`` diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 266b50a..c79d482 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -143,6 +143,9 @@ This module will set the following variables in your project System has the Python 3 development artifacts for Python embedding. ``Python3_INCLUDE_DIRS`` The Python 3 include directories. +``Python3_LINK_OPTIONS`` + The Python 3 link options. Some configurations require specific link options + for a correct build and execution. ``Python3_LIBRARIES`` The Python 3 libraries. ``Python3_LIBRARY_DIRS`` diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 314d80b..f7d8d13 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -353,6 +353,12 @@ if(NOT CMAKE_ANDROID_ARCH_ABI) endif() endif() endif() +if(_INCLUDED_ABIS AND NOT CMAKE_ANDROID_ARCH_ABI IN_LIST NDK_DEFAULT_ABIS) + message(FATAL_ERROR + "Android: ABI '${CMAKE_ANDROID_ARCH_ABI}' is not supported by the NDK.\n" + "Supported ABIS: ${NDK_DEFAULT_ABIS}." + ) +endif() set(CMAKE_ANDROID_ARCH "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_ARCH}") if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_ANDROID_ARCH}") message(FATAL_ERROR @@ -406,7 +412,8 @@ if(CMAKE_SYSTEM_VERSION) if(CMAKE_SYSTEM_VERSION GREATER NDK_MAX_PLATFORM_LEVEL OR CMAKE_SYSTEM_VERSION LESS NDK_MIN_PLATFORM_LEVEL) message(FATAL_ERROR - "Android: The API level ${CMAKE_SYSTEM_VERSION} is not supported by the NDK." + "Android: The API level ${CMAKE_SYSTEM_VERSION} is not supported by the NDK.\n" + "Choose one in the range of [${NDK_MIN_PLATFORM_LEVEL}, ${NDK_MAX_PLATFORM_LEVEL}]." ) endif() else() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a0462a4..1057aea 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 19) -set(CMake_VERSION_PATCH 20201009) +set(CMake_VERSION_PATCH 20201013) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 6b9a0f3..985f430 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2532,14 +2532,14 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams() return false; } - if (!this->DefaultFileConfig.empty()) { - if (!this->OpenFileStream(this->DefaultFileStream, NINJA_BUILD_FILE)) { - return false; - } - *this->DefaultFileStream - << "# Build using rules for '" << this->DefaultFileConfig << "'.\n\n" - << "include " << GetNinjaImplFilename(this->DefaultFileConfig) << "\n\n"; + if (!this->OpenFileStream(this->DefaultFileStream, NINJA_BUILD_FILE)) { + return false; } + *this->DefaultFileStream << "# Build using rules for '" + << this->DefaultFileConfig << "'.\n\n" + << "include " + << GetNinjaImplFilename(this->DefaultFileConfig) + << "\n\n"; // Write a comment about this file. *this->CommonFileStream diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 83609e2..b99e6a3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -461,6 +461,27 @@ bool HandleTargetsMode(std::vector<std::string> const& args, std::unique_ptr<cmInstallFilesGenerator> publicHeaderGenerator; std::unique_ptr<cmInstallFilesGenerator> resourceGenerator; + auto addTargetExport = [&]() { + // Add this install rule to an export if one was specified. + if (!exports.empty()) { + auto te = cm::make_unique<cmTargetExport>(); + te->TargetName = target.GetName(); + te->ArchiveGenerator = archiveGenerator.get(); + te->BundleGenerator = bundleGenerator.get(); + te->FrameworkGenerator = frameworkGenerator.get(); + te->HeaderGenerator = publicHeaderGenerator.get(); + te->LibraryGenerator = libraryGenerator.get(); + te->RuntimeGenerator = runtimeGenerator.get(); + te->ObjectsGenerator = objectGenerator.get(); + te->InterfaceIncludeDirectories = + cmJoin(includesArgs.GetIncludeDirs(), ";"); + + helper.Makefile->GetGlobalGenerator() + ->GetExportSets()[exports] + .AddTargetExport(std::move(te)); + } + }; + // Avoid selecting default destinations for PUBLIC_HEADER and // PRIVATE_HEADER if any artifacts are specified. bool artifactsSpecified = false; @@ -476,6 +497,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsDLLPlatform()) { // When in namelink only mode skip all libraries on Windows. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -507,6 +529,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -551,6 +574,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + addTargetExport(); continue; } @@ -744,25 +768,8 @@ bool HandleTargetsMode(std::vector<std::string> const& args, } } - // Add this install rule to an export if one was specified and - // this is not a namelink-only rule. - if (!exports.empty() && !namelinkOnly) { - auto te = cm::make_unique<cmTargetExport>(); - te->TargetName = target.GetName(); - te->ArchiveGenerator = archiveGenerator.get(); - te->BundleGenerator = bundleGenerator.get(); - te->FrameworkGenerator = frameworkGenerator.get(); - te->HeaderGenerator = publicHeaderGenerator.get(); - te->LibraryGenerator = libraryGenerator.get(); - te->RuntimeGenerator = runtimeGenerator.get(); - te->ObjectsGenerator = objectGenerator.get(); - te->InterfaceIncludeDirectories = - cmJoin(includesArgs.GetIncludeDirs(), ";"); - - helper.Makefile->GetGlobalGenerator() - ->GetExportSets()[exports] - .AddTargetExport(std::move(te)); - } + // Add this install rule to an export if one was specified. + addTargetExport(); // Keep track of whether we're installing anything in each category installsArchive = installsArchive || archiveGenerator; diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake index 81dd090..c4b1a00 100644 --- a/Tests/RunCMake/Android/RunCMakeTest.cmake +++ b/Tests/RunCMake/Android/RunCMakeTest.cmake @@ -157,7 +157,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) # Find a sysroot to test. file(GLOB _sysroots "${ndk}/platforms/android-[0-9][0-9]/arch-arm") - if(_sysroots) + if(_sysroots AND "armeabi" IN_LIST _abis_) list(GET _sysroots 0 _sysroot) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android diff --git a/Tests/RunCMake/CMakePresets/DocumentationExample.cmake b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake new file mode 100644 index 0000000..1f2fc00 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(MY_CACHE_VARIABLE "BOOL" "OFF") diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 4b430b3..18ea093 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.19) # CMP0053 + include(RunCMake) # Fix Visual Studio generator name @@ -214,3 +216,10 @@ unset(CMakePresets_WARN_UNUSED_CLI) set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in") run_cmake_presets(NoDebug) run_cmake_presets(Debug) + +# Test the example from the documentation +file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) +string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}") +file(WRITE "${RunCMake_BINARY_DIR}/example.json.in" "${_example}") +set(CMakePresets_FILE "${RunCMake_BINARY_DIR}/example.json.in") +run_cmake_presets(DocumentationExample --preset=default) diff --git a/Tests/RunCMake/export/NamelinkOnlyExport.cmake b/Tests/RunCMake/export/NamelinkOnlyExport.cmake new file mode 100644 index 0000000..4bdd180 --- /dev/null +++ b/Tests/RunCMake/export/NamelinkOnlyExport.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +add_library(foo SHARED empty.cpp) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 1c74762..95c8d5c 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -15,3 +15,5 @@ run_cmake(ForbiddenToExportPropertyWithGenExp) run_cmake(ExportPropertiesUndefined) run_cmake(DependOnNotExport) run_cmake(DependOnDoubleExport) +run_cmake(UnknownExport) +run_cmake(NamelinkOnlyExport) diff --git a/Tests/RunCMake/export/UnknownExport-result.txt b/Tests/RunCMake/export/UnknownExport-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/UnknownExport-stderr.txt b/Tests/RunCMake/export/UnknownExport-stderr.txt new file mode 100644 index 0000000..a8f8453 --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at UnknownExport\.cmake:[0-9]+ \(export\): + export Export set "fooExport" not found\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/UnknownExport.cmake b/Tests/RunCMake/export/UnknownExport.cmake new file mode 100644 index 0000000..bf82d1f --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake new file mode 100644 index 0000000..1c310d1 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake @@ -0,0 +1,12 @@ +enable_language(C) +add_library(foo SHARED empty.c) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt new file mode 100644 index 0000000..bd49fa2 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt @@ -0,0 +1 @@ +CMake Error: INSTALL\(EXPORT\) given unknown export "fooExport" diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport.cmake b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake new file mode 100644 index 0000000..2dbba4e --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake @@ -0,0 +1,5 @@ +enable_language(C) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 3573fbd..5aab88c 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -76,6 +76,8 @@ run_cmake(DIRECTORY-DESTINATION-bad) run_cmake(FILES-DESTINATION-bad) run_cmake(TARGETS-DESTINATION-bad) run_cmake(EXPORT-OldIFace) +run_cmake(EXPORT-UnknownExport) +run_cmake(EXPORT-NamelinkOnly) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) |