From e7ff50712c4a21dd73051147cb71225f63e05bcf Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 8 Oct 2021 09:13:26 +0900 Subject: Imported Upstream version 3.12.1 --- Help/command/FIND_XXX.txt | 24 +++++++++++-------- Help/command/find_package.rst | 6 +++-- Help/envvar/PackageName_ROOT.rst | 15 ++++++++++++ Help/manual/cmake-env-variables.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/policy/CMP0074.rst | 15 ++++++------ Help/release/3.12.rst | 5 ++-- Help/variable/PackageName_ROOT.rst | 14 +++++++++++ Modules/CMakeCSharpCompiler.cmake.in | 1 + Modules/CPack.cmake | 27 ++++++++++++---------- Modules/FindCUDA/select_compute_arch.cmake | 5 ++-- Modules/FindPython/Support.cmake | 6 +---- Modules/FindTCL.cmake | 6 +++++ Modules/FindTclStub.cmake | 2 ++ Modules/FindTclsh.cmake | 1 + Modules/GoogleTest.cmake | 7 ++++++ Modules/UseSWIG.cmake | 9 ++++---- Source/CMakeVersion.cmake | 2 +- Source/cmMakefile.cxx | 2 ++ Source/cmPolicies.h | 4 ++-- Source/cmProjectCommand.cxx | 9 ++++++-- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CPackConfig/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/CPackConfig/Version1-check.cmake | 6 +++++ Tests/RunCMake/CPackConfig/Version1.cmake | 1 + Tests/RunCMake/CPackConfig/Version2-check.cmake | 6 +++++ Tests/RunCMake/CPackConfig/Version2.cmake | 1 + Tests/RunCMake/CPackConfig/Version3-check.cmake | 6 +++++ Tests/RunCMake/CPackConfig/Version3.cmake | 1 + .../RunCMake/find_package/CMP0074-WARN-stderr.txt | 2 +- Tests/RunCMake/project_injected/CMP0048-WARN.cmake | 0 Tests/RunCMake/project_injected/CMakeLists.txt | 3 +++ Tests/RunCMake/project_injected/RunCMakeTest.cmake | 12 ++++++++++ 33 files changed, 155 insertions(+), 49 deletions(-) create mode 100644 Help/envvar/PackageName_ROOT.rst create mode 100644 Help/variable/PackageName_ROOT.rst create mode 100644 Tests/RunCMake/CPackConfig/Version1-check.cmake create mode 100644 Tests/RunCMake/CPackConfig/Version1.cmake create mode 100644 Tests/RunCMake/CPackConfig/Version2-check.cmake create mode 100644 Tests/RunCMake/CPackConfig/Version2.cmake create mode 100644 Tests/RunCMake/CPackConfig/Version3-check.cmake create mode 100644 Tests/RunCMake/CPackConfig/Version3.cmake create mode 100644 Tests/RunCMake/project_injected/CMP0048-WARN.cmake create mode 100644 Tests/RunCMake/project_injected/CMakeLists.txt create mode 100644 Tests/RunCMake/project_injected/RunCMakeTest.cmake diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index 48a1a7124..38c231a67 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -62,8 +62,11 @@ added to the search. If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: .. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace:: - |prefix_XXX_SUBDIR| for each ```` in ``PackageName_ROOT`` if called - from within a find module + |prefix_XXX_SUBDIR| for each ```` in the + :variable:`_ROOT` CMake variable and the + :envvar:`_ROOT` environment variable if + called from within a find module loaded by + :command:`find_package()` .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace:: |prefix_XXX_SUBDIR| for each ```` in :variable:`CMAKE_PREFIX_PATH` @@ -76,13 +79,16 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: |prefix_XXX_SUBDIR| for each ```` in :variable:`CMAKE_SYSTEM_PREFIX_PATH` -1. If called from within a find module, search prefix paths unique to the - current package being found. Specifically look in the ``PackageName_ROOT`` - CMake and environment variables. The package root variables are maintained - as a stack so if called from nested find modules, root paths from the - parent's find module will be searched after paths from the current module, - i.e. ``CurrentPackage_ROOT``, ``ENV{CurrentPackage_ROOT}``, - ``ParentPackage_ROOT``, ``ENV{ParentPackage_ROOT}``, etc. +1. If called from within a find module loaded by + :command:`find_package()`, search prefixes unique to the + current package being found. Specifically look in the + :variable:`_ROOT` CMake variable and the + :envvar:`_ROOT` environment variable. + The package root variables are maintained as a stack so if called from + nested find modules, root paths from the parent's find module will be + searched after paths from the current module, + i.e. ``_ROOT``, ``ENV{_ROOT}``, + ``_ROOT``, ``ENV{_ROOT}``, etc. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed. See policy :policy:`CMP0074`. diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 53f3819b3..a4416abd3 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -262,8 +262,10 @@ The set of installation prefixes is constructed using the following steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are enabled. -1. Search paths specified in the ``PackageName_ROOT`` CMake and environment - variables. The package root variables are maintained as a stack so if +1. Search paths specified in the :variable:`_ROOT` CMake + variable and the :envvar:`_ROOT` environment variable, + where ```` is the package to be found. + The package root variables are maintained as a stack so if called from within a find module, root paths from the parent's find module will also be searched after paths for the current package. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed. diff --git a/Help/envvar/PackageName_ROOT.rst b/Help/envvar/PackageName_ROOT.rst new file mode 100644 index 000000000..e01009bc7 --- /dev/null +++ b/Help/envvar/PackageName_ROOT.rst @@ -0,0 +1,15 @@ +_ROOT +------------------ + +Calls to :command:`find_package()` will search in prefixes +specified by the ``_ROOT`` environment variable, where +```` is the name given to the ``find_package`` call +and ``_ROOT`` is literal. For example, ``find_package(Foo)`` will search +prefixes specified in the ``Foo_ROOT`` environment variable (if set). +See policy :policy:`CMP0074`. + +This variable may hold a single prefix or a list of prefixes separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`_ROOT` CMake variable. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index 2d17bb540..42aeabc89 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -20,6 +20,7 @@ Environment Variables that Control the Build /envvar/DESTDIR /envvar/LDFLAGS /envvar/MACOSX_DEPLOYMENT_TARGET + /envvar/PackageName_ROOT Environment Variables for Languages =================================== diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index edfff6cc0..f6bf0bd92 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -204,6 +204,7 @@ Variables that Change Behavior /variable/CMAKE_WARN_DEPRECATED /variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION /variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY + /variable/PackageName_ROOT Variables that Describe the System ================================== diff --git a/Help/policy/CMP0074.rst b/Help/policy/CMP0074.rst index ffac4a7cb..896936b21 100644 --- a/Help/policy/CMP0074.rst +++ b/Help/policy/CMP0074.rst @@ -1,18 +1,19 @@ CMP0074 ------- -:command:`find_package` uses ``PackageName_ROOT`` variables. +:command:`find_package` uses ``_ROOT`` variables. -In CMake 3.12 and above the ``find_package(PackageName)`` command now searches -a prefix specified by a ``PackageName_ROOT`` CMake or environment variable. +In CMake 3.12 and above the :command:`find_package()` command now +searches prefixes specified by the :variable:`_ROOT` CMake +variable and the :envvar:`_ROOT` environment variable. Package roots are maintained as a stack so nested calls to all ``find_*`` commands inside find modules also search the roots as prefixes. This policy provides compatibility with projects that have not been updated to avoid using -``PackageName_ROOT`` variables for other purposes. +``_ROOT`` variables for other purposes. -The ``OLD`` behavior for this policy is to ignore ``PackageName_ROOT`` -variables. The ``NEW`` behavior for this policy is to use ``PackageName_ROOT`` -variables. +The ``OLD`` behavior for this policy is to ignore ``_ROOT`` +variables. The ``NEW`` behavior for this policy is to use +``_ROOT`` variables. This policy was introduced in CMake version 3.12. CMake version |release| warns when the policy is not set and uses ``OLD`` behavior. diff --git a/Help/release/3.12.rst b/Help/release/3.12.rst index f6fdb5aa9..f00be3e79 100644 --- a/Help/release/3.12.rst +++ b/Help/release/3.12.rst @@ -46,8 +46,9 @@ Commands were added to expose ``TOUCH`` functionality without having to use CMake's command-line tool mode with :command:`execute_process`. -* The :command:`find_package` command now searches a prefix specified by - a ``PackageName_ROOT`` CMake or environment variable. Package roots are +* The :command:`find_package` command now searches prefixes specified by + the :variable:`_ROOT` CMake variable and the + :envvar:`_ROOT` environment variable. Package roots are maintained as a stack so nested calls to all ``find_*`` commands inside find modules also search the roots as prefixes. See policy :policy:`CMP0074`. diff --git a/Help/variable/PackageName_ROOT.rst b/Help/variable/PackageName_ROOT.rst new file mode 100644 index 000000000..4f6c25b34 --- /dev/null +++ b/Help/variable/PackageName_ROOT.rst @@ -0,0 +1,14 @@ +_ROOT +------------------ + +Calls to :command:`find_package()` will search in prefixes +specified by the ``_ROOT`` CMake variable, where +```` is the name given to the ``find_package`` call +and ``_ROOT`` is literal. For example, ``find_package(Foo)`` will search +prefixes specified in the ``Foo_ROOT`` CMake variable (if set). +See policy :policy:`CMP0074`. + +This variable may hold a single prefix or a +:ref:`;-list ` of multiple prefixes. + +See also the :envvar:`_ROOT` environment variable. diff --git a/Modules/CMakeCSharpCompiler.cmake.in b/Modules/CMakeCSharpCompiler.cmake.in index 5ecc4800b..3d49b6bc9 100644 --- a/Modules/CMakeCSharpCompiler.cmake.in +++ b/Modules/CMakeCSharpCompiler.cmake.in @@ -2,6 +2,7 @@ set(CMAKE_CSharp_COMPILER "@CMAKE_CSharp_COMPILER@") set(CMAKE_CSharp_COMPILER_ID "@CMAKE_CSharp_COMPILER_ID@") set(CMAKE_CSharp_COMPILER_VERSION "@CMAKE_CSharp_COMPILER_VERSION@") +set(CMAKE_CSharp_COMPILER_LOADED 1) set(CMAKE_CSharp_COMPILER_WORKS "@CMAKE_CSharp_COMPILER_WORKS@") set(CMAKE_CSharp_COMPILER_ID_RUN "@CMAKE_CSharp_COMPILER_ID_RUN@") diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 80708690a..cdc38a6a9 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -403,28 +403,31 @@ endfunction() # Set the package name _cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") -if(CMAKE_PROJECT_VERSION_MAJOR) + +# Set the package version +if(CMAKE_PROJECT_VERSION_MAJOR GREATER_EQUAL 0) _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}") - if(CMAKE_PROJECT_VERSION_MINOR) + if(CMAKE_PROJECT_VERSION_MINOR GREATER_EQUAL 0) _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}") - if(CMAKE_PROJECT_VERSION_PATCH) + if(CMAKE_PROJECT_VERSION_PATCH GREATER_EQUAL 0) _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_PROJECT_VERSION_PATCH}") - _cpack_set_default(CPACK_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") - else() - _cpack_set_default(CPACK_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") endif() - else() - _cpack_set_default(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}") endif() else() _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0") _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1") _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1") - _cpack_set_default(CPACK_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") endif() +if(NOT DEFINED CPACK_PACKAGE_VERSION) + set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}") + if(CPACK_PACKAGE_VERSION_MINOR GREATER_EQUAL 0) + string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_MINOR}") + if(CPACK_PACKAGE_VERSION_PATCH GREATER_EQUAL 0) + string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_PATCH}") + endif() + endif() +endif() + _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity") if(CMAKE_PROJECT_DESCRIPTION) _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index 22c04df0e..cf4fc39df 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -18,8 +18,9 @@ # if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language - if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") - set(CUDA_VERSION "${CMAKE_CUDA_COMPILER_VERSION}") + if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" + AND CMAKE_CUDA_COMPILER_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(CUDA_VERSION "${CMAKE_MATCH_1}") endif() endif() diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 08f07fdaf..fe3df9119 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -196,10 +196,6 @@ endif() set (CMAKE_FIND_FRAMEWORK LAST) -unset (${_PYTHON_PREFIX}_VERSION_MAJOR) -unset (${_PYTHON_PREFIX}_VERSION_MINOR) -unset (${_PYTHON_PREFIX}_VERSION_PATCH) - unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) unset (_${_PYTHON_PREFIX}_CACHED_VARS) @@ -259,7 +255,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # try more generic names if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${${_PYTHON_PREFIX}_VERSION_MAJOR} python + NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} HINTS ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES bin) diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 19eb9329f..ad16e0de1 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -85,6 +85,8 @@ set(TCLTK_POSSIBLE_LIB_PATHS ) set(TCLTK_POSSIBLE_LIB_PATH_SUFFIXES + lib/tcl/tcl8.7 + lib/tcl/tk8.7 lib/tcl/tcl8.6 lib/tcl/tk8.6 lib/tcl/tcl8.5 @@ -116,6 +118,7 @@ find_library(TCL_LIBRARY NAMES tcl tcl${TCL_LIBRARY_VERSION} tcl${TCL_TCLSH_VERSION} tcl${TK_WISH_VERSION} + tcl87 tcl8.7 tcl87t tcl8.7t tcl86 tcl8.6 tcl86t tcl8.6t tcl85 tcl8.5 tcl84 tcl8.4 @@ -130,6 +133,7 @@ find_library(TK_LIBRARY NAMES tk tk${TK_LIBRARY_VERSION} tk${TCL_TCLSH_VERSION} tk${TK_WISH_VERSION} + tk87 tk8.7 tk87t tk8.7t tk86 tk8.6 tk86t tk8.6t tk85 tk8.5 tk84 tk8.4 @@ -176,6 +180,8 @@ set(TCLTK_POSSIBLE_INCLUDE_PATHS set(TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES include/tcl${TK_LIBRARY_VERSION} include/tcl${TCL_LIBRARY_VERSION} + include/tcl8.7 + include/tk8.7 include/tcl8.6 include/tk8.6 include/tcl8.5 diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake index 51fc02933..db0a7a176 100644 --- a/Modules/FindTclStub.cmake +++ b/Modules/FindTclStub.cmake @@ -101,6 +101,7 @@ find_library(TCL_STUB_LIBRARY NAMES tclstub tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION} + tclstub87 tclstub8.7 tclstub86 tclstub8.6 tclstub85 tclstub8.5 tclstub84 tclstub8.4 @@ -114,6 +115,7 @@ find_library(TK_STUB_LIBRARY NAMES tkstub tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION} + tkstub87 tkstub8.7 tkstub86 tkstub8.6 tkstub85 tkstub8.5 tkstub84 tkstub8.4 diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 9fcb41cb4..9bf935d8e 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -68,6 +68,7 @@ endif() set(TCL_TCLSH_NAMES tclsh tclsh${TCL_LIBRARY_VERSION} tclsh${TK_LIBRARY_VERSION} tclsh${TK_WISH_VERSION} + tclsh87 tclsh8.7 tclsh86 tclsh8.6 tclsh85 tclsh8.5 tclsh84 tclsh8.4 diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index bfb83e1b4..2c9ee1180 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -238,6 +238,10 @@ same as the Google Test name (i.e. ``suite.testcase``); see also #]=======================================================================] +# Save project's policies +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + #------------------------------------------------------------------------------ function(gtest_add_tests) @@ -454,3 +458,6 @@ endfunction() set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/GoogleTestAddTests.cmake ) + +# Restore project's policies +cmake_policy(POP) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b30618129..b7b9fe1a1 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -241,7 +241,6 @@ macro(SWIG_MODULE_INITIALIZE name language) string(TOUPPER "${language}" SWIG_MODULE_${name}_LANGUAGE) string(TOLOWER "${language}" SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG) - set(SWIG_MODULE_${name}_EXTRA_FLAGS) if (NOT DEFINED SWIG_MODULE_${name}_NOPROXY) set (SWIG_MODULE_${name}_NOPROXY FALSE) endif() @@ -249,12 +248,14 @@ macro(SWIG_MODULE_INITIALIZE name language) set (SWIG_MODULE_${name}_NOPROXY TRUE) endif () - if (SWIG_MODULE_${name}_NOPROXY AND NOT "-noproxy" IN_LIST CMAKE_SWIG_FLAGS) + if (SWIG_MODULE_${name}_NOPROXY AND + NOT ("-noproxy" IN_LIST CMAKE_SWIG_FLAGS OR "-noproxy" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)) list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-noproxy") endif() if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "UNKNOWN") message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") - elseif(SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL") + elseif(SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL" AND + NOT "-shadow" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS) list(APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") endif() endmacro() @@ -294,7 +295,7 @@ function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) endif() foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSIONS}) set(extra_file "${generatedpath}/${module_basename}${it}") - if (extra_file MATCHES "\\.cs$") + if (extra_file MATCHES "\\.cs$" AND CMAKE_CSharp_COMPILER_LOADED) set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "CSharp") else() # Treat extra outputs as plain files regardless of language. diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 24f74e4b9..a1343ae19 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 12) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 1) #set(CMake_VERSION_RC 0) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3c7a4cf2b..af97f8097 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1511,6 +1511,8 @@ void cmMakefile::Configure() project.Name.Lower = "project"; project.Arguments.emplace_back("Project", cmListFileArgument::Unquoted, 0); + project.Arguments.emplace_back("__CMAKE_INJECTED_PROJECT_COMMAND__", + cmListFileArgument::Unquoted, 0); listFile.Functions.insert(listFile.Functions.begin(), project); } } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 3fe0c844d..1ef1813c2 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -219,8 +219,8 @@ class cmMakefile; SELECT(POLICY, CMP0073, \ "Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0, \ cmPolicies::WARN) \ - SELECT(POLICY, CMP0074, "find_package uses PackageName_ROOT variables.", 3, \ - 12, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0074, "find_package uses _ROOT variables.", \ + 3, 12, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0075, \ "Include file check macros honor CMAKE_REQUIRED_LIBRARIES.", 3, 12, \ 0, cmPolicies::WARN) diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a25bd6b38..ee440079f 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -69,6 +69,7 @@ bool cmProjectCommand::InitialPass(std::vector const& args, bool haveLanguages = false; bool haveDescription = false; bool haveHomepage = false; + bool injectedProjectCommand = false; std::string version; std::string description; std::string homepage; @@ -160,6 +161,8 @@ bool cmProjectCommand::InitialPass(std::vector const& args, "by a value that expanded to nothing."); resetReporter(); }; + } else if (i == 1 && args[i] == "__CMAKE_INJECTED_PROJECT_COMMAND__") { + injectedProjectCommand = true; } else if (doing == DoingVersion) { doing = DoingLanguages; version = args[i]; @@ -280,8 +283,10 @@ bool cmProjectCommand::InitialPass(std::vector const& args, const char* v = this->Makefile->GetDefinition(i); if (v && *v) { if (cmp0048 == cmPolicies::WARN) { - vw += "\n "; - vw += i; + if (!injectedProjectCommand) { + vw += "\n "; + vw += i; + } } else { this->Makefile->AddDefinition(i, ""); } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index bb4614457..637c5c2cb 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -240,6 +240,7 @@ add_RunCMake_test(include_guard) add_RunCMake_test(list) add_RunCMake_test(message) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) +add_RunCMake_test(project_injected) add_RunCMake_test(return) add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake index 16d2cf39f..8f2196d5b 100644 --- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake @@ -4,3 +4,6 @@ run_cmake(Simple) run_cmake(Default) run_cmake(Special) run_cmake(Verbatim) +run_cmake(Version1) +run_cmake(Version2) +run_cmake(Version3) diff --git a/Tests/RunCMake/CPackConfig/Version1-check.cmake b/Tests/RunCMake/CPackConfig/Version1-check.cmake new file mode 100644 index 000000000..0f5347f78 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version1-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_PACKAGE_VERSION "0") +test_variable(CPACK_PACKAGE_VERSION_MAJOR "0") +test_variable(CPACK_PACKAGE_VERSION_MINOR "") +test_variable(CPACK_PACKAGE_VERSION_PATCH "") diff --git a/Tests/RunCMake/CPackConfig/Version1.cmake b/Tests/RunCMake/CPackConfig/Version1.cmake new file mode 100644 index 000000000..703485c98 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version1.cmake @@ -0,0 +1 @@ +project(Version LANGUAGES NONE VERSION 0) diff --git a/Tests/RunCMake/CPackConfig/Version2-check.cmake b/Tests/RunCMake/CPackConfig/Version2-check.cmake new file mode 100644 index 000000000..3a2d572df --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version2-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_PACKAGE_VERSION "1.0") +test_variable(CPACK_PACKAGE_VERSION_MAJOR "1") +test_variable(CPACK_PACKAGE_VERSION_MINOR "0") +test_variable(CPACK_PACKAGE_VERSION_PATCH "") diff --git a/Tests/RunCMake/CPackConfig/Version2.cmake b/Tests/RunCMake/CPackConfig/Version2.cmake new file mode 100644 index 000000000..c084137b4 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version2.cmake @@ -0,0 +1 @@ +project(Version LANGUAGES NONE VERSION 1.0) diff --git a/Tests/RunCMake/CPackConfig/Version3-check.cmake b/Tests/RunCMake/CPackConfig/Version3-check.cmake new file mode 100644 index 000000000..d4a3983dd --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version3-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_PACKAGE_VERSION "1.1.0") +test_variable(CPACK_PACKAGE_VERSION_MAJOR "1") +test_variable(CPACK_PACKAGE_VERSION_MINOR "1") +test_variable(CPACK_PACKAGE_VERSION_PATCH "0") diff --git a/Tests/RunCMake/CPackConfig/Version3.cmake b/Tests/RunCMake/CPackConfig/Version3.cmake new file mode 100644 index 000000000..4df28bbe1 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Version3.cmake @@ -0,0 +1 @@ +project(Version LANGUAGES NONE VERSION 1.1.0) diff --git a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt index 27fbb8636..fc08163cd 100644 --- a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt +++ b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt @@ -3,7 +3,7 @@ Foo_ROOT :/foo/cmake_root ENV{Foo_ROOT} :/foo/env_root + CMake Warning \(dev\) at CMP0074-common.cmake:[0-9]+ \(find_package\): - Policy CMP0074 is not set: find_package uses PackageName_ROOT variables. + Policy CMP0074 is not set: find_package uses _ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN.cmake b/Tests/RunCMake/project_injected/CMP0048-WARN.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/RunCMake/project_injected/CMakeLists.txt b/Tests/RunCMake/project_injected/CMakeLists.txt new file mode 100644 index 000000000..1b4931b8f --- /dev/null +++ b/Tests/RunCMake/project_injected/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12.2) # old enough to not set CMP0048 +# no project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/project_injected/RunCMakeTest.cmake b/Tests/RunCMake/project_injected/RunCMakeTest.cmake new file mode 100644 index 000000000..ba1a00377 --- /dev/null +++ b/Tests/RunCMake/project_injected/RunCMakeTest.cmake @@ -0,0 +1,12 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS + # Simulate a previous CMake run that used `project(... VERSION ...)` + # in a non-injected call site. + -DCMAKE_PROJECT_VERSION:STATIC=1.2.3 + -DCMAKE_PROJECT_VERSION_MAJOR:STATIC=1 + -DCMAKE_PROJECT_VERSION_MINOR:STATIC=2 + -DCMAKE_PROJECT_VERSION_PATCH:STATIC=3 + ) +run_cmake(CMP0048-WARN) +unset(RunCMake_TEST_OPTIONS) -- cgit v1.2.3