diff options
39 files changed, 202 insertions, 131 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 77f42a1..ca8fc77 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -12,12 +12,12 @@ Try Compiling Whole Projects .. code-block:: cmake - try_compile(RESULT_VAR <bindir> <srcdir> + try_compile(<resultVar> <bindir> <srcdir> <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] [OUTPUT_VARIABLE <var>]) Try building a project. The success or failure of the ``try_compile``, -i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``RESULT_VAR``. +i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``. In this form, ``<srcdir>`` should contain a complete CMake project with a ``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>`` @@ -30,7 +30,7 @@ Try Compiling Source Files .. code-block:: cmake - try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...> + try_compile(<resultVar> <bindir> <srcfile|SOURCES srcfile...> [CMAKE_FLAGS <flags>...] [COMPILE_DEFINITIONS <defs>...] [LINK_OPTIONS <options>...] @@ -42,13 +42,19 @@ Try Compiling Source Files [<LANG>_EXTENSIONS <bool>] ) -Try building an executable from one or more source files. The success or -failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is -returned in ``RESULT_VAR``. +Try building an executable or static library from one or more source files +(which one is determined by the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` +variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or +``FALSE`` respectively, is returned in ``<resultVar>``. -In this form the user need only supply one or more source files that include a -definition for ``main``. CMake will create a ``CMakeLists.txt`` file to build -the source(s) as an executable that looks something like this: +In this form, one or more source files must be provided. If +:variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``, +the sources must include a definition for ``main`` and CMake will create a +``CMakeLists.txt`` file to build the source(s) as an executable. +If :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``STATIC_LIBRARY``, +a static library will be built instead and no definition for ``main`` is +required. For an executable, the generated ``CMakeLists.txt`` file would +contain something like the following: .. code-block:: cmake @@ -73,7 +79,7 @@ The options are: in the generated test project. ``COPY_FILE <fileName>`` - Copy the linked executable to the given ``<fileName>``. + Copy the built executable or static library to the given ``<fileName>``. ``COPY_FILE_ERROR <var>`` Use after ``COPY_FILE`` to capture into variable ``<var>`` any error @@ -88,12 +94,12 @@ The options are: given to the ``CMAKE_FLAGS`` option will be ignored. ``LINK_OPTIONS <options>...`` - Specify link step options to pass to :command:`target_link_options` or - to :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated - project, depending of the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable. + Specify link step options to pass to :command:`target_link_options` or to + set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated + project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable. ``OUTPUT_VARIABLE <var>`` - Store the output from the build process the given variable. + Store the output from the build process in the given variable. ``<LANG>_STANDARD <std>`` Specify the :prop_tgt:`C_STANDARD`, :prop_tgt:`CXX_STANDARD`, @@ -114,7 +120,7 @@ passed to ``cmake`` to avoid this clean. However, multiple sequential ``try_compile`` operations reuse this single output directory. If you use ``--debug-trycompile``, you can only debug one ``try_compile`` call at a time. The recommended procedure is to protect all ``try_compile`` calls in your -project by ``if(NOT DEFINED RESULT_VAR)`` logic, configure with cmake +project by ``if(NOT DEFINED <resultVar>)`` logic, configure with cmake all the way through once, then delete the cache entry associated with the try_compile call of interest, and then re-run cmake again with ``--debug-trycompile``. @@ -139,8 +145,8 @@ behavior at link time, the ``check_pie_supported()`` command from the :module:`CheckPIESupported` module must be called before using the :command:`try_compile` command. -The current settings of :policy:`CMP0065` and :policy:`CMP0083` are set in the -generated project. +The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated +through to the generated test project. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. @@ -150,7 +156,9 @@ the type of target used for the source file signature. Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify variables that must be propagated into the test project. This variable is -meant for use only in toolchain files. +meant for use only in toolchain files and is only honored by the +``try_compile()`` command for the source files form, not when given a whole +project. If :policy:`CMP0067` is set to ``NEW``, or any of the ``<LANG>_STANDARD``, ``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used, diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index 137402f..d401ebe 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -12,8 +12,8 @@ Try Compiling and Running Source Files .. code-block:: cmake - try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR - bindir srcfile [CMAKE_FLAGS <flags>...] + try_run(<runResultVar> <compileResultVar> + <bindir> <srcfile> [CMAKE_FLAGS <flags>...] [COMPILE_DEFINITIONS <defs>...] [LINK_OPTIONS <options>...] [LINK_LIBRARIES <libs>...] @@ -23,9 +23,9 @@ Try Compiling and Running Source Files [ARGS <args>...]) Try compiling a ``<srcfile>``. Returns ``TRUE`` or ``FALSE`` for success -or failure in ``COMPILE_RESULT_VAR``. If the compile succeeded, runs the -executable and returns its exit code in ``RUN_RESULT_VAR``. If the -executable was built, but failed to run, then ``RUN_RESULT_VAR`` will be +or failure in ``<compileResultVar>``. If the compile succeeded, runs the +executable and returns its exit code in ``<runResultVar>``. If the +executable was built, but failed to run, then ``<runResultVar>`` will be set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for information on how the test project is constructed to build the source file. @@ -85,10 +85,10 @@ presetting them in some CMake script file to the values the executable would have produced if it had been run on its actual target platform. These cache entries are: -``<RUN_RESULT_VAR>`` +``<runResultVar>`` Exit code if the executable were to be run on the target platform. -``<RUN_RESULT_VAR>__TRYRUN_OUTPUT`` +``<runResultVar>__TRYRUN_OUTPUT`` Output from stdout and stderr if the executable were to be run on the target platform. This is created only if the ``RUN_OUTPUT_VARIABLE`` or ``OUTPUT_VARIABLE`` option was used. diff --git a/Help/policy/CMP0083.rst b/Help/policy/CMP0083.rst index b26d6c8..32acf1f 100644 --- a/Help/policy/CMP0083.rst +++ b/Help/policy/CMP0083.rst @@ -23,9 +23,10 @@ which it is used, it is the project's responsibility to use the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property for executables will be honored at link time. -This policy was introduced in CMake version 3.14. CMake version -|release| warns when the policy is not set and uses ``OLD`` behavior. Use -the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +This policy was introduced in CMake version 3.14. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike most policies, CMake version |release| does not warn when this policy is +not set and simply uses ``OLD`` behavior. .. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst index e7457e1..0eee297 100644 --- a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst @@ -6,8 +6,16 @@ Exclude the target from the all target. A property on a target that indicates if the target is excluded from the default build target. If it is not, then with a Makefile for example typing make will cause this target to be built. The same -concept applies to the default build of other generators. Installing -a target with EXCLUDE_FROM_ALL set to true has undefined behavior. +concept applies to the default build of other generators. + +With ``EXCLUDE_FROM_ALL`` set to false or not set at all, the target +will be brought up to date as part of doing a ``make install`` or its +equivalent for the CMake generator being used. If a target has +``EXCLUDE_FROM_ALL`` set to true, then any attempt to install that +target has undefined behavior. Note that such a target can still safely +be listed in an :command:`install(TARGETS)` command as long as the install +components the target belongs to are not part of the set of components +that anything tries to install. This property is enabled by default for targets that are created in directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``. diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst index a04005c..0246071 100644 --- a/Help/release/3.14.rst +++ b/Help/release/3.14.rst @@ -166,6 +166,11 @@ Modules :command:`check_fortran_source_runs` command to check if a Fortran source snippet compiles and runs. +* The :module:`CMakePackageConfigHelpers` module's + :command:`write_basic_package_version_file` command gained a new + ``ARCH_INDEPENDENT`` option for supporting architecture-independent + packages. + * The :module:`ExternalProject` module :command:`ExternalProject_Add` command gained ``LOG_DIR`` and ``LOG_MERGED_STDOUTERR`` options to control logging. @@ -370,3 +375,7 @@ Other Changes :variable:`CPACK_DEBIAN_ARCHIVE_TYPE` variable, because ``dpkg`` has never supported the PAX tar format. The ``paxr`` value will be mapped to ``gnutar`` and a deprecation message emitted. + +* CMake no longer issues a warning if a target listed in an + :command:`install(TARGETS)` command has its :prop_tgt:`EXCLUDE_FROM_ALL` + property set to true. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst index cc80851..e361fd9 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst @@ -6,4 +6,9 @@ Directories implicitly searched by the compiler for header files. CMake does not explicitly specify these directories on compiler command lines for language ``<LANG>``. This prevents system include directories from being treated as user include directories on some -compilers. +compilers, which is important for ``C``, ``CXX``, and ``CUDA`` to +avoid overriding standard library headers. + +This value is not used for ``Fortran`` because it has no standard +library headers and some compilers do not search their implicit +include directories for module ``.mod`` files. diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake index 7db976b..5e3f195 100644 --- a/Modules/CheckCXXSourceRuns.cmake +++ b/Modules/CheckCXXSourceRuns.cmake @@ -103,7 +103,8 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" - COMPILE_OUTPUT_VARIABLE OUTPUT) + COMPILE_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE RUN_OUTPUT) # if it did not compile make the return value fail code of 1 if(NOT ${VAR}_COMPILED) @@ -118,6 +119,8 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" "Return value: ${${VAR}}\n" "Source file was:\n${SOURCE}\n") else() @@ -133,6 +136,8 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" "Return value: ${${VAR}_EXITCODE}\n" "Source file was:\n${SOURCE}\n") endif() diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index 13fdb0b..a80c13d 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -133,7 +133,8 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}" - COMPILE_OUTPUT_VARIABLE OUTPUT) + COMPILE_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE RUN_OUTPUT) # if it did not compile make the return value fail code of 1 if(NOT ${VAR}_COMPILED) @@ -148,6 +149,8 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n" "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" "Return value: ${${VAR}}\n" "Source file was:\n${SOURCE}\n") else() @@ -163,6 +166,8 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" "Return value: ${${VAR}_EXITCODE}\n" "Source file was:\n${SOURCE}\n") endif() @@ -57,12 +57,19 @@ You need to have a C++ compiler (supporting C++11) and a ``make`` installed. Run the ``bootstrap`` script you find in the source directory of CMake. You can use the ``--help`` option to see the supported options. You may use the ``--prefix=<install_prefix>`` option to specify a custom -installation directory for CMake. You can run the ``bootstrap`` script from -within the CMake source directory or any other build directory of your -choice. Once this has finished successfully, run ``make`` and -``make install``. In summary:: +installation directory for CMake. Once this has finished successfully, +run ``make`` and ``make install``. - $ ./bootstrap && make && sudo make install +For example, if you simply want to build and install CMake from source, +you can build directly in the source tree:: + + $ ./bootstrap && make && sudo make install + +Or, if you plan to develop CMake or otherwise run the test suite, create +a separate build tree:: + + $ mkdir cmake-build && cd cmake-build + $ ../cmake-source/bootstrap && make Windows ^^^^^^^ @@ -79,9 +86,7 @@ There are two ways for building CMake under Windows: $ pacman -S --needed git base-devel mingw-w64-x86_64-gcc - and bootstrap as above:: - - $ ./bootstrap && make + and bootstrap as above. .. _`CMake Download Page`: https://cmake.org/cmake/resources/software.html .. _`MSYS2`: https://www.msys2.org/ diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b324571..5c07a8b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 20190220) +set(CMake_VERSION_PATCH 20190225) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 575254e..127bcf9 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1255,9 +1255,8 @@ bool cmCPackGenerator::ConfigureFile(const std::string& inName, int cmCPackGenerator::CleanTemporaryDirectory() { - std::string tempInstallDirectoryWithPostfix = + std::string tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); - const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str(); if (cmsys::SystemTools::FileExists(tempInstallDirectory)) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Clean temporary : " << tempInstallDirectory << std::endl); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index b154caf..83aeb64 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -365,7 +365,7 @@ bool cmCTestBZR::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c75f4d4..07bc7e7 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -418,8 +418,8 @@ int cmCTestBuildHandler::ProcessHandler() int retVal = 0; int res = cmsysProcess_State_Exited; if (!this->CTest->GetShowOnly()) { - res = this->RunMakeCommand(makeCommand.c_str(), &retVal, - buildDirectory.c_str(), 0, ofs); + res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0, + ofs); } else { cmCTestOptionalLog(this->CTest, DEBUG, "Build with command: " << makeCommand << std::endl, @@ -766,9 +766,10 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers( } } -int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, - const char* dir, int timeout, - std::ostream& ofs, Encoding encoding) +int cmCTestBuildHandler::RunMakeCommand(const std::string& command, + int* retVal, const char* dir, + int timeout, std::ostream& ofs, + Encoding encoding) { // First generate the command and arguments std::vector<std::string> args = cmSystemTools::ParseArguments(command); diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index a9b121b..722c590 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -52,7 +52,7 @@ private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. - int RunMakeCommand(const char* command, int* retVal, const char* dir, + int RunMakeCommand(const std::string& command, int* retVal, const char* dir, int timeout, std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 6e8f73f..9c03839 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -78,7 +78,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 6b7601b..7e93189 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -61,7 +61,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand << std::endl, this->Quiet); - res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal, + res = this->CTest->RunMakeCommand(cCommand, output, &retVal, buildDirectory.c_str(), cmDuration::zero(), ofs); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 4dda9ad..d76bd2a 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1004,7 +1004,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( static_cast<void>(locale_C); std::vector<std::string> basecovargs = - cmSystemTools::ParseArguments(gcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(gcovExtraFlags); basecovargs.insert(basecovargs.begin(), gcovCommand); basecovargs.emplace_back("-o"); @@ -1377,7 +1377,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( static_cast<void>(locale_C); std::vector<std::string> covargs = - cmSystemTools::ParseArguments(lcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(lcovExtraFlags); covargs.insert(covargs.begin(), lcovCommand); const std::string command = joinCommandLine(covargs); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 210abe5..11cd005 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -162,7 +162,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { git_fetch.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 6fb99d8..727c59c 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -144,7 +144,7 @@ bool cmCTestHG::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { hg_update.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 954f5bb..22c8469 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -520,7 +520,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->CTest->GetCTestConfiguration("ValgrindCommandOptions"); } this->MemoryTesterOptions = - cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); + cmSystemTools::ParseArguments(memoryTesterOptions); this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log"; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index ac4753c..315f498 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -324,8 +324,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions) // The CTEST_P4_OPTIONS variable adds additional Perforce command line // options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector<std::string> args = - cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); P4Options.insert(P4Options.end(), args.begin(), args.end()); } @@ -501,7 +500,7 @@ bool cmCTestP4::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { p4_sync.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 3bf66ca..b7a4e4c 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -242,7 +242,7 @@ bool cmCTestSVN::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { @@ -277,7 +277,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); std::vector<std::string> parsedUserOptions = - cmSystemTools::ParseArguments(userOptions.c_str()); + cmSystemTools::ParseArguments(userOptions); for (std::string const& opt : parsedUserOptions) { args.push_back(opt.c_str()); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index ba2fe6c..c77bb97 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1009,7 +1009,7 @@ int cmCTest::GetTestModelFromString(const char* str) //###################################################################### //###################################################################### -int cmCTest::RunMakeCommand(const char* command, std::string& output, +int cmCTest::RunMakeCommand(const std::string& command, std::string& output, int* retVal, const char* dir, cmDuration timeout, std::ostream& ofs, Encoding encoding) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 7dbf4d5..a765fed 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -280,8 +280,9 @@ public: * Run command specialized for make and configure. Returns process status * and retVal is return value or exception. */ - int RunMakeCommand(const char* command, std::string& output, int* retVal, - const char* dir, cmDuration timeout, std::ostream& ofs, + int RunMakeCommand(const std::string& command, std::string& output, + int* retVal, const char* dir, cmDuration timeout, + std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); /** Return the current tag */ diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index abddc82..44d8615 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1266,7 +1266,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) void cmComputeLinkInformation::AddDirectoryItem(std::string const& item) { if (this->Makefile->IsOn("APPLE") && - cmSystemTools::IsPathToFramework(item.c_str())) { + cmSystemTools::IsPathToFramework(item)) { this->AddFrameworkItem(item); } else { this->DropDirectoryItem(item); diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 8cb666a..36651af 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -67,7 +67,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args, std::string command; if (!arguments.empty()) { - command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str()); + command = cmSystemTools::ConvertToRunCommandPath(args[0]); command += " "; command += arguments; } else { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6f5e9bd..3f23e5a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -510,21 +510,10 @@ const char* cmGeneratorTarget::GetLinkPIEProperty( return nullptr; } - switch (this->GetPolicyStatusCMP0083()) { - case cmPolicies::WARN: { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0083); - this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - CM_FALLTHROUGH; - } - case cmPolicies::OLD: - return nullptr; - default: - // nothing to do - break; - } - - return PICValue.c_str(); + auto status = this->GetPolicyStatusCMP0083(); + return (status != cmPolicies::WARN && status != cmPolicies::OLD) + ? PICValue.c_str() + : nullptr; } bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index c63e01a..9f8f12b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -210,7 +210,7 @@ void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout, if (flagsByLangI != this->FlagsByLanguage.end()) { if (!flagsByLangI->second.empty()) { std::vector<std::string> ghsCompFlags = - cmSystemTools::ParseArguments(flagsByLangI->second.c_str()); + cmSystemTools::ParseArguments(flagsByLangI->second); for (auto& f : ghsCompFlags) { fout << " " << f << std::endl; } @@ -265,16 +265,14 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, frameworkPath, linkPath, this->GeneratorTarget); // write out link options - std::vector<std::string> lopts = - cmSystemTools::ParseArguments(linkFlags.c_str()); + std::vector<std::string> lopts = cmSystemTools::ParseArguments(linkFlags); for (auto& l : lopts) { fout << " " << l << std::endl; } // write out link search paths // must be quoted for paths that contain spaces - std::vector<std::string> lpath = - cmSystemTools::ParseArguments(linkPath.c_str()); + std::vector<std::string> lpath = cmSystemTools::ParseArguments(linkPath); for (auto& l : lpath) { fout << " -L\"" << l << "\"" << std::endl; } @@ -284,7 +282,7 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, std::string cbd = this->LocalGenerator->GetCurrentBinaryDirectory(); std::vector<std::string> llibs = - cmSystemTools::ParseArguments(linkLibraries.c_str()); + cmSystemTools::ParseArguments(linkLibraries); for (auto& l : llibs) { if (l.compare(0, 2, "-l") == 0) { fout << " \"" << l << "\"" << std::endl; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index daec0eb..ab8d670 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2197,7 +2197,7 @@ cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget( bool cmGlobalGenerator::NameResolvesToFramework( const std::string& libname) const { - if (cmSystemTools::IsPathToFramework(libname.c_str())) { + if (cmSystemTools::IsPathToFramework(libname)) { return true; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7053e99..4fefe23 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -41,22 +41,6 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( cmInstallTargetGenerator::~cmInstallTargetGenerator() = default; -void cmInstallTargetGenerator::GenerateScript(std::ostream& os) -{ - // Warn if installing an exclude-from-all target. - if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - std::ostringstream msg; - msg << "WARNING: Target \"" << this->Target->GetName() - << "\" has EXCLUDE_FROM_ALL set and will not be built by default " - << "but an install rule has been provided for it. CMake does " - << "not define behavior for this case."; - cmSystemTools::Message(msg.str(), "Warning"); - } - - // Perform the main install script generation. - this->cmInstallGenerator::GenerateScript(os); -} - void cmInstallTargetGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent indent) { diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 715b4ae..6df5b1a 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -69,7 +69,6 @@ public: cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; } protected: - void GenerateScript(std::ostream& os) override; void GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent indent) override; void GenerateScriptForConfigObjectLibrary(std::ostream& os, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 90f1c00..a14fd7d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -776,7 +776,7 @@ std::string cmLocalGenerator::GetIncludeFlags( #endif for (std::string const& i : includes) { if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && - cmSystemTools::IsPathToFramework(i.c_str())) { + cmSystemTools::IsPathToFramework(i)) { std::string frameworkDir = i; frameworkDir += "/../"; frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); @@ -944,15 +944,21 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( std::vector<std::string> impDirVec = userStandardDirs; // Load implicit include directories for this language. - std::string key = "CMAKE_"; - key += lang; - key += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if (const char* value = this->Makefile->GetDefinition(key)) { - size_t const impDirVecOldSize = impDirVec.size(); - cmSystemTools::ExpandListArgument(value, impDirVec); - // FIXME: Use cmRange with 'advance()' when it supports non-const. - for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { - cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); + // We ignore this for Fortran because: + // * There are no standard library headers to avoid overriding. + // * Compilers like gfortran do not search their own implicit include + // directories for modules ('.mod' files). + if (lang != "Fortran") { + std::string key = "CMAKE_"; + key += lang; + key += "_IMPLICIT_INCLUDE_DIRECTORIES"; + if (const char* value = this->Makefile->GetDefinition(key)) { + size_t const impDirVecOldSize = impDirVec.size(); + cmSystemTools::ExpandListArgument(value, impDirVec); + // FIXME: Use cmRange with 'advance()' when it supports non-const. + for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { + cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); + } } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 3264237..b38d410 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -283,6 +283,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()); vars.Language = this->TargetLinkLanguage.c_str(); + if (this->TargetLinkLanguage == "Swift") { + vars.SwiftPartialModules = "$SWIFT_PARTIAL_MODULES"; + vars.TargetSwiftModule = "$TARGET_SWIFT_MODULE"; + vars.TargetSwiftDoc = "$TARGET_SWIFT_DOC"; + } std::string responseFlag; if (!useResponseFile) { @@ -787,6 +792,34 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps outputs; outputs.push_back(targetOutputReal); + if (this->TargetLinkLanguage == "Swift") { + if (const char* name = gt.GetProperty("SWIFT_MODULE_NAME")) { + vars["TARGET_SWIFT_DOC"] = std::string(name) + ".swiftdoc"; + vars["TARGET_SWIFT_MODULE"] = std::string(name) + ".swiftmodule"; + } else { + vars["TARGET_SWIFT_DOC"] = gt.GetName() + ".swiftdoc"; + vars["TARGET_SWIFT_MODULE"] = gt.GetName() + ".swiftmodule"; + } + outputs.push_back(vars["TARGET_SWIFT_DOC"]); + outputs.push_back(vars["TARGET_SWIFT_MODULE"]); + + cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); + + std::string partials; + std::vector<cmSourceFile const*> sources; + gt.GetObjectSources(sources, this->GetConfigName()); + for (cmSourceFile const* source : sources) { + partials += " "; + if (const char* partial = source->GetProperty("SWIFT_PARTIAL_MODULE")) { + partials += partial; + } else { + partials += localGen.GetTargetDirectory(>) + "/" + + gt.GetObjectName(source) + ".swiftmodule"; + } + } + vars["SWIFT_PARTIAL_MODULES"] = partials; + } + // Compute specific libraries to link with. cmNinjaDeps explicitDeps = this->GetObjects(); cmNinjaDeps implicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage); diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 18d00b1..309ee30 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -187,6 +187,21 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.SwiftPartialModule; } } + if (replaceValues.SwiftPartialModules) { + if (variable == "SWIFT_PARTIAL_MODULES") { + return replaceValues.SwiftPartialModules; + } + } + if (replaceValues.TargetSwiftDoc) { + if (variable == "TARGET_SWIFT_DOC") { + return replaceValues.TargetSwiftDoc; + } + } + if (replaceValues.TargetSwiftModule) { + if (variable == "TARGET_SWIFT_MODULE") { + return replaceValues.TargetSwiftModule; + } + } if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" || variable == "TARGET_INSTALLNAME_DIR") { // All these variables depend on TargetSOName diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index 93d0577..ebd4d41 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -63,6 +63,9 @@ public: const char* SwiftLibraryName; const char* SwiftPartialModule; const char* SwiftPartialDoc; + const char* TargetSwiftModule; + const char* TargetSwiftDoc; + const char* SwiftPartialModules; }; // Expand rule variables in CMake of the type found in language rules diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1ca2360..2392473 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -571,13 +571,14 @@ std::vector<std::string> cmSystemTools::HandleResponseFile( return arg_full; } -std::vector<std::string> cmSystemTools::ParseArguments(const char* command) +std::vector<std::string> cmSystemTools::ParseArguments(const std::string& cmd) { std::vector<std::string> args; std::string arg; bool win_path = false; + const char* command = cmd.c_str(); if (command[0] && command[1] && ((command[0] != '/' && command[1] == ':' && command[2] == '\\') || (command[0] == '\"' && command[1] != '/' && command[2] == ':' && @@ -878,8 +879,7 @@ bool cmSystemTools::RunSingleCommand(const std::string& command, outputflag = OUTPUT_NONE; } - std::vector<std::string> args = - cmSystemTools::ParseArguments(command.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if (args.empty()) { return false; @@ -1411,7 +1411,7 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path) #endif } -std::string cmSystemTools::ConvertToRunCommandPath(const char* path) +std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path) { #if defined(_WIN32) && !defined(__CYGWIN__) return cmSystemTools::ConvertToWindowsOutputPath(path); @@ -1614,7 +1614,7 @@ void cmSystemTools::EnableVSConsoleOutput() #endif } -bool cmSystemTools::IsPathToFramework(const char* path) +bool cmSystemTools::IsPathToFramework(const std::string& path) { return (cmSystemTools::FileIsFullPath(path) && cmHasLiteralSuffix(path, ".framework")); @@ -3005,7 +3005,7 @@ bool cmSystemTools::CheckRPath(std::string const& file, #endif } -bool cmSystemTools::RepeatedRemoveDirectory(const char* dir) +bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) { // Windows sometimes locks files temporarily so try a few times. for (int i = 0; i < 10; ++i) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 82e4f01..60e8c18 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -141,7 +141,7 @@ public: ///! Return true if value is NOTFOUND or ends in -NOTFOUND. static bool IsNOTFOUND(const char* value); ///! Return true if the path is a framework - static bool IsPathToFramework(const char* value); + static bool IsPathToFramework(const std::string& value); static bool DoesFileExistWithExtensions( const std::string& name, const std::vector<std::string>& sourceExts); @@ -242,7 +242,7 @@ public: /** * Parse arguments out of a single string command */ - static std::vector<std::string> ParseArguments(const char* command); + static std::vector<std::string> ParseArguments(const std::string& command); /** Parse arguments out of a windows command line string. */ static void ParseWindowsCommandLine(const char* command, @@ -353,7 +353,7 @@ public: // ConvertToRunCommandPath does not use s_ForceUnixPaths and should // be used when RunCommand is called from cmake, because the // running cmake needs paths to be in its format - static std::string ConvertToRunCommandPath(const char* path); + static std::string ConvertToRunCommandPath(const std::string& path); /** compute the relative path from local to remote. local must be a directory. remote can be a file or a directory. @@ -488,7 +488,7 @@ public: static bool CheckRPath(std::string const& file, std::string const& newRPath); /** Remove a directory; repeat a few times in case of locked files. */ - static bool RepeatedRemoveDirectory(const char* dir); + static bool RepeatedRemoveDirectory(const std::string& dir); /** Tokenize a string */ static std::vector<std::string> tokenize(const std::string& str, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index d863339..da34bca 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -173,7 +173,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, std::vector<std::string> emulatorWithArgs; cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); finalCommand += - cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str()); + cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]); finalCommand += " "; for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) { finalCommand += "\""; @@ -182,8 +182,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, finalCommand += " "; } } - finalCommand += - cmSystemTools::ConvertToRunCommandPath(this->OutputFile.c_str()); + finalCommand += cmSystemTools::ConvertToRunCommandPath(this->OutputFile); if (!runArgs.empty()) { finalCommand += runArgs; } diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt b/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt deleted file mode 100644 index 86e3ec0..0000000 --- a/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^WARNING: Target "notall" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it\. CMake does not define behavior for this case\.$ |