diff options
-rw-r--r-- | Help/command/try_compile.rst | 44 | ||||
-rw-r--r-- | Help/command/try_run.rst | 14 | ||||
-rw-r--r-- | Help/policy/CMP0083.rst | 7 | ||||
-rw-r--r-- | Help/prop_tgt/EXCLUDE_FROM_ALL.rst | 12 | ||||
-rw-r--r-- | Help/release/3.14.rst | 9 | ||||
-rw-r--r-- | Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst | 7 | ||||
-rw-r--r-- | Modules/CheckCXXSourceRuns.cmake | 7 | ||||
-rw-r--r-- | Modules/CheckFortranSourceRuns.cmake | 7 | ||||
-rw-r--r-- | README.rst | 21 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 19 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 24 | ||||
-rw-r--r-- | Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt | 1 |
15 files changed, 107 insertions, 84 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/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/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 1921e30..9c5c974 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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/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\.$ |