diff options
19 files changed, 71 insertions, 50 deletions
diff --git a/Help/command/export.rst b/Help/command/export.rst index 0f79f63..2e14a10 100644 --- a/Help/command/export.rst +++ b/Help/command/export.rst @@ -78,6 +78,10 @@ to automatically export the same targets from the build tree as transitive usage requirements of other targets that link to the object libraries in their implementation. +This command exports all :ref:`build configurations` from the build tree. +See the :variable:`CMAKE_MAP_IMPORTED_CONFIG_<CONFIG>` variable to map +configurations of dependent projects to the exported configurations. + Exporting Targets to Android.mk """"""""""""""""""""""""""""""" diff --git a/Help/command/install.rst b/Help/command/install.rst index d5092ae..b56f20c 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -835,6 +835,8 @@ the ``FILE`` option must be a file name with the ``.cmake`` extension. If a ``CONFIGURATIONS`` option is given then the file will only be installed when one of the named configurations is installed. Additionally, the generated import file will reference only the matching target +configurations. See the :variable:`CMAKE_MAP_IMPORTED_CONFIG_<CONFIG>` +variable to map configurations of dependent projects to the installed configurations. The ``EXPORT_LINK_INTERFACE_LIBRARIES`` keyword, if present, causes the contents of the properties matching ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst index 3dab97f..910eacb 100644 --- a/Help/guide/tutorial/Adding Generator Expressions.rst +++ b/Help/guide/tutorial/Adding Generator Expressions.rst @@ -149,8 +149,8 @@ interface library. Lastly, we only want these warning flags to be used during builds. Consumers of our installed project should not inherit our warning flags. To specify -this, we wrap our flags in a generator expression using the ``BUILD_INTERFACE`` -condition. The resulting full code looks like the following: +this, we wrap our flags from TODO 3 in a generator expression using the +``BUILD_INTERFACE`` condition. The resulting full code looks like the following: .. raw:: html diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index 2273063..5e803f5 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -127,7 +127,7 @@ Remove this line: </details> -And the lines: +And remove ``EXTRA_INCLUDES`` from ``target_include_directories``: .. raw:: html @@ -143,23 +143,6 @@ And the lines: </details> -The remaining code looks like: - -.. raw:: html - - <details><summary>Click to show/hide the resulting code</summary> - -.. literalinclude:: Step4/CMakeLists.txt - :caption: Remaining code after removing EXTRA_INCLUDES - :name: CMakeLists.txt-after-removing-EXTRA_INCLUDES - :language: cmake - :start-after: add_subdirectory(MathFunctions) - -.. raw:: html - - </details> - - Notice that with this technique, the only thing our executable target does to use our library is call :command:`target_link_libraries` with the name of the library target. In larger projects, the classic method of specifying @@ -309,8 +292,8 @@ and this: :caption: TODO 7: MathFunctions/CMakeLists.txt :name: MathFunctions-SqrtLibrary-target_link_libraries-step4 :language: cmake - :start-after: target_link_libraries(SqrtLibrary - :end-before: endif() + :start-after: # link our compiler flags interface library + :end-before: target_link_libraries(MathFunctions PUBLIC SqrtLibrary) .. raw:: html diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 694dfaf..178334a 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -96,7 +96,7 @@ a library target called ``MathFunctions`` with :command:`add_library`. The source files for the library are passed as an argument to :command:`add_library`. This looks like the following line: -.. raw:: html/ +.. raw:: html <details><summary>TODO 1: Click to show/hide answer</summary> diff --git a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst index 504e42f..a2f5e2a 100644 --- a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst +++ b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst @@ -44,7 +44,18 @@ SqrtLibrary to be ``True`` when building shared libraries. :caption: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-POSITION_INDEPENDENT_CODE :language: cmake - :lines: 37-42 + :start-at: # state that SqrtLibrary need PIC when the default is shared libraries + :end-at: ) + +Define ``EXPORTING_MYMATH`` stating we are using ``declspec(dllexport)`` when +building on Windows. + +.. literalinclude:: Step11/MathFunctions/CMakeLists.txt + :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-dll-export + :language: cmake + :start-at: # define the symbol stating we are using the declspec(dllexport) when + :end-at: target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") **Exercise**: We modified ``MathFunctions.h`` to use dll export defines. Using CMake documentation can you find a helper module to simplify this? diff --git a/Modules/Compiler/ARMClang-DetermineCompiler.cmake b/Modules/Compiler/ARMClang-DetermineCompiler.cmake index eb0de53..7d1478c 100644 --- a/Modules/Compiler/ARMClang-DetermineCompiler.cmake +++ b/Modules/Compiler/ARMClang-DetermineCompiler.cmake @@ -4,7 +4,7 @@ set(_compiler_id_pp_test "defined(__clang__) && defined(__ARMCOMPILER_VERSION)") set(_compiler_id_version_compute " # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ARMCOMPILER_VERSION/1000000) # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ARMCOMPILER_VERSION/10000 % 100) - # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCOMPILER_VERSION % 10000)") + # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCOMPILER_VERSION/100 % 100)") string(APPEND _compiler_id_version_compute " # define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__ARMCOMPILER_VERSION)") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9722c76..3236afb 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 27) -set(CMake_VERSION_PATCH 20230717) +set(CMake_VERSION_PATCH 20230719) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx index 5d2c208..ada9a5b 100644 --- a/Source/CPack/cmCPackInnoSetupGenerator.cxx +++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx @@ -583,10 +583,8 @@ bool cmCPackInnoSetupGenerator::ProcessComponents() "this script uses components }"); // Installation types - bool noTypes = true; std::vector<cmCPackInstallationType*> types(InstallationTypes.size()); for (auto& i : InstallationTypes) { - noTypes = false; types[i.second.Index - 1] = &i.second; } @@ -601,17 +599,16 @@ bool cmCPackInnoSetupGenerator::ProcessComponents() typeInstructions.push_back(ISKeyValueLine(params)); } - if (!noTypes) { - // Inno Setup requires the "custom" type - cmCPackInnoSetupKeyValuePairs params; + // Inno Setup requires the additional "custom" type + cmCPackInnoSetupKeyValuePairs customTypeParams; - params["Name"] = "\"custom\""; - params["Description"] = "\"{code:CPackGetCustomInstallationMessage}\""; - params["Flags"] = "iscustom"; + customTypeParams["Name"] = "\"custom\""; + customTypeParams["Description"] = + "\"{code:CPackGetCustomInstallationMessage}\""; + customTypeParams["Flags"] = "iscustom"; - allTypes.push_back("custom"); - typeInstructions.push_back(ISKeyValueLine(params)); - } + allTypes.push_back("custom"); + typeInstructions.push_back(ISKeyValueLine(customTypeParams)); // Components std::vector<cmCPackComponent*> downloadedComponents; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index bc59514..735c4ba 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -637,6 +637,8 @@ public: }; StripCommandStyle GetStripCommandStyle(std::string const& strip); + virtual std::string& EncodeLiteral(std::string& lit) { return lit; } + protected: // for a project collect all its targets by following depend // information, and also collect all the targets diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e405909..71084cc 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -181,14 +181,13 @@ std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name) return encoded; } -std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit) +std::string cmGlobalNinjaGenerator::GetEncodedLiteral(const std::string& lit) { std::string result = lit; - EncodeLiteralInplace(result); - return result; + return this->EncodeLiteral(result); } -void cmGlobalNinjaGenerator::EncodeLiteralInplace(std::string& lit) +std::string& cmGlobalNinjaGenerator::EncodeLiteral(std::string& lit) { cmSystemTools::ReplaceString(lit, "$", "$$"); cmSystemTools::ReplaceString(lit, "\n", "$\n"); @@ -196,6 +195,7 @@ void cmGlobalNinjaGenerator::EncodeLiteralInplace(std::string& lit) cmSystemTools::ReplaceString(lit, cmStrCat('$', this->GetCMakeCFGIntDir()), this->GetCMakeCFGIntDir()); } + return lit; } std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path) @@ -207,7 +207,7 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path) else std::replace(result.begin(), result.end(), '/', '\\'); #endif - this->EncodeLiteralInplace(result); + this->EncodeLiteral(result); cmSystemTools::ReplaceString(result, " ", "$ "); cmSystemTools::ReplaceString(result, ":", "$:"); return result; @@ -394,7 +394,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( #endif vars["COMMAND"] = std::move(cmd); } - vars["DESC"] = this->EncodeLiteral(description); + vars["DESC"] = this->GetEncodedLiteral(description); if (restat) { vars["restat"] = "1"; } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 95d64e3..4b026eb 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -77,8 +77,8 @@ public: static void WriteDivider(std::ostream& os); static std::string EncodeRuleName(std::string const& name); - std::string EncodeLiteral(const std::string& lit); - void EncodeLiteralInplace(std::string& lit); + std::string& EncodeLiteral(std::string& lit) override; + std::string GetEncodedLiteral(const std::string& lit); std::string EncodePath(const std::string& path); std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ad4023..cf1eb96 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1431,11 +1431,14 @@ void cmLocalGenerator::GetDeviceLinkFlags( } this->AddVisibilityPresetFlags(linkFlags, target, "CUDA"); + this->GetGlobalGenerator()->EncodeLiteral(linkFlags); std::vector<std::string> linkOpts; target->GetLinkOptions(linkOpts, config, "CUDA"); + this->SetLinkScriptShell(this->GetGlobalGenerator()->GetUseLinkScript()); // LINK_OPTIONS are escaped. this->AppendCompileOptions(linkFlags, linkOpts); + this->SetLinkScriptShell(false); } void cmLocalGenerator::GetTargetFlags( @@ -1501,13 +1504,17 @@ void cmLocalGenerator::GetTargetFlags( } if (!sharedLibFlags.empty()) { + this->GetGlobalGenerator()->EncodeLiteral(sharedLibFlags); linkFlags.emplace_back(std::move(sharedLibFlags)); } std::vector<BT<std::string>> linkOpts = target->GetLinkOptions(config, linkLanguage); + this->SetLinkScriptShell(this->GetGlobalGenerator()->GetUseLinkScript()); // LINK_OPTIONS are escaped. this->AppendCompileOptions(linkFlags, linkOpts); + this->SetLinkScriptShell(false); + if (pcli) { this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, frameworkPath, linkPath); @@ -1581,13 +1588,16 @@ void cmLocalGenerator::GetTargetFlags( } if (!exeFlags.empty()) { + this->GetGlobalGenerator()->EncodeLiteral(exeFlags); linkFlags.emplace_back(std::move(exeFlags)); } std::vector<BT<std::string>> linkOpts = target->GetLinkOptions(config, linkLanguage); + this->SetLinkScriptShell(this->GetGlobalGenerator()->GetUseLinkScript()); // LINK_OPTIONS are escaped. this->AppendCompileOptions(linkFlags, linkOpts); + this->SetLinkScriptShell(false); } break; default: break; @@ -1603,6 +1613,7 @@ void cmLocalGenerator::GetTargetFlags( config); if (!extraLinkFlags.empty()) { + this->GetGlobalGenerator()->EncodeLiteral(extraLinkFlags); linkFlags.emplace_back(std::move(extraLinkFlags)); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1dd48b3..5e3bf61 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -126,8 +126,11 @@ void cmMakefileTargetGenerator::GetDeviceLinkFlags( std::vector<std::string> linkOpts; this->GeneratorTarget->GetLinkOptions(linkOpts, this->GetConfigName(), linkLanguage); + this->LocalGenerator->SetLinkScriptShell( + this->GlobalGenerator->GetUseLinkScript()); // LINK_OPTIONS are escaped. this->LocalGenerator->AppendCompileOptions(linkFlags, linkOpts); + this->LocalGenerator->SetLinkScriptShell(false); } void cmMakefileTargetGenerator::GetTargetLinkFlags( @@ -144,8 +147,11 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags( std::vector<std::string> opts; this->GeneratorTarget->GetLinkOptions(opts, this->GetConfigName(), linkLanguage); + this->LocalGenerator->SetLinkScriptShell( + this->GlobalGenerator->GetUseLinkScript()); // LINK_OPTIONS are escaped. this->LocalGenerator->AppendCompileOptions(flags, opts); + this->LocalGenerator->SetLinkScriptShell(false); this->LocalGenerator->AppendPositionIndependentLinkerFlags( flags, this->GeneratorTarget, this->GetConfigName(), linkLanguage); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 063ca6b..a5280fb 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -952,8 +952,6 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkStatement( this->addPoolNinjaVariable("JOB_POOL_LINK", genTarget, vars); - vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]); - vars["MANIFESTS"] = this->GetManifests(config); vars["LINK_PATH"] = frameworkPath + linkPath; @@ -1271,8 +1269,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( vars["LINK_FLAGS"], this->GetGeneratorTarget(), this->TargetLinkLanguage(config)); - vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]); - vars["MANIFESTS"] = this->GetManifests(config); vars["AIX_EXPORTS"] = this->GetAIXExports(config); diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake new file mode 100644 index 0000000..0f897fe --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_\\$dollar") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_$dollar'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake index bb04841..879151b 100644 --- a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake @@ -53,3 +53,7 @@ target_link_options(LinkOptions_mod PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RE # executable with generator expression add_executable(LinkOptions_exe LinkOptionsExe.c) target_link_options(LinkOptions_exe PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>) + +# executable with dollar character +add_executable(LinkOptions_dollar_exe LinkOptionsExe.c) +target_link_options(LinkOptions_dollar_exe PRIVATE "${pre}BADFLAG_$dollar${obj}") diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 1a29ecf..ff0c5a8 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -30,7 +30,7 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release) run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release) run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release) - + run_cmake_target(LINK_OPTIONS dollar-option LinkOptions_dollar_exe --config Release) run_cmake(genex_LINK_LANGUAGE) |