From fa0c02e9dfbc7880653a058a90634d3cea66cf1b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 18 Nov 2020 11:47:19 -0500 Subject: ci: update to use CMake 3.19.0 --- .gitlab/ci/cmake.ps1 | 4 ++-- .gitlab/ci/cmake.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/cmake.ps1 b/.gitlab/ci/cmake.ps1 index e73aab7..9d7f317 100755 --- a/.gitlab/ci/cmake.ps1 +++ b/.gitlab/ci/cmake.ps1 @@ -1,7 +1,7 @@ $erroractionpreference = "stop" -$version = "3.18.4" -$sha256sum = "A932BC0C8EE79F1003204466C525B38A840424D4AE29F9E5FB88959116F2407D" +$version = "3.19.0" +$sha256sum = "67BBDA67C98C5F0789199FE1DB650F12274A6AD40FD8CAE88D208029AC618905" $filename = "cmake-$version-win64-x64" $tarball = "$filename.zip" diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh index b4c6ddf..2547663 100755 --- a/.gitlab/ci/cmake.sh +++ b/.gitlab/ci/cmake.sh @@ -2,17 +2,17 @@ set -e -readonly version="3.18.4" +readonly version="3.19.0" case "$( uname -s )" in Linux) shatool="sha256sum" - sha256sum="149e0cee002e59e0bb84543cf3cb099f108c08390392605e944daeb6594cbc29" + sha256sum="5446cdee900e906e46162a5a7be9b4542bb5e886041cf8cffeda62aae2696ccf" platform="Linux" ;; Darwin) shatool="shasum -a 256" - sha256sum="9d27049660474cf134ab46fa0e0db771b263313fcb8ba82ee8b2d1a1a62f8f20" + sha256sum="315eb5500753f797075b6ea43189420e97b0b9f32c8fc87ec94ba1d80b72eb7f" platform="Darwin" ;; *) -- cgit v0.12 From ec5223666b9b8dc06fccf3d39bc79b163a5de867 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 18 Nov 2020 11:49:55 -0500 Subject: gitlab-ci: update macOS jobs to use Xcode 12.0 --- .gitlab/os-macos.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index a500d36..db6f3bf 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -7,7 +7,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci ext/$CI_CONCURRENT_ID" # TODO: Factor this out so that each job selects the Xcode version to # use so that different versions can be tested in a single pipeline. - DEVELOPER_DIR: "/Applications/Xcode-11.7.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode-12.0.app/Contents/Developer" # Avoid conflicting with other projects running on the same machine. SCCACHE_SERVER_PORT: 4227 @@ -63,7 +63,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-11.7 + - xcode-12.0 - nonconcurrent .macos_builder_tags_package: @@ -71,7 +71,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-11.7 + - xcode-12.0 - nonconcurrent - finder @@ -80,7 +80,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-11.7 + - xcode-12.0 - concurrent ## macOS-specific scripts -- cgit v0.12 From 30aa715fac06deba7eaa3e6167cf34eb4d2521d0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Nov 2020 15:19:36 -0500 Subject: Revert "specify language flag when source LANGUAGE property is set" Revert commit 74b1c9fc8e (Explicitly specify language flag when source LANGUAGE property is set, 2020-06-01, v3.19.0-rc1~722^2) and the lookup tables from its two immediate ancestors. The purpose of that change was to convert an explicit `LANGUAGE` source file property into an explicit language specification compiler flag like `-x c`. This seems reasonable since the property is documented as meaning "indicate what programming language the source file is". It is also needed to help compilers deal with non-standard source file extensions they don't recognize. However, some projects have been setting `LANGUAGE C` on `.S` assembler source files to mean "use the C compiler". Passing `-x c` for them breaks the build because the `.S` sources are not written in C. These projects should be updated to use `enable_language(ASM)`, for which CMake often chooses the C compiler as the assembler when using toolchains that support it (which would have to be the case for projects using the approach). Revert the change for now to preserve the old behavior for such projects. We can re-introduce it with a policy in a future version of CMake. Fixes: #21469 Issue: #14516, #20716 --- Help/release/3.19.rst | 16 ++++++++++++++++ Modules/Compiler/AppleClang-C.cmake | 2 -- Modules/Compiler/AppleClang-CXX.cmake | 2 -- Modules/Compiler/Clang-C.cmake | 2 -- Modules/Compiler/Clang-CXX.cmake | 2 -- Modules/Compiler/GNU-C.cmake | 2 -- Modules/Compiler/GNU-CXX.cmake | 2 -- Modules/Compiler/Intel-C.cmake | 2 -- Modules/Compiler/Intel-CXX.cmake | 2 -- Modules/Compiler/XL-C.cmake | 2 -- Modules/Compiler/XL-CXX.cmake | 5 +++-- Modules/Compiler/XLClang-C.cmake | 2 -- Modules/Compiler/XLClang-CXX.cmake | 2 -- Source/cmExtraSublimeTextGenerator.cxx | 7 ------- Source/cmGlobalXCodeGenerator.cxx | 8 -------- Source/cmMakefileTargetGenerator.cxx | 7 ------- Source/cmNinjaTargetGenerator.cxx | 11 +---------- Tests/SetLang/CMakeLists.txt | 7 ------- Tests/SetLang/bar.c | 14 +------------- Tests/SetLang/zoom.zzz | 7 ------- 20 files changed, 21 insertions(+), 83 deletions(-) delete mode 100644 Tests/SetLang/zoom.zzz diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index be63e9d..961d6c0 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -330,3 +330,19 @@ Other Changes * If ``CUDA`` compiler detection fails with user-specified :variable:`CMAKE_CUDA_ARCHITECTURES` or :variable:`CMAKE_CUDA_HOST_COMPILER`, an error is raised. + +Updates +======= + +Changes made since CMake 3.19.0 include the following. + +3.19.1 +------ + +* CMake 3.19.0 compiles source files with the :prop_sf:`LANGUAGE` + property by passing an explicit language flag such as ``-x c``. + This is consistent with the property's documented meaning that + the source file is written in the specified language. However, + it can break projects that were using the property only to + cause the specified language's compiler to be used. This has + been reverted to restore behavior from CMake 3.18 and below. diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index 26a4bbd..2794f52 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -1,8 +1,6 @@ include(Compiler/Clang) __compiler_clang(C) -set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 611c674..15edc21 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1,8 +1,6 @@ include(Compiler/Clang) __compiler_clang(CXX) -set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) - if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index fb6ffa7..7c4a263 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -8,8 +8,6 @@ endif() if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") -elseif("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") - set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 311d2b0..789e991 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -2,9 +2,7 @@ include(Compiler/Clang) __compiler_clang(CXX) __compiler_clang_cxx_standards(CXX) - if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") - set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 8105a77..ca286b3 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -1,8 +1,6 @@ include(Compiler/GNU) __compiler_gnu(C) -set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 59ec056..fcaaeab 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -1,8 +1,6 @@ include(Compiler/GNU) __compiler_gnu(CXX) -set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) - if (WIN32) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 322f63d..ec3bfd8 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -28,8 +28,6 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") else() - set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 42adfd1..b71b946 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -42,8 +42,6 @@ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") else() - set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 78c44d5..2077bda 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -6,8 +6,6 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded") -set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -qsourcetype=c) - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 3b911f3..41e3e11 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -6,8 +6,6 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded") -set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -+) - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) if(CMAKE_SYSTEM MATCHES "Linux") set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") @@ -34,3 +32,6 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) endif () __compiler_check_default_language_standard(CXX 10.1 98) + +set(CMAKE_CXX_COMPILE_OBJECT + " -+ -o -c ") diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake index 1668a4d..54c18a6 100644 --- a/Modules/Compiler/XLClang-C.cmake +++ b/Modules/Compiler/XLClang-C.cmake @@ -1,8 +1,6 @@ include(Compiler/XLClang) __compiler_xlclang(C) -set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") diff --git a/Modules/Compiler/XLClang-CXX.cmake b/Modules/Compiler/XLClang-CXX.cmake index 02638c7..9ea3d7c 100644 --- a/Modules/Compiler/XLClang-CXX.cmake +++ b/Modules/Compiler/XLClang-CXX.cmake @@ -1,8 +1,6 @@ include(Compiler/XLClang) __compiler_xlclang(CXX) -set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 1c7e4b1..7c36144 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -349,13 +349,6 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( if (language.empty()) { language = "C"; } - - // explicitly add the explicit language flag before any other flag - // this way backwards compatibility with user flags is maintained - if (source->GetProperty("LANGUAGE")) { - lg->AppendFeatureOptions(flags, language, "EXPLICIT_LANGUAGE"); - } - std::string const& config = lg->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 766ae72..b40d8ea 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -937,14 +937,6 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( default: break; } - - // explicitly add the explicit language flag before any other flag - // this way backwards compatibility with user flags is maintained - if (sf->GetProperty("LANGUAGE")) { - this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, - "EXPLICIT_LANGUAGE"); - } - const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) { lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5f97d86..3c4f68c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -573,13 +573,6 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Build the set of compiler flags. std::string flags; - // explicitly add the explicit language flag before any other flag - // this way backwards compatibility with user flags is maintained - if (source.GetProperty("LANGUAGE")) { - this->LocalGenerator->AppendFeatureOptions(flags, lang, - "EXPLICIT_LANGUAGE"); - } - // Add language-specific flags. std::string langFlags = cmStrCat("$(", lang, "_FLAGS", filterArch, ")"); this->LocalGenerator->AppendFlags(flags, langFlags); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 04d84a0..76df9f2 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -190,16 +190,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( } } - std::string flags; - // explicitly add the explicit language flag before any other flag - // this way backwards compatibility with user flags is maintained - if (source->GetProperty("LANGUAGE")) { - this->LocalGenerator->AppendFeatureOptions(flags, language, - "EXPLICIT_LANGUAGE"); - flags += " "; - } - - flags += this->GetFlags(language, config, filterArch); + std::string flags = this->GetFlags(language, config, filterArch); // Add Fortran format flags. if (language == "Fortran") { diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt index 616421e..9de4fc6 100644 --- a/Tests/SetLang/CMakeLists.txt +++ b/Tests/SetLang/CMakeLists.txt @@ -15,10 +15,3 @@ if(CMAKE_GENERATOR MATCHES "^Visual Studio" AND "x${CMAKE_C_COMPILER_ID}" STREQU add_library(stay stay_c.c stay_cxx.cxx) set_property(TARGET stay PROPERTY COMPILE_OPTIONS "-TP") endif() - -if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|MSVC|Borland|Embarcadero|Intel|TI|XL)")) - add_library(zoom zoom.zzz) - set_source_files_properties(zoom.zzz PROPERTIES LANGUAGE CXX) - target_link_libraries(SetLang zoom) - target_compile_definitions(SetLang PRIVATE WITH_ZOOM) -endif() diff --git a/Tests/SetLang/bar.c b/Tests/SetLang/bar.c index 515e8c2..b934356 100644 --- a/Tests/SetLang/bar.c +++ b/Tests/SetLang/bar.c @@ -1,22 +1,10 @@ #include int foo(); - -#ifdef WITH_ZOOM -int zoom(); -#endif - class A { public: - A() - { - this->i = foo(); -#ifdef WITH_ZOOM - i += zoom(); - i -= zoom(); -#endif - } + A() { this->i = foo(); } int i; }; diff --git a/Tests/SetLang/zoom.zzz b/Tests/SetLang/zoom.zzz deleted file mode 100644 index a0c8899..0000000 --- a/Tests/SetLang/zoom.zzz +++ /dev/null @@ -1,7 +0,0 @@ -int zoom() -{ - int r = 10; - r++; - int ret = r + 10; - return ret; -} -- cgit v0.12 From 64dc4efc511f766d0a099df717e2f35f9eccabce Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 20 Nov 2020 09:29:08 -0500 Subject: FindGTest: Revert "Allow either "Debug" or "Release" configurations." Revert commit a064b18f85 (FindGTest: Allow either "Debug" or "Release" configurations., 2020-06-29, v3.19.0-rc1~584^2). If both configurations are found then `GTEST_LIBRARY` is populated in a way that breaks `__gtest_determine_library_type`, and the imported target is not created correctly. Fixes: #21473 Issue: #17799 --- Modules/FindGTest.cmake | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 10e31b2..53cab1a 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -96,27 +96,6 @@ function(__gtest_find_library _name) mark_as_advanced(${_name}) endfunction() -function(__gtest_find_library_configuration _name _lib _cfg_suffix) - set(_libs ${_lib}) - if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD") - # The provided /MD project files for Google Test add -md suffixes to the - # library names. - list(INSERT _libs 0 ${_lib}-md) - endif() - list(TRANSFORM _libs APPEND "${_cfg_suffix}") - - __gtest_find_library(${_name} ${_libs}) -endfunction() - -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -function(__gtest_find_and_select_library_configurations _basename _lib) - __gtest_find_library_configuration(${_basename}_LIBRARY_RELEASE ${_lib} "") - __gtest_find_library_configuration(${_basename}_LIBRARY_DEBUG ${_lib} "d") - - select_library_configurations(${_basename}) - set(${_basename}_LIBRARY ${${_basename}_LIBRARY} PARENT_SCOPE) -endfunction() - macro(__gtest_determine_windows_library_type _var) if(EXISTS "${${_var}}") file(TO_NATIVE_PATH "${${_var}}" _lib_path) @@ -208,13 +187,18 @@ find_path(GTEST_INCLUDE_DIR gtest/gtest.h ) mark_as_advanced(GTEST_INCLUDE_DIR) -# Allow GTEST_LIBRARY and GTEST_MAIN_LIBRARY to be set manually, as the -# locations of the gtest and gtest_main libraries, respectively. -if(NOT GTEST_LIBRARY) - __gtest_find_and_select_library_configurations(GTEST gtest) -endif() -if(NOT GTEST_MAIN_LIBRARY) - __gtest_find_and_select_library_configurations(GTEST_MAIN gtest_main) +if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD") + # The provided /MD project files for Google Test add -md suffixes to the + # library names. + __gtest_find_library(GTEST_LIBRARY gtest-md gtest) + __gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd) + __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main) + __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind) +else() + __gtest_find_library(GTEST_LIBRARY gtest) + __gtest_find_library(GTEST_LIBRARY_DEBUG gtestd) + __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main) + __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -- cgit v0.12 From 67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 20 Nov 2020 09:45:14 -0500 Subject: Makefiles: Fix CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule Fixes: #21471 --- Source/cmMakefileTargetGenerator.cxx | 16 ++++++++++------ .../ExportCompileCommands/CustomCompileRule.cmake | 5 +++++ Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5f97d86..6e6c8df 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -838,13 +838,17 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), this->GetFlags(lang, this->GetConfigName())); std::string langDefines = std::string("$(") + lang + "_DEFINES)"; - compileCommand.replace(compileCommand.find(langDefines), - langDefines.size(), - this->GetDefines(lang, this->GetConfigName())); + std::string::size_type ldPos = compileCommand.find(langDefines); + if (ldPos != std::string::npos) { + compileCommand.replace(ldPos, langDefines.size(), + this->GetDefines(lang, this->GetConfigName())); + } std::string langIncludes = std::string("$(") + lang + "_INCLUDES)"; - compileCommand.replace(compileCommand.find(langIncludes), - langIncludes.size(), - this->GetIncludes(lang, this->GetConfigName())); + std::string::size_type liPos = compileCommand.find(langIncludes); + if (liPos != std::string::npos) { + compileCommand.replace(liPos, langIncludes.size(), + this->GetIncludes(lang, this->GetConfigName())); + } cmProp eliminate[] = { this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"), diff --git a/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake b/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake new file mode 100644 index 0000000..12368a2 --- /dev/null +++ b/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake @@ -0,0 +1,5 @@ +enable_language(C) +add_library(empty STATIC empty.c) +string(REPLACE "" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake b/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake index b540a04..9e7e732 100644 --- a/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake_with_options(BeforeProject -DCMAKE_PROJECT_INCLUDE_BEFORE=BeforeProjectBEFORE.cmake) +run_cmake(CustomCompileRule) -- cgit v0.12 From 6e7625989c753391b517904cfb36d684e7db6884 Mon Sep 17 00:00:00 2001 From: Nikita Nemkin Date: Sun, 22 Nov 2020 03:15:02 +0500 Subject: Help: Fix `.. versionadded` directives for CTEST_CUSTOM_* variables CTEST_CUSTOM_* variables predate 3.0, but the docs were only added in 3.4. Issue: #19715 --- Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst | 2 -- Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst | 2 -- Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst | 2 -- Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst | 2 -- Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst | 2 -- Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst | 2 -- Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst | 2 -- Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst | 2 -- Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst | 2 -- Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst | 2 -- Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst | 2 -- Help/variable/CTEST_CUSTOM_POST_TEST.rst | 2 -- Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst | 2 -- Help/variable/CTEST_CUSTOM_PRE_TEST.rst | 2 -- Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst | 2 -- Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst | 2 -- Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst | 2 -- 17 files changed, 34 deletions(-) diff --git a/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst b/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst index 84ba12d..d5893c9 100644 --- a/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst +++ b/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_COVERAGE_EXCLUDE ----------------------------- -.. versionadded:: 3.4 - A list of regular expressions which will be used to exclude files by their path from coverage output by the :command:`ctest_coverage` command. diff --git a/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst b/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst index 7191ce4..cd65ae3 100644 --- a/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst +++ b/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_ERROR_EXCEPTION ---------------------------- -.. versionadded:: 3.4 - A list of regular expressions which will be used to exclude when detecting error messages in build outputs by the :command:`ctest_test` command. diff --git a/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst b/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst index 5d213f2..558f5e5 100644 --- a/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst +++ b/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_ERROR_MATCH ------------------------ -.. versionadded:: 3.4 - A list of regular expressions which will be used to detect error messages in build outputs by the :command:`ctest_test` command. diff --git a/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst b/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst index 452d060..614859b 100644 --- a/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst +++ b/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_ERROR_POST_CONTEXT ------------------------------- -.. versionadded:: 3.4 - The number of lines to include as context which follow an error message by the :command:`ctest_test` command. The default is 10. diff --git a/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst b/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst index b7717dd..74dc47a 100644 --- a/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst +++ b/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_ERROR_PRE_CONTEXT ------------------------------ -.. versionadded:: 3.4 - The number of lines to include as context which precede an error message by the :command:`ctest_test` command. The default is 10. diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst index 31ba099..5aeae88 100644 --- a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst +++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE -------------------------------------------- -.. versionadded:: 3.4 - When saving a failing test's output, this is the maximum size, in bytes, that will be collected by the :command:`ctest_test` command. Defaults to 307200 (300 KiB). diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst index e5be1ad..920cb04 100644 --- a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst +++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS ------------------------------------- -.. versionadded:: 3.4 - The maximum number of errors in a single build step which will be detected. After this, the :command:`ctest_test` command will truncate the output. Defaults to 50. diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst index b513a5c..a1f1cc1 100644 --- a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst +++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS --------------------------------------- -.. versionadded:: 3.4 - The maximum number of warnings in a single build step which will be detected. After this, the :command:`ctest_test` command will truncate the output. Defaults to 50. diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst index 08762d8..1fbb8c5 100644 --- a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst +++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE -------------------------------------------- -.. versionadded:: 3.4 - When saving a passing test's output, this is the maximum size, in bytes, that will be collected by the :command:`ctest_test` command. Defaults to 1024 (1 KiB). diff --git a/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst b/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst index 405fc33..578576c 100644 --- a/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst +++ b/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_MEMCHECK_IGNORE ---------------------------- -.. versionadded:: 3.4 - A list of regular expressions to use to exclude tests during the :command:`ctest_memcheck` command. diff --git a/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst b/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst index 5e488a7..40291fe 100644 --- a/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst +++ b/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_POST_MEMCHECK -------------------------- -.. versionadded:: 3.4 - A list of commands to run at the end of the :command:`ctest_memcheck` command. .. include:: CTEST_CUSTOM_XXX.txt diff --git a/Help/variable/CTEST_CUSTOM_POST_TEST.rst b/Help/variable/CTEST_CUSTOM_POST_TEST.rst index 7ec42f7..791292c 100644 --- a/Help/variable/CTEST_CUSTOM_POST_TEST.rst +++ b/Help/variable/CTEST_CUSTOM_POST_TEST.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_POST_TEST ---------------------- -.. versionadded:: 3.4 - A list of commands to run at the end of the :command:`ctest_test` command. .. include:: CTEST_CUSTOM_XXX.txt diff --git a/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst b/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst index 99e47bd..00de8aa 100644 --- a/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst +++ b/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_PRE_MEMCHECK ------------------------- -.. versionadded:: 3.4 - A list of commands to run at the start of the :command:`ctest_memcheck` command. diff --git a/Help/variable/CTEST_CUSTOM_PRE_TEST.rst b/Help/variable/CTEST_CUSTOM_PRE_TEST.rst index 95c6314..6af7152 100644 --- a/Help/variable/CTEST_CUSTOM_PRE_TEST.rst +++ b/Help/variable/CTEST_CUSTOM_PRE_TEST.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_PRE_TEST ---------------------- -.. versionadded:: 3.4 - A list of commands to run at the start of the :command:`ctest_test` command. .. include:: CTEST_CUSTOM_XXX.txt diff --git a/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst index 27a75d9..57222ca 100644 --- a/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst +++ b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_TESTS_IGNORE ------------------------- -.. versionadded:: 3.14 - A list of regular expressions to use to exclude tests during the :command:`ctest_test` command. diff --git a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst index 539760b..a03d473 100644 --- a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst +++ b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_WARNING_EXCEPTION ------------------------------ -.. versionadded:: 3.4 - A list of regular expressions which will be used to exclude when detecting warning messages in build outputs by the :command:`ctest_build` command. diff --git a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst index 53e7707..18aa6b3 100644 --- a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst +++ b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst @@ -1,8 +1,6 @@ CTEST_CUSTOM_WARNING_MATCH -------------------------- -.. versionadded:: 3.4 - A list of regular expressions which will be used to detect warning messages in build outputs by the :command:`ctest_build` command. -- cgit v0.12 From 440dc98b07d89d3c45c19a9c4ddfbf264081600b Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sun, 22 Nov 2020 11:03:00 +0200 Subject: CUDA: Clang CUDA 11.1 support version.txt is gone from CUDA 11.1 installations, but the rest is the same. Instead of looking for version.txt look for /nvvm/libdevice, which is the main thing that Clang requires (though it also checks for the existence of bin and include). Fixes #21353. --- Help/release/3.19.rst | 2 ++ Modules/CMakeDetermineCUDACompiler.cmake | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index 961d6c0..a29dc07 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -346,3 +346,5 @@ Changes made since CMake 3.19.0 include the following. it can break projects that were using the property only to cause the specified language's compiler to be used. This has been reverted to restore behavior from CMake 3.18 and below. + +* CUDA 11.1 support for Clang. diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 9220551..781c590 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -176,12 +176,12 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) # In a non-scattered installation the following are equivalent to CMAKE_CUDA_COMPILER_TOOLKIT_ROOT. # We first check for a non-scattered installation to prefer it over a scattered installation. - # CMAKE_CUDA_COMPILER_LIBRARY_ROOT contains the device library and version file. - if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/version.txt") + # CMAKE_CUDA_COMPILER_LIBRARY_ROOT contains the device library. + if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}") - elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt") + elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda") - elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt") + elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda") endif() -- cgit v0.12 From 046e454fdd7bf624608f867e032bc88919b86d88 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sun, 22 Nov 2020 11:10:48 +0200 Subject: CUDA: Error if can't determine toolkit library root Finding the toolkit is required for Clang and is assumed to have been correctly found by FindCUDAToolkit if the CUDA language is found. Error out early with an useful error instead of failing later on due to the path not being set. --- Modules/CMakeDetermineCUDACompiler.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 781c590..972adef 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -183,6 +183,8 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda") elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda") + else() + message(FATAL_ERROR "Couldn't find CUDA library root.") endif() # CMAKE_CUDA_COMPILER_TOOLKIT_LIBRARY_ROOT contains the linking stubs necessary for device linking and other low-level library files. -- cgit v0.12 From b4c994f69c6e62ab95a5746db237d0237bc87bc1 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 23 Nov 2020 15:03:25 +0100 Subject: cmFileTime: Fix overflow on time computation On Windows, time starting point is Januray, 1st of 1601. So computing number of nanoseconds from this date exceeds 64bit capabilities. --- Source/cmFileTime.cxx | 15 ++++++++------- Source/cmFileTime.h | 52 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Source/cmFileTime.cxx b/Source/cmFileTime.cxx index 96c70fe..0606baf 100644 --- a/Source/cmFileTime.cxx +++ b/Source/cmFileTime.cxx @@ -24,13 +24,13 @@ bool cmFileTime::Load(std::string const& fileName) } # if CMake_STAT_HAS_ST_MTIM // Nanosecond resolution - this->NS = fst.st_mtim.tv_sec * NsPerS + fst.st_mtim.tv_nsec; + this->Time = fst.st_mtim.tv_sec * UtPerS + fst.st_mtim.tv_nsec; # elif CMake_STAT_HAS_ST_MTIMESPEC // Nanosecond resolution - this->NS = fst.st_mtimespec.tv_sec * NsPerS + fst.st_mtimespec.tv_nsec; + this->Time = fst.st_mtimespec.tv_sec * UtPerS + fst.st_mtimespec.tv_nsec; # else // Second resolution - this->NS = fst.st_mtime * NsPerS; + this->Time = fst.st_mtime * UtPerS; # endif #else // Windows version. Get the modification time from extended file attributes. @@ -41,10 +41,11 @@ bool cmFileTime::Load(std::string const& fileName) } // Copy the file time to the output location. - this->NS = (static_cast(fdata.ftLastWriteTime.dwHighDateTime) << 32) | - static_cast(fdata.ftLastWriteTime.dwLowDateTime); - // The file time resolution is 100 ns. - this->NS *= 100; + using uint64 = unsigned long long; + + this->Time = static_cast( + (uint64(fdata.ftLastWriteTime.dwHighDateTime) << 32) + + fdata.ftLastWriteTime.dwLowDateTime); #endif return true; } diff --git a/Source/cmFileTime.h b/Source/cmFileTime.h index f496cdc..4419880 100644 --- a/Source/cmFileTime.h +++ b/Source/cmFileTime.h @@ -13,9 +13,15 @@ class cmFileTime { public: - using NSC = long long; - static constexpr NSC NsPerS = 1000000000; - + using TimeType = long long; + // unit time per second +#if !defined(_WIN32) || defined(__CYGWIN__) + // unit time is one nanosecond + static constexpr TimeType UtPerS = 1000000000; +#else + // unit time is 100 nanosecond + static constexpr TimeType UtPerS = 10000000; +#endif cmFileTime() = default; ~cmFileTime() = default; @@ -28,22 +34,28 @@ public: /** * @brief Return true if this is older than ftm */ - bool Older(cmFileTime const& ftm) const { return (this->NS - ftm.NS) < 0; } + bool Older(cmFileTime const& ftm) const + { + return (this->Time - ftm.Time) < 0; + } /** * @brief Return true if this is newer than ftm */ - bool Newer(cmFileTime const& ftm) const { return (ftm.NS - this->NS) < 0; } + bool Newer(cmFileTime const& ftm) const + { + return (ftm.Time - this->Time) < 0; + } /** * @brief Return true if this is the same as ftm */ - bool Equal(cmFileTime const& ftm) const { return this->NS == ftm.NS; } + bool Equal(cmFileTime const& ftm) const { return this->Time == ftm.Time; } /** * @brief Return true if this is not the same as ftm */ - bool Differ(cmFileTime const& ftm) const { return this->NS != ftm.NS; } + bool Differ(cmFileTime const& ftm) const { return this->Time != ftm.Time; } /** * @brief Compare file modification times. @@ -51,7 +63,7 @@ public: */ int Compare(cmFileTime const& ftm) const { - NSC const diff = this->NS - ftm.NS; + TimeType const diff = this->Time - ftm.Time; if (diff == 0) { return 0; } @@ -65,7 +77,7 @@ public: */ bool OlderS(cmFileTime const& ftm) const { - return (ftm.NS - this->NS) >= cmFileTime::NsPerS; + return (ftm.Time - this->Time) >= cmFileTime::UtPerS; } /** @@ -73,7 +85,7 @@ public: */ bool NewerS(cmFileTime const& ftm) const { - return (this->NS - ftm.NS) >= cmFileTime::NsPerS; + return (this->Time - ftm.Time) >= cmFileTime::UtPerS; } /** @@ -81,11 +93,11 @@ public: */ bool EqualS(cmFileTime const& ftm) const { - NSC diff = this->NS - ftm.NS; + TimeType diff = this->Time - ftm.Time; if (diff < 0) { diff = -diff; } - return (diff < cmFileTime::NsPerS); + return (diff < cmFileTime::UtPerS); } /** @@ -93,11 +105,11 @@ public: */ bool DifferS(cmFileTime const& ftm) const { - NSC diff = this->NS - ftm.NS; + TimeType diff = this->Time - ftm.Time; if (diff < 0) { diff = -diff; } - return (diff >= cmFileTime::NsPerS); + return (diff >= cmFileTime::UtPerS); } /** @@ -107,21 +119,21 @@ public: */ int CompareS(cmFileTime const& ftm) const { - NSC const diff = this->NS - ftm.NS; - if (diff <= -cmFileTime::NsPerS) { + TimeType const diff = this->Time - ftm.Time; + if (diff <= -cmFileTime::UtPerS) { return -1; } - if (diff >= cmFileTime::NsPerS) { + if (diff >= cmFileTime::UtPerS) { return 1; } return 0; } /** - * @brief The file modification time in nanoseconds + * @brief The file modification time in unit time per second */ - NSC GetNS() const { return this->NS; } + TimeType GetTime() const { return this->Time; } private: - NSC NS = 0; + TimeType Time = 0; }; -- cgit v0.12 From 36921d2d231632768bba8dfb33f86fb92e695b43 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Nov 2020 10:09:20 -0500 Subject: Xcode: Fix custom command work-dir placeholders in "new build system" The placeholders for `CONFIGURATION` and `EFFECTIVE_PLATFORM_NAME` need to be handled in the `WORKING_DIRECTORY` of custom commands just as we already do for the `COMMAND`. Fixes: #21483 --- Source/cmGlobalXCodeGenerator.cxx | 14 +++++++++++--- Tests/RunCMake/add_custom_command/PrintDir.cmake | 1 + Tests/RunCMake/add_custom_command/RunCMakeTest.cmake | 15 +++++++++++++++ .../WorkingDirectory-build-multi-config-stdout.txt | 1 + .../WorkingDirectory-build-single-config-stdout.txt | 1 + Tests/RunCMake/add_custom_command/WorkingDirectory.cmake | 9 +++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 Tests/RunCMake/add_custom_command/PrintDir.cmake create mode 100644 Tests/RunCMake/add_custom_command/WorkingDirectory-build-multi-config-stdout.txt create mode 100644 Tests/RunCMake/add_custom_command/WorkingDirectory-build-single-config-stdout.txt create mode 100644 Tests/RunCMake/add_custom_command/WorkingDirectory.cmake diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b40d8ea..7ee94b2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1965,6 +1965,15 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase( return buildPhase; } +namespace { +void ReplaceScriptVars(std::string& cmd) +{ + cmSystemTools::ReplaceString(cmd, "$(CONFIGURATION)", "$CONFIGURATION"); + cmSystemTools::ReplaceString(cmd, "$(EFFECTIVE_PLATFORM_NAME)", + "$EFFECTIVE_PLATFORM_NAME"); +} +} + std::string cmGlobalXCodeGenerator::ConstructScript( cmCustomCommandGenerator const& ccg) { @@ -1975,6 +1984,7 @@ std::string cmGlobalXCodeGenerator::ConstructScript( wd = lg->GetCurrentBinaryDirectory(); } wd = lg->ConvertToOutputFormat(wd, cmOutputConverter::SHELL); + ReplaceScriptVars(wd); script = cmStrCat(script, " cd ", wd, "\n"); for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) { std::string cmd = ccg.GetCommand(c); @@ -1984,9 +1994,7 @@ std::string cmGlobalXCodeGenerator::ConstructScript( cmSystemTools::ReplaceString(cmd, "/./", "/"); cmd = lg->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL); ccg.AppendArguments(c, cmd); - cmSystemTools::ReplaceString(cmd, "$(CONFIGURATION)", "$CONFIGURATION"); - cmSystemTools::ReplaceString(cmd, "$(EFFECTIVE_PLATFORM_NAME)", - "$EFFECTIVE_PLATFORM_NAME"); + ReplaceScriptVars(cmd); script = cmStrCat(script, " ", cmd, '\n'); } return script; diff --git a/Tests/RunCMake/add_custom_command/PrintDir.cmake b/Tests/RunCMake/add_custom_command/PrintDir.cmake new file mode 100644 index 0000000..0a7b646 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/PrintDir.cmake @@ -0,0 +1 @@ +message(STATUS "WorkingDir='${CMAKE_CURRENT_BINARY_DIR}'") diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 96642fa..aac085d 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -27,3 +27,18 @@ set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(AssigningMultipleTargets-build ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) + +if(NOT RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") + run_cmake(WorkingDirectory) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/WorkingDirectory-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake-stdout-file WorkingDirectory-build-multi-config-stdout.txt) + else() + set(RunCMake-stdout-file WorkingDirectory-build-single-config-stdout.txt) + endif() + run_cmake_command(WorkingDirectory-build ${CMAKE_COMMAND} --build . --config Debug) + unset(RunCMake-stdout-file) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() diff --git a/Tests/RunCMake/add_custom_command/WorkingDirectory-build-multi-config-stdout.txt b/Tests/RunCMake/add_custom_command/WorkingDirectory-build-multi-config-stdout.txt new file mode 100644 index 0000000..95ecf42 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/WorkingDirectory-build-multi-config-stdout.txt @@ -0,0 +1 @@ +-- WorkingDir='[^']*/Tests/RunCMake/add_custom_command/WorkingDirectory-build/Debug' diff --git a/Tests/RunCMake/add_custom_command/WorkingDirectory-build-single-config-stdout.txt b/Tests/RunCMake/add_custom_command/WorkingDirectory-build-single-config-stdout.txt new file mode 100644 index 0000000..1db56ae --- /dev/null +++ b/Tests/RunCMake/add_custom_command/WorkingDirectory-build-single-config-stdout.txt @@ -0,0 +1 @@ +-- WorkingDir='[^']*/Tests/RunCMake/add_custom_command/WorkingDirectory-build' diff --git a/Tests/RunCMake/add_custom_command/WorkingDirectory.cmake b/Tests/RunCMake/add_custom_command/WorkingDirectory.cmake new file mode 100644 index 0000000..65b7250 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/WorkingDirectory.cmake @@ -0,0 +1,9 @@ +add_custom_target(mkdir COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/$") +add_custom_command( + OUTPUT out.txt + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/PrintDir.cmake + WORKING_DIRECTORY ${CMAKE_CFG_INTDIR} + ) +set_property(SOURCE out.txt PROPERTY SYMBOLIC 1) +add_custom_target(drive ALL DEPENDS out.txt) +add_dependencies(drive mkdir) -- cgit v0.12 From ef91fb02f3658954b631e46858e254008ca58132 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 23 Nov 2020 14:20:08 -0500 Subject: cmGlobalGenerator: FindMakeProgram() at a generator-specific time d5b5c192 moved FindMakeProgram() to an earlier time, which resulted in CMAKE_MAKE_PROGRAM not being read from the toolchain file. Change it to only call FindMakeProgram() early in the specific cases of Visual Studio and Xcode, and restore the old behavior for all other generators. Fixes: #21486 --- Source/cmGlobalGenerator.cxx | 9 ++++++++- Source/cmGlobalGenerator.h | 11 +++++++++++ Source/cmGlobalVisualStudioGenerator.h | 5 +++++ Source/cmGlobalXCodeGenerator.h | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1197db6..fc40d63 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -584,7 +584,8 @@ void cmGlobalGenerator::EnableLanguage( // Find the native build tool for this generator. // This has to be done early so that MSBuild can be used to examine the // cross-compilation environment. - if (!this->FindMakeProgram(mf)) { + if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Early && + !this->FindMakeProgram(mf)) { return; } } @@ -660,6 +661,12 @@ void cmGlobalGenerator::EnableLanguage( cmSystemTools::SetFatalErrorOccured(); return; } + + // Find the native build tool for this generator. + if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Late && + !this->FindMakeProgram(mf)) { + return; + } } // Check that the languages are supported by the generator and its diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b532a43..c106258 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -597,6 +597,17 @@ protected: std::string GetPredefinedTargetsFolder(); + enum class FindMakeProgramStage + { + Early, + Late, + }; + + virtual FindMakeProgramStage GetFindMakeProgramStage() const + { + return FindMakeProgramStage::Late; + } + private: using TargetMap = std::unordered_map; using GeneratorTargetMap = diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 3c46408..3bfcbd0 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -166,6 +166,11 @@ protected: void WriteSLNHeader(std::ostream& fout); + FindMakeProgramStage GetFindMakeProgramStage() const override + { + return FindMakeProgramStage::Early; + } + bool ComputeTargetDepends() override; class VSDependSet : public std::set { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 5b05214..ab5eeb2 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -124,6 +124,11 @@ protected: void AddExtraIDETargets() override; void Generate() override; + FindMakeProgramStage GetFindMakeProgramStage() const override + { + return FindMakeProgramStage::Early; + } + private: bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); bool ProcessGeneratorToolsetField(std::string const& key, -- cgit v0.12 From 43c95df8fb8776d36240e57ffc222587bc2049cd Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Nov 2020 15:50:58 -0500 Subject: Tests: Match RunCMake.CMP0111 stderr more strictly --- Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt | 14 ++++++++++++-- Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt | 20 +++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt index ba5d936..91a90e5 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -1,7 +1,17 @@ +^CMake Error in CMakeLists.txt: + IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration + "[^"]+")?. ++ CMake Error in CMakeLists.txt: IMPORTED_LOCATION not set for imported target "static_lib"( configuration - ".+")?. + "[^"]+")?. + CMake Error in CMakeLists.txt: IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration - ".+")?. + "[^"]+")?.( ++ +CMake Error in CMakeLists.txt: + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration + "[^"]+")?.)* ++ +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt index 3abca0a..27af911 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -1,11 +1,11 @@ -CMake Warning \(dev\) in CMakeLists.txt: +^CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0111 is not set: An imported target missing its location property fails during generation. Run "cmake --help-policy CMP0111" for policy details. Use the cmake_policy command to set the policy and suppress this warning. IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration - ".+")?. + "[^"]+")?. This warning is for project developers. Use -Wno-dev to suppress it. + CMake Warning \(dev\) in CMakeLists.txt: @@ -15,7 +15,7 @@ CMake Warning \(dev\) in CMakeLists.txt: warning. IMPORTED_LOCATION not set for imported target "static_lib"( configuration - ".+")?. + "[^"]+")?. This warning is for project developers. Use -Wno-dev to suppress it. + CMake Warning \(dev\) in CMakeLists.txt: @@ -25,5 +25,15 @@ CMake Warning \(dev\) in CMakeLists.txt: warning. IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration - ".+")?. -This warning is for project developers. Use -Wno-dev to suppress it. + "[^"]+")?. +This warning is for project developers. Use -Wno-dev to suppress it.( ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target missing its location property + fails during generation. Run "cmake --help-policy CMP0111" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration + "[^"]+")?. +This warning is for project developers. Use -Wno-dev to suppress it.)*$ -- cgit v0.12 From f06f4b517cad32ec619774ce8a3a529c3ae32ebd Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Nov 2020 15:00:27 -0500 Subject: cmTarget: Do not enforce CMP0111 on imported INTERFACE libraries Fix logic added by commit 359c500a24 (cmTarget: Raise error if imported target location is not set, 2020-08-08, v3.19.0-rc1~273^2) to exclude INTERFACE libraries from the policy. They have no location. Fixes: #21470 --- Source/cmTarget.cxx | 56 +++++++++++++++-------------- Tests/RunCMake/CMP0111/CMP0111-Common.cmake | 5 +-- Tests/RunCMake/CMP0111/main.cpp | 3 -- Tests/RunCMake/CMP0111/module.cpp | 4 +++ 4 files changed, 36 insertions(+), 32 deletions(-) delete mode 100644 Tests/RunCMake/CMP0111/main.cpp create mode 100644 Tests/RunCMake/CMP0111/module.cpp diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e076d1e..d26de9c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2045,35 +2045,37 @@ std::string cmTarget::ImportedGetFullPath( } if (result.empty()) { - auto message = [&]() -> std::string { - std::string unset; - std::string configuration; - - if (artifact == cmStateEnums::RuntimeBinaryArtifact) { - unset = "IMPORTED_LOCATION"; - } else if (artifact == cmStateEnums::ImportLibraryArtifact) { - unset = "IMPORTED_IMPLIB"; - } - - if (!config.empty()) { - configuration = cmStrCat(" configuration \"", config, "\""); - } + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { + auto message = [&]() -> std::string { + std::string unset; + std::string configuration; + + if (artifact == cmStateEnums::RuntimeBinaryArtifact) { + unset = "IMPORTED_LOCATION"; + } else if (artifact == cmStateEnums::ImportLibraryArtifact) { + unset = "IMPORTED_IMPLIB"; + } - return cmStrCat(unset, " not set for imported target \"", - this->GetName(), "\"", configuration, "."); - }; + if (!config.empty()) { + configuration = cmStrCat(" configuration \"", config, "\""); + } - switch (this->GetPolicyStatus(cmPolicies::CMP0111)) { - case cmPolicies::WARN: - impl->Makefile->IssueMessage( - MessageType::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(cmPolicies::CMP0111) + "\n" + - message()); - CM_FALLTHROUGH; - case cmPolicies::OLD: - break; - default: - impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, message()); + return cmStrCat(unset, " not set for imported target \"", + this->GetName(), "\"", configuration, "."); + }; + + switch (this->GetPolicyStatus(cmPolicies::CMP0111)) { + case cmPolicies::WARN: + impl->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmPolicies::GetPolicyWarning(cmPolicies::CMP0111) + "\n" + + message()); + CM_FALLTHROUGH; + case cmPolicies::OLD: + break; + default: + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, message()); + } } result = cmStrCat(this->GetName(), "-NOTFOUND"); diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake index 564169d..c31e4ba 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -4,6 +4,7 @@ set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder") add_library(unknown_lib UNKNOWN IMPORTED) add_library(static_lib STATIC IMPORTED) add_library(shared_lib SHARED IMPORTED) +add_library(interface_lib INTERFACE IMPORTED) -add_executable(executable main.cpp) -target_link_libraries(executable unknown_lib static_lib shared_lib) +add_library(module MODULE module.cpp) +target_link_libraries(module unknown_lib static_lib shared_lib interface_lib) diff --git a/Tests/RunCMake/CMP0111/main.cpp b/Tests/RunCMake/CMP0111/main.cpp deleted file mode 100644 index 5047a34..0000000 --- a/Tests/RunCMake/CMP0111/main.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int main() -{ -} diff --git a/Tests/RunCMake/CMP0111/module.cpp b/Tests/RunCMake/CMP0111/module.cpp new file mode 100644 index 0000000..b82bb31 --- /dev/null +++ b/Tests/RunCMake/CMP0111/module.cpp @@ -0,0 +1,4 @@ +int module() +{ + return 0; +} -- cgit v0.12 From 54ef732b0c409b3ed9376bf6cdb40d1038209ecb Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Nov 2020 15:25:57 -0500 Subject: cmVisualStudio10TargetGenerator: Avoid GetFullPath on INTERFACE library Issue: #21470 --- Source/cmVisualStudio10TargetGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a482ed6..4eb3b7f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3944,7 +3944,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries( if (managedType != cmGeneratorTarget::ManagedType::Native && this->GeneratorTarget->GetManagedType(config) != cmGeneratorTarget::ManagedType::Native && - l.Target->IsImported()) { + l.Target->IsImported() && + l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { auto location = l.Target->GetFullPath(config); if (!location.empty()) { ConvertToWindowsSlash(location); -- cgit v0.12 From 64fb825438a2fecb9eab9933d5d1b926bf6f294b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Nov 2020 08:50:26 -0500 Subject: CMake 3.19.1 --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bc0a66f..e57e02e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 19) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 1) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 1af2d1d0eac17ef87d75f1a4c6d480274c12d0b0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Nov 2020 12:19:38 -0500 Subject: Tests: Add CMake_TEST_Java option to control Java tests --- .gitlab/ci/configure_macos_common.cmake | 4 +--- Tests/CMakeLists.txt | 14 +++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/configure_macos_common.cmake b/.gitlab/ci/configure_macos_common.cmake index 3d09779..4bd3c7d 100644 --- a/.gitlab/ci/configure_macos_common.cmake +++ b/.gitlab/ci/configure_macos_common.cmake @@ -2,9 +2,7 @@ # detect that Java is available and working, but a test machine then not have a # working Java installed. To work around this, just act as if Java is not # available on any CI machine. -set(Java_JAVA_EXECUTABLE "" CACHE FILEPATH "") -set(Java_JAVAC_EXECUTABLE "" CACHE FILEPATH "") -set(Java_JAR_EXECUTABLE "" CACHE FILEPATH "") +set(CMake_TEST_Java 0 CACHE FILEPATH "") # Qt binaries get placed inside the source directory, which causes them to not # be included in the install-time rpath, but we still want them in the diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9aa401d..10406e3 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3326,9 +3326,17 @@ if(BUILD_TESTING) endif() endif() - find_package(Java COMPONENTS Development QUIET) - if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW - AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") + if(NOT DEFINED CMake_TEST_Java) + if(APPLE OR MINGW) + set(CMake_TEST_Java 0) + else() + set(CMake_TEST_Java 1) + endif() + endif() + if(CMake_TEST_Java) + find_package(Java COMPONENTS Development QUIET) + endif() + if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE) set(JavaExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) ADD_TEST_MACRO(JavaExportImport JavaExportImport) -- cgit v0.12 From 928ca50b6ffd3c095a0df91c89de5d6ecb446b6c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Nov 2020 14:27:43 -0500 Subject: Tests: Teach RunCMake to ignore Xcode install_name_tool signature warnings The `install_name_tool` may warn: install_name_tool: warning: changes being made to the file will invalidate the code signature in: ... Teach RunCMake to drop such incidental lines before matching against expected output. --- Tests/RunCMake/RunCMake.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 7d96e50..e8fbd6a 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -152,6 +152,7 @@ function(run_cmake test) "|Please obtain a new version at" "|contact PGI Sales at" + "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" "|[^\n]*objc[^\n]*: Class AMSupportURL[^\n]* One of the two will be used. Which one is undefined." "|[^\n]*is a member of multiple groups" -- cgit v0.12 From 5213328008f12f97a2a9d124946f1a40a3f7dc14 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Nov 2020 13:18:05 -0500 Subject: gitlab-ci: update macOS jobs to use Xcode 12.2 --- .gitlab/os-macos.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index db6f3bf..d9df621 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -7,7 +7,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci ext/$CI_CONCURRENT_ID" # TODO: Factor this out so that each job selects the Xcode version to # use so that different versions can be tested in a single pipeline. - DEVELOPER_DIR: "/Applications/Xcode-12.0.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode-12.2.app/Contents/Developer" # Avoid conflicting with other projects running on the same machine. SCCACHE_SERVER_PORT: 4227 @@ -63,7 +63,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-12.0 + - xcode-12.2 - nonconcurrent .macos_builder_tags_package: @@ -71,7 +71,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-12.0 + - xcode-12.2 - nonconcurrent - finder @@ -80,7 +80,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-12.0 + - xcode-12.2 - concurrent ## macOS-specific scripts -- cgit v0.12 From 20807a188299b5f070cf145e40539a30761975ff Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 24 Nov 2020 18:50:32 +0200 Subject: CUDA: Fix user-set architectures during detection with Visual Studio If the user specifies CMAKE_CUDA_ARCHITECTURES we use those during detection and error out if they don't work. For Visual Studio a dummy project file is used instead of invoking the compiler directly. NVCC would thus use its default and we'd fail if CMAKE_CUDA_ARCHITECTURES was anything other than NVCC's default. Use the necessary project file variable in CMakeDetermineCompilerId.cmake to match other generators. Fixes #21492. --- Modules/CMakeDetermineCompilerId.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 44332a6..1feaf91 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -368,7 +368,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}") set(id_compile "CudaCompile") - set(id_ItemDefinitionGroup_entry "%(AdditionalOptions)-v") + if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) + set(cuda_target "64") + endif() + foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) + string(REGEX MATCH "[0-9]+" arch_name "${arch}") + string(APPEND cuda_codegen "compute_${arch_name},sm_${arch_name};") + endforeach() + set(id_ItemDefinitionGroup_entry "${cuda_target}%(AdditionalOptions)-v${cuda_codegen}") set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR) set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc") @@ -378,9 +385,6 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} string(CONCAT id_Import_props [[]]) string(CONCAT id_Import_targets [[]]) endif() - if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) - set(id_ItemDefinitionGroup_entry "64%(AdditionalOptions)-v") - endif() if(CMAKE_CUDA_FLAGS MATCHES "(^| )-cudart +shared( |$)") set(id_Link_AdditionalDependencies "cudart.lib") else() -- cgit v0.12 From 01d91ae5f26c25fe11e4eedd16ed8d8163636015 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 25 Nov 2020 08:12:25 -0500 Subject: Tests: Fix RunCMake.Check* conditions for enabling Fortran --- Tests/RunCMake/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7000b79..615bf20 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -539,10 +539,13 @@ add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILE add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA} - -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) + -DCMake_TEST_ISPC=${CMake_TEST_ISPC} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) add_RunCMake_test(CheckSourceCompiles -DCMake_TEST_CUDA=${CMake_TEST_CUDA} - -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) -add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + -DCMake_TEST_ISPC=${CMake_TEST_ISPC} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) +add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) set_property(TEST RunCMake.CheckCompilerFlag RunCMake.CheckSourceCompiles RunCMake.CheckSourceRuns -- cgit v0.12 From f3d4254b3d2437938440257cd989cb87da517e01 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 25 Nov 2020 07:52:53 -0500 Subject: Check*: Tolerate variables set with names of languages Fix the language checks added by commit 90dead024c (CheckCompilerFlag: unified way to check compiler flags per language, 2020-09-25, v3.19.0-rc1~88^2), commit 10ae907de0 (CheckSoureCompiles: Add a unified way to check if a source compiles, 2020-09-14, v3.19.0-rc1~118^2~1), and commit 357e2ef429 (CheckSoureRuns: Add a unified way to check if a source runs, 2020-09-14, v3.19.0-rc1~118^2) to work when variables of the language names are set. Fixes: #21500 --- Modules/Internal/CheckCompilerFlag.cmake | 14 +++++++------- Modules/Internal/CheckSourceCompiles.cmake | 14 +++++++------- Modules/Internal/CheckSourceRuns.cmake | 12 ++++++------ Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake | 2 ++ .../RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake | 2 ++ .../RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake | 2 ++ .../CheckCompilerFlag/CheckFortranCompilerFlag.cmake | 2 ++ .../RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake | 2 ++ .../CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake | 2 ++ .../CheckSourceCompiles/CheckCSourceCompiles.cmake | 2 ++ .../CheckSourceCompiles/CheckCUDASourceCompiles.cmake | 2 ++ .../CheckSourceCompiles/CheckCXXSourceCompiles.cmake | 2 ++ .../CheckSourceCompiles/CheckFortranSourceCompiles.cmake | 2 ++ .../CheckSourceCompiles/CheckOBJCSourceCompiles.cmake | 2 ++ .../CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake | 2 ++ Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake | 2 ++ Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake | 2 ++ Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake | 2 ++ .../RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake | 2 ++ Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake | 2 ++ Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake | 2 ++ 21 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Modules/Internal/CheckCompilerFlag.cmake b/Modules/Internal/CheckCompilerFlag.cmake index f790d87..6b2a11e 100644 --- a/Modules/Internal/CheckCompilerFlag.cmake +++ b/Modules/Internal/CheckCompilerFlag.cmake @@ -11,20 +11,20 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_src "int main(void) { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_src "int main() { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_src "__host__ int main() { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" # Host GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_src " program test\n stop\n end program") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Fortran") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_src [=[ #ifndef __OBJC__ # error "Not an Objective-C compiler" @@ -32,7 +32,7 @@ function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) int main(void) { return 0; }]=]) set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_src [=[ #ifndef __OBJC__ # error "Not an Objective-C++ compiler" @@ -40,7 +40,7 @@ int main(void) { return 0; }]=]) int main(void) { return 0; }]=]) set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL ISPC) + elseif(_lang STREQUAL "ISPC") set(_lang_src "float func(uniform int32, float a) { return a / 2.25; }") else() message (SEND_ERROR "check_compiler_flag: ${_lang}: unknown language.") diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index 91c8964..3b2152a 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -10,25 +10,25 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) if(NOT DEFINED "${_var}") - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_textual "C") set(_lang_ext "c") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_textual "C++") set(_lang_ext "cxx") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_textual "CUDA") set(_lang_ext "cu") - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_textual "Fortran") set(_lang_ext "F90") - elseif(_lang STREQUAL ISPC) + elseif(_lang STREQUAL "ISPC") set(_lang_textual "ISPC") set(_lang_ext "ispc") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_textual "Objective-C") set(_lang_ext "m") - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_textual "Objective-C++") set(_lang_ext "mm") else() diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index 3a4b758..676f3d0 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -10,22 +10,22 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) if(NOT DEFINED "${_var}") - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_textual "C") set(_lang_ext "c") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_textual "C++") set(_lang_ext "cxx") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_textual "CUDA") set(_lang_ext "cu") - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_textual "Fortran") set(_lang_ext "F90") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_textual "Objective-C") set(_lang_ext "m") - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_textual "Objective-C++") set(_lang_ext "mm") else() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake index 095fd54..6483f11 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckCompilerFlag) +set(C 1) # test that this is tolerated + check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid C compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake index a40699c..681a546 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckCompilerFlag) +set(CUDA 1) # test that this is tolerated + check_compiler_flag(CUDA "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CUDA compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake index bbc104e..60e9755 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckCompilerFlag) +set(CXX 1) # test that this is tolerated + check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CXX compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake index 220ee29..7bb88b1 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (Fortran) include(CheckCompilerFlag) +set(Fortran 1) # test that this is tolerated + check_compiler_flag(Fortran "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid Fortran compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake index e9344ca..f250f8d 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckCompilerFlag) +set(OBJC 1) # test that this is tolerated + check_compiler_flag(OBJC "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid OBJC compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake index 503a1de..bc940a6 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckCompilerFlag) +set(OBJCXX 1) # test that this is tolerated + check_compiler_flag(OBJCXX "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid OBJCXX compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake index cf46189..4f73622 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckSourceCompiles) +set(C 1) # test that this is tolerated + check_source_compiles(C "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid C source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake index 1e6e6b2..2190649 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckSourceCompiles) +set(CUDA 1) # test that this is tolerated + check_source_compiles(CUDA "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CUDA source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake index ec01d42..97c9c30 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckSourceCompiles) +set(CXX 1) # test that this is tolerated + check_source_compiles(CXX "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CXX source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake index 1d4e16d..48dc525 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake @@ -3,6 +3,8 @@ enable_language (Fortran) include(CheckSourceCompiles) +set(Fortran 1) # test that this is tolerated + check_source_compiles(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake index 2f53cfc4..76a5009 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckSourceCompiles) +set(OBJC 1) # test that this is tolerated + check_source_compiles(OBJC [[ #import int main() { diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake index 805d513..814237e 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckSourceCompiles) +set(OBJCXX 1) # test that this is tolerated + check_source_compiles(OBJCXX [[ #include #import diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake index 3029ac2..96a1027 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckSourceRuns) +set(C 1) # test that this is tolerated + check_source_runs(C "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "C check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake index 01e5ac8..ea5f4f9 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckSourceRuns) +set(CUDA 1) # test that this is tolerated + check_source_runs(CUDA "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "CUDA check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake index d47ddda..c4bef6e 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckSourceRuns) +set(CXX 1) # test that this is tolerated + check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake index 2a1fdfe..50e8ec8 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake @@ -3,6 +3,8 @@ enable_language (Fortran) include(CheckSourceRuns) +set(Fortran 1) # test that this is tolerated + check_source_runs(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake index 55f28f3..b828352 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckSourceRuns) +set(OBJC 1) # test that this is tolerated + check_source_runs(OBJC [[ #import int main() { diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake index a218acd..8a56f13 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckSourceRuns) +set(OBJCXX 1) # test that this is tolerated + check_source_runs(OBJCXX [[ #include #import -- cgit v0.12 From 34f6d767552b60436d2d6aec35ae2a3d137a8b20 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 25 Nov 2020 14:49:41 +0000 Subject: QNX: Do not disable compiler extensions for CMake itself The `set(CMAKE_CXX_EXTENSIONS FALSE)` option has the effect of passing compile option `-std=c++NN` instead of `-std=gnu++NN`. On some platforms, the latter form (or the secondary effects that it has, such as setting _XOPEN_SOURCE) is required. This typically affects platforms such as mingw, cygwin and QNX. The GNU-like compiers default to `-std=gnu++NN`, which means that users can typically build source code on those platforms by default. While the `set(CMAKE_CXX_EXTENSIONS FALSE)` option was set here in commit f034b0f6 (CMake compilation: do not use compiler extensions, 2020-03-14), the other changes in that commit added `#defines` which become required in the absense of use of `-std=gnu++NN`. However, only platforms regularly tested in the cmake dashboard were ported, as is reasonable. That made CMake fail to compile on QNX and perhaps other platforms which for which no one is submitting regular testing to the cmake dashboard. Make the `set(CMAKE_CXX_EXTENSIONS FALSE)` option conditional on non-QNX to restore the QNX build. Issue: #21503 --- Source/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ba378fb..ca56d3a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -2,9 +2,12 @@ # file Copyright.txt or https://cmake.org/licensing for details. # To ensure maximum portability across various compilers and platforms -# deactivate any compiler extensions -set(CMAKE_C_EXTENSIONS FALSE) -set(CMAKE_CXX_EXTENSIONS FALSE) +# deactivate any compiler extensions. Skip this for QNX, where additional +# work is needed to build without compiler extensions. +if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(CMAKE_C_EXTENSIONS FALSE) + set(CMAKE_CXX_EXTENSIONS FALSE) +endif() include(CheckIncludeFile) # Check if we can build support for ELF parsing. -- cgit v0.12 From 14ecf9c2f6edfae4033d9311f79d79d0d07fc1cf Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Wed, 25 Nov 2020 16:36:12 +0100 Subject: FPHSA: ensure it can be used outside 'find_package' Fixes: #21505 --- Modules/FindPackageHandleStandardArgs.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 7af0171..7e17277 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -275,8 +275,10 @@ function(FIND_PACKAGE_CHECK_VERSION version result) unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE) endif() - if (CMAKE_FIND_PACKAGE_NAME) - set (package ${CMAKE_FIND_PACKAGE_NAME}) + if (_CMAKE_FPHSA_PACKAGE_NAME) + set (package "${_CMAKE_FPHSA_PACKAGE_NAME}") + elseif (CMAKE_FIND_PACKAGE_NAME) + set (package "${CMAKE_FIND_PACKAGE_NAME}") else() message (FATAL_ERROR "find_package_check_version(): Cannot be used outside a 'Find Module'") endif() @@ -436,6 +438,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) "will be used.") endif() + # to propagate package name to FIND_PACKAGE_CHECK_VERSION + set(_CMAKE_FPHSA_PACKAGE_NAME "${_NAME}") + # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") -- cgit v0.12 From 72f6b4bfbe84a369fbdf4c9671470ba8c3ce14cc Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 25 Nov 2020 10:45:12 -0500 Subject: Modules: Rename Internal/CMake{CheckCompiler => TryCompilerOrLinker}Flag Rename the `CheckPIESupported` helper functions so that they don't clobber other internal functions. Also rename them to document they can't be unified with `CheckCompilerFlag`. Fixes: #21497 --- Modules/CheckPIESupported.cmake | 8 +- Modules/Compiler/GNU.cmake | 1 - Modules/Internal/CMakeCheckCompilerFlag.cmake | 158 --------------------- .../Internal/CMakeTryCompilerOrLinkerFlag.cmake | 158 +++++++++++++++++++++ 4 files changed, 163 insertions(+), 162 deletions(-) delete mode 100644 Modules/Internal/CMakeCheckCompilerFlag.cmake create mode 100644 Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index a99d8c4..fb87822 100644 --- a/Modules/CheckPIESupported.cmake +++ b/Modules/CheckPIESupported.cmake @@ -62,7 +62,7 @@ Examples #]=======================================================================] -include (Internal/CMakeCheckCompilerFlag) +include (Internal/CMakeTryCompilerOrLinkerFlag) function (check_pie_supported) cmake_policy(GET CMP0083 cmp0083) @@ -109,14 +109,16 @@ function (check_pie_supported) foreach(lang IN LISTS CHECK_PIE_LANGUAGES) if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER) - cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_PIE}" + cmake_try_compiler_or_linker_flag(${lang} + "${CMAKE_${lang}_LINK_OPTIONS_PIE}" CMAKE_${lang}_LINK_PIE_SUPPORTED OUTPUT_VARIABLE output) if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED) string (APPEND outputs "PIE (${lang}): ${output}\n") endif() - cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}" + cmake_try_compiler_or_linker_flag(${lang} + "${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}" CMAKE_${lang}_LINK_NO_PIE_SUPPORTED OUTPUT_VARIABLE output) if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 668a6a9..81ab3a2 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -9,7 +9,6 @@ endif() set(__COMPILER_GNU 1) include(Compiler/CMakeCommonCompilerMacros) -include(Internal/CMakeCheckCompilerFlag) set(__pch_header_C "c-header") set(__pch_header_CXX "c++-header") diff --git a/Modules/Internal/CMakeCheckCompilerFlag.cmake b/Modules/Internal/CMakeCheckCompilerFlag.cmake deleted file mode 100644 index 9c8dfb6..0000000 --- a/Modules/Internal/CMakeCheckCompilerFlag.cmake +++ /dev/null @@ -1,158 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=[ - -NOTE: This function is used internally by CMake. Projects should not include - this file directly. - -The cmake_check_compiler_flag() function can be used to compile and link a -source file to check whether a specific compiler or linker flag is supported. -The function does not use the try_compile() command so as to avoid infinite -recursion. It may not work for all platforms or toolchains, the caller is -responsible for ensuring it is only called in valid situations. - - cmake_check_compiler_flag( - [SRC_EXT ] [COMMAND_PATTERN ] - [FAIL_REGEX ...] - [OUTPUT_VARIABLE ]) - -Parameters: - - Language to check. - - The flag to add to the compile/link command line. - - Boolean output variable. It will be stored in the cache as an - internal variable and if true, will cause future tests that assign - to that variable to be bypassed. - -Optional parameters: - SRC_EXT - Overrides the extension of the source file used for the - check. Defaults are 'c' (C), 'cxx' (CXX), 'F' (Fortran). - COMMAND_PATTERN - Pattern to be used for the command line. The default is - ' -o ' - FAIL_REGEX - List of additional regular expressions that, if matched by - the output, give a failed result for the check. A common - set of regular expressions will be included in addition to - those given by FAIL_REGEX. - OUTPUT_VARIABLE - Set variable with details about any error. -#]=] - -include_guard(GLOBAL) -include(CMakeCheckCompilerFlagCommonPatterns) - -function(CMAKE_CHECK_COMPILER_FLAG lang flag result) - # Cache results between runs similar to check__source_compiles() - if(DEFINED ${result}) - return() - endif() - - set(comment "Is the '${flag}' option(s) supported") - string(REPLACE ";" " " comment "${comment}") - - if (NOT lang MATCHES "^(C|CXX|Fortran|ASM)$") - # other possible languages are not supported - # log message to keep trace of this problem... - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Function 'CMAKE_CHECK_COMPILER_FLAG' called with unsupported language: ${lang}\n") - set(${result} FALSE CACHE INTERNAL ${comment}) - return() - endif() - if (lang STREQUAL "ASM") - # assume ASM compiler is a multi-language compiler, so supports C language as well - set(check_lang C) - else() - set(check_lang ${lang}) - endif() - - cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN;OUTPUT_VARIABLE" "FAIL_REGEX" ${ARGN}) - - if (NOT CCCF_COMMAND_PATTERN) - set (CCCF_COMMAND_PATTERN " -o ") - endif() - - list (APPEND CCCF_FAIL_REGEX "argument unused during compilation") # clang - if (check_lang STREQUAL "C") - list(APPEND CCCF_FAIL_REGEX - "command line option .* is valid for .* but not for C") # GNU - elseif(check_lang STREQUAL "CXX") - list(APPEND CCCF_FAIL_REGEX - "command line option .* is valid for .* but not for C\\+\\+") # GNU - elseif(check_lang STREQUAL "Fortran") - list(APPEND CCCF_FAIL_REGEX - "command line option .* is valid for .* but not for Fortran") # GNU - endif() - - # Add patterns for common errors - check_compiler_flag_common_patterns(COMPILER_FLAG_COMMON_PATTERNS) - foreach(arg IN LISTS COMPILER_FLAG_COMMON_PATTERNS) - if(arg MATCHES "^FAIL_REGEX$") - continue() - endif() - list(APPEND CCCF_FAIL_REGEX "${arg}") - endforeach() - - if(NOT CCCF_SRC_EXT) - if (check_lang STREQUAL "C") - set(CCCF_SRC_EXT c) - elseif(check_lang STREQUAL "CXX") - set(CCCF_SRC_EXT cxx) - elseif(check_lang STREQUAL "Fortran") - set(CCCF_SRC_EXT F) - endif() - endif() - - if (CCCF_OUTPUT_VARIABLE) - unset(${CCCF_OUTPUT_VARIABLE} PARENT_SCOPE) - endif() - - # Compute the directory in which to run the test. - set(COMPILER_FLAG_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp") - # Compute source and output files. - set(COMPILER_FLAG_SRC - "${COMPILER_FLAG_DIR}/CompilerFlag${lang}.${CCCF_SRC_EXT}") - if(check_lang STREQUAL "Fortran") - file(WRITE "${COMPILER_FLAG_SRC}" - " program simple\n end program simple\n") - else() - file(WRITE "${COMPILER_FLAG_SRC}" "int main (void)\n{ return 0; }\n") - endif() - get_filename_component(COMPILER_FLAG_EXE "${COMPILER_FLAG_SRC}" NAME_WE) - string(APPEND COMPILER_FLAG_EXE "${CMAKE_EXECUTABLE_SUFFIX}") - - # Build command line - separate_arguments(CCCF_COMMAND_PATTERN UNIX_COMMAND - "${CCCF_COMMAND_PATTERN}") - list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${COMPILER_FLAG_SRC}") - list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${COMPILER_FLAG_EXE}") - list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${flag}") - - execute_process( - COMMAND "${CMAKE_COMMAND}" -E env LC_ALL=C LC_MESSAGES=C LANG=C - "${CMAKE_${lang}_COMPILER}" ${CCCF_COMMAND_PATTERN} - WORKING_DIRECTORY "${COMPILER_FLAG_DIR}" - OUTPUT_VARIABLE COMPILER_FLAG_OUTPUT - ERROR_VARIABLE COMPILER_FLAG_OUTPUT - RESULT_VARIABLE COMPILER_FLAG_RESULT) - - # Record result in the cache so we can avoid re-testing every CMake run - if (COMPILER_FLAG_RESULT) - set(${result} FALSE CACHE INTERNAL ${comment}) - else() - foreach(regex IN LISTS CCCF_FAIL_REGEX) - if(COMPILER_FLAG_OUTPUT MATCHES "${regex}") - set(${result} FALSE CACHE INTERNAL ${comment}) - endif() - endforeach() - endif() - if (DEFINED ${result}) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the ${flag} option " - "is supported for ${lang} language failed with the following output:\n" - "${COMPILER_FLAG_OUTPUT}\n") - if (CCCF_OUTPUT_VARIABLE) - set(${CCCF_OUTPUT_VARIABLE} "${COMPILER_FLAG_OUTPUT}" PARENT_SCOPE) - endif() - return() - endif() - - set(${result} TRUE CACHE INTERNAL ${comment}) -endfunction() diff --git a/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake b/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake new file mode 100644 index 0000000..d6fa5f0 --- /dev/null +++ b/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake @@ -0,0 +1,158 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=[ + +NOTE: This function is used internally by CMake. Projects should not include + this file directly. + +The cmake_try_compiler_or_linker_flag() function can be used to compile and link a +source file to check whether a specific compiler or linker flag is supported. +The function does not use the try_compile() command so as to avoid infinite +recursion. It may not work for all platforms or toolchains, the caller is +responsible for ensuring it is only called in valid situations. + + cmake_try_compiler_or_linker_flag( + [SRC_EXT ] [COMMAND_PATTERN ] + [FAIL_REGEX ...] + [OUTPUT_VARIABLE ]) + +Parameters: + - Language to check. + - The flag to add to the compile/link command line. + - Boolean output variable. It will be stored in the cache as an + internal variable and if true, will cause future tests that assign + to that variable to be bypassed. + +Optional parameters: + SRC_EXT - Overrides the extension of the source file used for the + check. Defaults are 'c' (C), 'cxx' (CXX), 'F' (Fortran). + COMMAND_PATTERN - Pattern to be used for the command line. The default is + ' -o ' + FAIL_REGEX - List of additional regular expressions that, if matched by + the output, give a failed result for the check. A common + set of regular expressions will be included in addition to + those given by FAIL_REGEX. + OUTPUT_VARIABLE - Set variable with details about any error. +#]=] + +include_guard(GLOBAL) +include(CMakeCheckCompilerFlagCommonPatterns) + +function(CMAKE_TRY_COMPILER_OR_LINKER_FLAG lang flag result) + # Cache results between runs similar to check__source_compiles() + if(DEFINED ${result}) + return() + endif() + + set(comment "Is the '${flag}' option(s) supported") + string(REPLACE ";" " " comment "${comment}") + + if (NOT lang MATCHES "^(C|CXX|Fortran|ASM)$") + # other possible languages are not supported + # log message to keep trace of this problem... + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Function 'CMAKE_CHECK_COMPILER_FLAG' called with unsupported language: ${lang}\n") + set(${result} FALSE CACHE INTERNAL ${comment}) + return() + endif() + if (lang STREQUAL "ASM") + # assume ASM compiler is a multi-language compiler, so supports C language as well + set(check_lang C) + else() + set(check_lang ${lang}) + endif() + + cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN;OUTPUT_VARIABLE" "FAIL_REGEX" ${ARGN}) + + if (NOT CCCF_COMMAND_PATTERN) + set (CCCF_COMMAND_PATTERN " -o ") + endif() + + list (APPEND CCCF_FAIL_REGEX "argument unused during compilation") # clang + if (check_lang STREQUAL "C") + list(APPEND CCCF_FAIL_REGEX + "command line option .* is valid for .* but not for C") # GNU + elseif(check_lang STREQUAL "CXX") + list(APPEND CCCF_FAIL_REGEX + "command line option .* is valid for .* but not for C\\+\\+") # GNU + elseif(check_lang STREQUAL "Fortran") + list(APPEND CCCF_FAIL_REGEX + "command line option .* is valid for .* but not for Fortran") # GNU + endif() + + # Add patterns for common errors + check_compiler_flag_common_patterns(COMPILER_FLAG_COMMON_PATTERNS) + foreach(arg IN LISTS COMPILER_FLAG_COMMON_PATTERNS) + if(arg MATCHES "^FAIL_REGEX$") + continue() + endif() + list(APPEND CCCF_FAIL_REGEX "${arg}") + endforeach() + + if(NOT CCCF_SRC_EXT) + if (check_lang STREQUAL "C") + set(CCCF_SRC_EXT c) + elseif(check_lang STREQUAL "CXX") + set(CCCF_SRC_EXT cxx) + elseif(check_lang STREQUAL "Fortran") + set(CCCF_SRC_EXT F) + endif() + endif() + + if (CCCF_OUTPUT_VARIABLE) + unset(${CCCF_OUTPUT_VARIABLE} PARENT_SCOPE) + endif() + + # Compute the directory in which to run the test. + set(COMPILER_FLAG_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp") + # Compute source and output files. + set(COMPILER_FLAG_SRC + "${COMPILER_FLAG_DIR}/CompilerFlag${lang}.${CCCF_SRC_EXT}") + if(check_lang STREQUAL "Fortran") + file(WRITE "${COMPILER_FLAG_SRC}" + " program simple\n end program simple\n") + else() + file(WRITE "${COMPILER_FLAG_SRC}" "int main (void)\n{ return 0; }\n") + endif() + get_filename_component(COMPILER_FLAG_EXE "${COMPILER_FLAG_SRC}" NAME_WE) + string(APPEND COMPILER_FLAG_EXE "${CMAKE_EXECUTABLE_SUFFIX}") + + # Build command line + separate_arguments(CCCF_COMMAND_PATTERN UNIX_COMMAND + "${CCCF_COMMAND_PATTERN}") + list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${COMPILER_FLAG_SRC}") + list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${COMPILER_FLAG_EXE}") + list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "" "${flag}") + + execute_process( + COMMAND "${CMAKE_COMMAND}" -E env LC_ALL=C LC_MESSAGES=C LANG=C + "${CMAKE_${lang}_COMPILER}" ${CCCF_COMMAND_PATTERN} + WORKING_DIRECTORY "${COMPILER_FLAG_DIR}" + OUTPUT_VARIABLE COMPILER_FLAG_OUTPUT + ERROR_VARIABLE COMPILER_FLAG_OUTPUT + RESULT_VARIABLE COMPILER_FLAG_RESULT) + + # Record result in the cache so we can avoid re-testing every CMake run + if (COMPILER_FLAG_RESULT) + set(${result} FALSE CACHE INTERNAL ${comment}) + else() + foreach(regex IN LISTS CCCF_FAIL_REGEX) + if(COMPILER_FLAG_OUTPUT MATCHES "${regex}") + set(${result} FALSE CACHE INTERNAL ${comment}) + endif() + endforeach() + endif() + if (DEFINED ${result}) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the ${flag} option " + "is supported for ${lang} language failed with the following output:\n" + "${COMPILER_FLAG_OUTPUT}\n") + if (CCCF_OUTPUT_VARIABLE) + set(${CCCF_OUTPUT_VARIABLE} "${COMPILER_FLAG_OUTPUT}" PARENT_SCOPE) + endif() + return() + endif() + + set(${result} TRUE CACHE INTERNAL ${comment}) +endfunction() -- cgit v0.12 From ca289abea53fb0bbeb3bf84a65a4685476ae9d15 Mon Sep 17 00:00:00 2001 From: Sam Freed Date: Wed, 25 Nov 2020 12:58:31 -0500 Subject: Help: Fix presets typo (longDescription to displayName) --- Help/manual/cmake-presets.7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 62c4b7c..6f137c4 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -93,7 +93,7 @@ Format An optional array of strings representing the names of presets to inherit from. The preset will inherit all of the fields from the ``inherits`` presets by default (except ``name``, ``hidden``, ``inherits``, - ``description``, and ``longDescription``), but can override them as + ``description``, and ``displayName``), but can override them as desired. If multiple ``inherits`` presets provide conflicting values for the same field, the earlier preset in the ``inherits`` list will be preferred. Presets in ``CMakePresets.json`` may not inherit from presets -- cgit v0.12 From 9ac98767576e459060a8c9b8e0aa97aa14f7380c Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 30 Nov 2020 15:31:45 +0100 Subject: Clang on Windows: 'LINKER:' prefix must be honored Fixes: #21094 --- Modules/Platform/Windows-Clang.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 2261c90..f90c36a 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -35,6 +35,9 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1) set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) + if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)") math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") endif() -- cgit v0.12 From 35432aabdaf16611ef5faf0e3eec29b7847c1026 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 27 Nov 2020 09:39:02 -0800 Subject: PCH: Fix compiler errors on iOS multi-arch using Ninja Multi-Config Fixes: #21401 --- Source/cmLocalGenerator.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4e6010c..65ddf95 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2506,8 +2506,10 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) } if (!useMultiArchPch.empty()) { - target->Target->SetProperty( - cmStrCat(lang, "_COMPILE_OPTIONS_USE_PCH"), useMultiArchPch); + + target->Target->AppendProperty( + cmStrCat(lang, "_COMPILE_OPTIONS_USE_PCH"), + cmStrCat("$<$:", useMultiArchPch, ">")); } } -- cgit v0.12 From 11f42593626e1909ac9d56d189c6b3540bfff866 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 30 Nov 2020 14:54:45 -0500 Subject: Ninja: Clean metadata after regen during build on Windows with 1.10.2+ Ninja 1.10.2 fixes support for `generator = 1` rules that run metadata update commands during regeneration while a build is running. Update the condition added by commit ccaa0bccc4 (Ninja: Do not clean metadata when re-generating inside a running build, 2020-01-27, v3.17.0-rc1~73^2) to remove our workaround when Ninja is new enough. Fixes: #20274 --- Source/cmGlobalNinjaGenerator.cxx | 8 ++++++-- Source/cmGlobalNinjaGenerator.h | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index cf45da9..d477c7d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -539,10 +539,11 @@ void cmGlobalNinjaGenerator::Generate() this->CloseBuildFileStreams(); #ifdef _WIN32 - // The ninja tools will not be able to update metadata on Windows + // Older ninja tools will not be able to update metadata on Windows // when we are re-generating inside an existing 'ninja' invocation // because the outer tool has the files open for write. - if (!this->GetCMakeInstance()->GetRegenerateDuringBuild()) + if (this->NinjaSupportsMetadataOnRegeneration || + !this->GetCMakeInstance()->GetRegenerateDuringBuild()) #endif { this->CleanMetaData(); @@ -691,6 +692,9 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaSupportsMultipleOutputs = !cmSystemTools::VersionCompare( cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), RequiredNinjaVersionForMultipleOutputs().c_str()); + this->NinjaSupportsMetadataOnRegeneration = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForMetadataOnRegeneration().c_str()); } bool cmGlobalNinjaGenerator::CheckLanguages( diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a0724ac..3d92ec9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -373,6 +373,10 @@ public: { return "1.10"; } + static std::string RequiredNinjaVersionForMetadataOnRegeneration() + { + return "1.10.2"; + } bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; @@ -538,6 +542,7 @@ private: bool NinjaSupportsUnconditionalRecompactTool = false; bool NinjaSupportsCleanDeadTool = false; bool NinjaSupportsMultipleOutputs = false; + bool NinjaSupportsMetadataOnRegeneration = false; private: void InitOutputPathPrefix(); -- cgit v0.12 From 73d1c78bf435af11cf5245ad47530f4b4b831412 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 30 Nov 2020 15:02:10 -0500 Subject: ci: update to use ninja 1.10.2 --- .gitlab/ci/ninja.ps1 | 4 ++-- .gitlab/ci/ninja.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/ninja.ps1 b/.gitlab/ci/ninja.ps1 index 91f8b02..4cc6bcb 100755 --- a/.gitlab/ci/ninja.ps1 +++ b/.gitlab/ci/ninja.ps1 @@ -1,7 +1,7 @@ $erroractionpreference = "stop" -$version = "1.10.0" -$sha256sum = "919FD158C16BF135E8A850BB4046EC1CE28A7439EE08B977CD0B7F6B3463D178" +$version = "1.10.2" +$sha256sum = "BBDE850D247D2737C5764C927D1071CBB1F1957DCABDA4A130FA8547C12C695F" $filename = "ninja-win" $tarball = "$filename.zip" diff --git a/.gitlab/ci/ninja.sh b/.gitlab/ci/ninja.sh index 93c1ee9..9011bbc 100755 --- a/.gitlab/ci/ninja.sh +++ b/.gitlab/ci/ninja.sh @@ -2,17 +2,17 @@ set -e -readonly version="1.10.0" +readonly version="1.10.2" case "$( uname -s )" in Linux) shatool="sha256sum" - sha256sum="6566836ddf3d72ca06685b34814e0c6fa0f0943542d651d0dab3150f10307c82" + sha256sum="763464859c7ef2ea3a0a10f4df40d2025d3bb9438fcb1228404640410c0ec22d" platform="linux" ;; Darwin) shatool="shasum -a 256" - sha256sum="2ee405c0e205d55666c60cc9c0d8d04c8ede06d3ef2e2c2aabe08fd81c17d22e" + sha256sum="6fa359f491fac7e5185273c6421a000eea6a2f0febf0ac03ac900bd4d80ed2a5" platform="mac" ;; *) -- cgit v0.12 From 38bcb5c0a3accd2dd29fb7632c6b3bf31b990d82 Mon Sep 17 00:00:00 2001 From: Deniz Bahadir Date: Tue, 1 Dec 2020 00:25:39 +0100 Subject: export: Do not fail generation for separate namelink only case Update the change from commit 64690f6df0 (export: Do not fail generation for namelink-only case, 2020-10-09, v3.19.0-rc1~7^2) to also handle separate namelink-only and namelink-skip calls. Fixes: #21529 --- Source/cmExportBuildFileGenerator.cxx | 3 +++ Source/cmExportInstallFileGenerator.cxx | 3 +++ Source/cmInstallCommand.cxx | 19 +++++++++++-------- Source/cmTargetExport.h | 2 ++ Tests/RunCMake/export/RunCMakeTest.cmake | 1 + Tests/RunCMake/export/SeparateNamelinkExport.cmake | 16 ++++++++++++++++ Tests/RunCMake/install/EXPORT-SeparateNamelink.cmake | 19 +++++++++++++++++++ Tests/RunCMake/install/RunCMakeTest.cmake | 1 + 8 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 Tests/RunCMake/export/SeparateNamelinkExport.cmake create mode 100644 Tests/RunCMake/install/EXPORT-SeparateNamelink.cmake diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index dd700c5..1a31ae4 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -288,6 +288,9 @@ void cmExportBuildFileGenerator::GetTargets( if (this->ExportSet) { for (std::unique_ptr const& te : this->ExportSet->GetTargetExports()) { + if (te->NamelinkOnly) { + continue; + } targets.push_back(te->TargetName); } return; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 987ec9e..0b9b183 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -42,6 +42,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::string sep; for (std::unique_ptr const& te : this->IEGen->GetExportSet()->GetTargetExports()) { + if (te->NamelinkOnly) { + continue; + } expectedTargets += sep + this->Namespace + te->Target->GetExportName(); sep = " "; if (this->ExportedTargets.insert(te->Target).second) { diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index b99e6a3..ff08ee4 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -461,6 +461,13 @@ bool HandleTargetsMode(std::vector const& args, std::unique_ptr publicHeaderGenerator; std::unique_ptr resourceGenerator; + // Avoid selecting default destinations for PUBLIC_HEADER and + // PRIVATE_HEADER if any artifacts are specified. + bool artifactsSpecified = false; + + // Track whether this is a namelink-only rule. + bool namelinkOnly = false; + auto addTargetExport = [&]() { // Add this install rule to an export if one was specified. if (!exports.empty()) { @@ -475,20 +482,13 @@ bool HandleTargetsMode(std::vector const& args, te->ObjectsGenerator = objectGenerator.get(); te->InterfaceIncludeDirectories = cmJoin(includesArgs.GetIncludeDirs(), ";"); - + te->NamelinkOnly = namelinkOnly; helper.Makefile->GetGlobalGenerator() ->GetExportSets()[exports] .AddTargetExport(std::move(te)); } }; - // Avoid selecting default destinations for PUBLIC_HEADER and - // PRIVATE_HEADER if any artifacts are specified. - bool artifactsSpecified = false; - - // Track whether this is a namelink-only rule. - bool namelinkOnly = false; - switch (target.GetType()) { case cmStateEnums::SHARED_LIBRARY: { // Shared libraries are handled differently on DLL and non-DLL @@ -497,6 +497,7 @@ bool HandleTargetsMode(std::vector const& args, if (target.IsDLLPlatform()) { // When in namelink only mode skip all libraries on Windows. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + namelinkOnly = true; addTargetExport(); continue; } @@ -529,6 +530,7 @@ bool HandleTargetsMode(std::vector const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + namelinkOnly = true; addTargetExport(); continue; } @@ -574,6 +576,7 @@ bool HandleTargetsMode(std::vector const& args, if (target.IsFrameworkOnApple()) { // When in namelink only mode skip frameworks. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + namelinkOnly = true; addTargetExport(); continue; } diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h index cb4d8da..1e38d84 100644 --- a/Source/cmTargetExport.h +++ b/Source/cmTargetExport.h @@ -31,4 +31,6 @@ public: cmInstallFilesGenerator* HeaderGenerator; std::string InterfaceIncludeDirectories; ///@} + + bool NamelinkOnly = false; }; diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 95c8d5c..0e6020f 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -17,3 +17,4 @@ run_cmake(DependOnNotExport) run_cmake(DependOnDoubleExport) run_cmake(UnknownExport) run_cmake(NamelinkOnlyExport) +run_cmake(SeparateNamelinkExport) diff --git a/Tests/RunCMake/export/SeparateNamelinkExport.cmake b/Tests/RunCMake/export/SeparateNamelinkExport.cmake new file mode 100644 index 0000000..b006aea --- /dev/null +++ b/Tests/RunCMake/export/SeparateNamelinkExport.cmake @@ -0,0 +1,16 @@ +enable_language(CXX) +add_library(foo SHARED empty.cpp) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + COMPONENT runtime + NAMELINK_SKIP +) +install(TARGETS foo EXPORT fooExport + LIBRARY + DESTINATION lib + COMPONENT development + NAMELINK_ONLY +) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/install/EXPORT-SeparateNamelink.cmake b/Tests/RunCMake/install/EXPORT-SeparateNamelink.cmake new file mode 100644 index 0000000..5c6fa10 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-SeparateNamelink.cmake @@ -0,0 +1,19 @@ +enable_language(C) +add_library(foo SHARED empty.c) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + COMPONENT runtime + NAMELINK_SKIP +) +install(TARGETS foo EXPORT fooExport + LIBRARY + DESTINATION lib + COMPONENT development + NAMELINK_ONLY +) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 5aab88c..d64d88b 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -78,6 +78,7 @@ run_cmake(TARGETS-DESTINATION-bad) run_cmake(EXPORT-OldIFace) run_cmake(EXPORT-UnknownExport) run_cmake(EXPORT-NamelinkOnly) +run_cmake(EXPORT-SeparateNamelink) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) -- cgit v0.12 From 8eeddb1f0a73e45a4b5c54fd80e486cc706da941 Mon Sep 17 00:00:00 2001 From: Adam Weisi Date: Tue, 1 Dec 2020 09:56:21 -0500 Subject: Compiler/TI: Fix C standard flags in C-only project Use our compiler architecture variable for C rather than CXX. --- Modules/Compiler/TI-C.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index 3c97afb..bd88989 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -26,7 +26,7 @@ else() endif() -if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}}") +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_${CMAKE_C_COMPILER_ARCHITECTURE_ID}}") set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89" "--strict_ansi") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89" "--relaxed_ansi") @@ -34,8 +34,8 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_$ set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") - if(DEFINED __COMPILER_TI_C11_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} AND - CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C11_VERSION_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}}") + if(DEFINED __COMPILER_TI_C11_VERSION_${CMAKE_C_COMPILER_ARCHITECTURE_ID} AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C11_VERSION_${CMAKE_C_COMPILER_ARCHITECTURE_ID}}") set(CMAKE_C11_STANDARD_COMPILE_OPTION "--c11" "--strict_ansi") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--c11" "--relaxed_ansi") -- cgit v0.12 From 9ee4a42813b10e541e17bc3b4e50dfd99f9dab14 Mon Sep 17 00:00:00 2001 From: Justin LaPolla Date: Tue, 1 Dec 2020 10:42:06 -0600 Subject: Cray: Fix Cray compiler detection on new platforms Customer reported problems detecting the Cray compiler on their Apollo80 system. We were checking for the __CRAYXC and __CRAYXE predefined macros. These macros reflect the platform that the compiler is running on, i.e. Cray XC and Cray XE machines. Naturally, this didn't work on Apollo80. This commit uses the official Cray compiler identification macros which are defined on every platform: CCE Version C Macro C++ Macro Fortran Macro ============ ======== ========= ============= version < 9 _CRAYC _CRAYC _CRAYFTN version >= 9 __cray__ __cray__ _CRAYFTN --- Modules/CMakeCCompilerId.c.in | 4 ++-- Modules/CMakeCXXCompilerId.cpp.in | 4 ++-- Modules/CMakeFortranCompilerId.F.in | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 2f6bdb4..8ba6abc 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -26,7 +26,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; char const* qnxnto = "INFO" ":" "qnxnto[]"; #endif -#if defined(__CRAYXE) || defined(__CRAYXC) +#if defined(_CRAYC) || defined(__cray__) char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #endif @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif -#if defined(__CRAYXE) || defined(__CRAYXC) +#if defined(_CRAYC) || defined(__cray__) require += info_cray[argc]; #endif require += info_language_dialect_default[argc]; diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index a743ce7..672fff8 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -20,7 +20,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; char const* qnxnto = "INFO" ":" "qnxnto[]"; #endif -#if defined(__CRAYXE) || defined(__CRAYXC) +#if defined(_CRAYC) || defined(__cray__) char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #endif @@ -76,7 +76,7 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif -#if defined(__CRAYXE) || defined(__CRAYXC) +#if defined(_CRAYC) || defined(__cray__) require += info_cray[argc]; #endif require += info_language_dialect_default[argc]; diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 30f8d4c..7e8828b 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -108,7 +108,7 @@ #else PRINT *, 'INFO:compiler[]' #endif -#if defined(__CRAYXE) || defined(__CRAYXC) +#if defined(_CRAYFTN) PRINT *, 'INFO:compiler_wrapper[CrayPrgEnv]' #endif -- cgit v0.12 From adf108441e04e244af3ca70c6745b536d18fa13e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 1 Dec 2020 15:31:21 -0500 Subject: FindHDF5: improve error messages when a location variable isn't known --- Modules/FindHDF5.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 0a92c71..3c486ce 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -1026,7 +1026,7 @@ if (HDF5_FOUND) # Error if we still don't have the location. message(SEND_ERROR "HDF5 was found, but a different variable was set which contains " - "its location.") + "the location of the `hdf5::${hdf5_target_name}` library.") endif () add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_DEFINITIONS}") @@ -1085,7 +1085,7 @@ if (HDF5_FOUND) # Error if we still don't have the location. message(SEND_ERROR "HDF5 was found, but a different variable was set which contains " - "its location.") + "the location of the `hdf5::${hdf5_target_name}` library.") endif () add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_HL_DEFINITIONS}") -- cgit v0.12 From 175beadd4c3ba6b3e3a2f266a6643f217d39e32e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 1 Dec 2020 15:31:47 -0500 Subject: FindHDF5: support the hdf5hl_fortran-based variable names Fixes: #21537 --- Modules/FindHDF5.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 3c486ce..0c1e93b 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -1057,12 +1057,14 @@ if (HDF5_FOUND) continue () endif () + set(hdf5_alt_target_name "") if (hdf5_lang STREQUAL "C") set(hdf5_target_name "hdf5_hl") elseif (hdf5_lang STREQUAL "CXX") set(hdf5_target_name "hdf5_hl_cpp") elseif (hdf5_lang STREQUAL "Fortran") set(hdf5_target_name "hdf5_hl_fortran") + set(hdf5_alt_target_name "hdf5hl_fortran") else () continue () endif () @@ -1081,6 +1083,8 @@ if (HDF5_FOUND) set(_hdf5_location "${HDF5_${hdf5_lang}_HL_LIBRARY}") elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}") set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}}") + elseif (hdf5_alt_target_name AND DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_alt_target_name}") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_alt_target_name}}") else () # Error if we still don't have the location. message(SEND_ERROR -- cgit v0.12 From f7ff0d34f0750387f5c56483ab6ba3fb4825b62d Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sun, 29 Nov 2020 02:46:00 -0800 Subject: llvm-rc: Force C language for the clang gnu frontend When preprocessing the rc file using the clang gnu front end we need to force the source file type to a c file for the preprocessing to take place. Fixes: #21472 --- Modules/Platform/Windows-Clang.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index f90c36a..389d6ab 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -105,7 +105,7 @@ macro(__windows_compiler_clang_gnu lang) enable_language(RC) endmacro() -macro(__enable_llvm_rc_preprocessing clang_option_prefix) +macro(__enable_llvm_rc_preprocessing clang_option_prefix extra_pp_flags) # Feed the preprocessed rc file to llvm-rc if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc" OR CMAKE_RC_COMPILER MATCHES "llvm-rc") if(DEFINED CMAKE_C_COMPILER_ID) @@ -115,7 +115,7 @@ macro(__enable_llvm_rc_preprocessing clang_option_prefix) endif() if(DEFINED CMAKE_RC_PREPROCESSOR) set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}") - set(CMAKE_RC_COMPILE_OBJECT " -E cmake_llvm_rc .pp <${CMAKE_RC_PREPROCESSOR}> -DRC_INVOKED -E -- ++ -I /fo .pp") + set(CMAKE_RC_COMPILE_OBJECT " -E cmake_llvm_rc .pp <${CMAKE_RC_PREPROCESSOR}> -DRC_INVOKED ${extra_pp_flags} -E -- ++ -I /fo .pp") if(CMAKE_GENERATOR MATCHES "Ninja") set(CMAKE_NINJA_CMCLDEPS_RC 0) set(CMAKE_NINJA_DEP_TYPE_RC gcc) @@ -165,7 +165,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) include(Platform/Windows-MSVC) # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage - __enable_llvm_rc_preprocessing("-clang:") + __enable_llvm_rc_preprocessing("-clang:" "") macro(__windows_compiler_clang_base lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) @@ -181,7 +181,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(CMAKE_BUILD_TYPE_INIT Debug) - __enable_llvm_rc_preprocessing("") + __enable_llvm_rc_preprocessing("" "-x c") macro(__windows_compiler_clang_base lang) __windows_compiler_clang_gnu(${lang}) endmacro() @@ -189,7 +189,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" else() include(Platform/Windows-GNU) - __enable_llvm_rc_preprocessing("") + __enable_llvm_rc_preprocessing("" "-x c") macro(__windows_compiler_clang_base lang) __windows_compiler_gnu(${lang}) endmacro() -- cgit v0.12 From dca8800cb51eec7bda18fb47d3be76c18ff264c8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Dec 2020 10:21:56 -0500 Subject: Tests: Look for Visual Studio only on Windows hosts Update logic added by commit 6051a49c78 (Visual Studio: Add Android support, 2020-06-12, v3.19.0-rc1~619^2) to only look for VS installations using `cmake_host_system_information` on Windows hosts. Otherwise the `VS_*_DIR` keys are not available. Fixes: #21547 --- Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 10406e3..4938681 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -206,7 +206,7 @@ if(BUILD_TESTING) set(${reg} 0) endif() endforeach() - if(COMMAND cmake_host_system_information) + if(CMAKE_HOST_WIN32 AND COMMAND cmake_host_system_information) set(info_vs15 "VS_15_DIR") set(info_vs16 "VS_16_DIR") set(vs_versions) -- cgit v0.12 From 1ee99104f76ccd831713816eec588eb5d7e93f8b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Dec 2020 14:33:11 -0500 Subject: CMakeDetermineCompilerId: Filter IAR-AVR format INFO strings earlier Remove the bytes between characters from the entire list at once. --- Modules/CMakeDetermineCompilerId.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index a982d2c..ca82d8a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -756,15 +756,16 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) # With the IAR Compiler, some strings are found twice, first time as incomplete # list like "?". Remove the incomplete copies. list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\? Date: Thu, 3 Dec 2020 14:36:19 -0500 Subject: CMakeDetermineCompilerId: Add whitespace to clarify logic Also initialize a variable closer to its use. --- Modules/CMakeDetermineCompilerId.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index ca82d8a..d586275 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -752,10 +752,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) break() endif() endforeach() - set(COMPILER_ID_TWICE) + # With the IAR Compiler, some strings are found twice, first time as incomplete # list like "?". Remove the incomplete copies. list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\? Date: Thu, 3 Dec 2020 14:35:15 -0500 Subject: CMakeDetermineCompilerId: Tolerate stray text around INFO strings When cross-compiling with Xcode our compiler id test binary may be compiled with multiple architectures. The INFO strings should be identical and therefore de-duplicated. However, this can be broken by stray text that happens to sit immediately before or after an INFO string. Filter out such text so we can match clean INFO strings. Fixes: #21526 --- Modules/CMakeDetermineCompilerId.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d586275..937a120 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -765,6 +765,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRINGS}") endif() + # Remove arbitrary text that may appear before or after each INFO string. + string(REGEX MATCHALL "INFO:[A-Za-z0-9_]+\\[([^]\"]*)\\]" + CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRINGS}") + # In C# binaries, some strings are found more than once. list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_ID_STRINGS) -- cgit v0.12 From fcabf4a47e0c441ff80fad8f34e388b16738bd33 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 4 Dec 2020 17:17:02 +0200 Subject: macOS: Add architecture flags only for native ASM dialect ASM dialects like NASM have languages names such as ASM_NASM. However such ASM dialects don't support the architecture flags, so match only the full name. Fixes #21553. --- Source/cmLocalGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65ddf95..61e7857 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1879,7 +1879,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, target->GetAppleArchs(config, archs); if (!archs.empty() && (lang == "C" || lang == "CXX" || lang == "OBJ" || lang == "OBJCXX" || - cmHasLiteralPrefix(lang, "ASM"))) { + lang == "ASM")) { for (std::string const& arch : archs) { if (filterArch.empty() || filterArch == arch) { flags += " -arch "; -- cgit v0.12 From afb0ffcac7852e1c2d7472ee914081e5eaf0cfe0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 4 Dec 2020 13:58:34 -0500 Subject: FindPython2: avoid doubling the extension in CPython2 SOABI Commit 951640f1f9 (FindPython: manage SOABI for all Python versions, 2020-08-11) extended support for Python2's SOABI variable in order to support the PyPy interpreter as well. This caused a regression in the way that the SOABI variable was built up for the CPython interpreter. This caused the variable to be set to `.so` which ended up causing a doubling of the resulting `SOABI` variable in the end. Co-Author: Marc Chevrier Fixes: #21548 --- Modules/FindPython/Support.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index c8225c4..3732463 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -452,7 +452,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) list (REMOVE_DUPLICATES _values) elseif (NAME STREQUAL "SOABI") # clean-up: remove prefix character and suffix - string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$") + set(_values "") + else() + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + endif() endif() endif() endif() @@ -504,7 +508,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endforeach() if (_values) # clean-up: remove prefix character and suffix - string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$") + set(_values "") + else() + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + endif() endif() endif() else() -- cgit v0.12 From 72ae15ebcb6061623b8a4a7119ddb49154e83094 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 7 Dec 2020 09:14:13 -0500 Subject: ISPC: Ninja properly compute ISPC_HEADER_DIRECTORY location --- Source/cmNinjaTargetGenerator.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 76df9f2..662399e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1375,15 +1375,16 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); - std::string ispcDirectory = objectFileDir; + std::string ispcHeaderDirectory = + this->GeneratorTarget->GetObjectDirectory(config); if (cmProp prop = this->GeneratorTarget->GetProperty("ISPC_HEADER_DIRECTORY")) { - ispcDirectory = *prop; + ispcHeaderDirectory = + cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop); } - ispcDirectory = - cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', ispcDirectory); - std::string ispcHeader = cmStrCat(ispcDirectory, '/', ispcSource, ".h"); + std::string ispcHeader = + cmStrCat(ispcHeaderDirectory, '/', ispcSource, ".h"); ispcHeader = this->ConvertToNinjaPath(ispcHeader); // Make sure ninja knows what command generates the header @@ -1395,8 +1396,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( auto ispcSuffixes = detail::ComputeISPCObjectSuffixes(this->GeneratorTarget); if (ispcSuffixes.size() > 1) { + std::string rootObjectDir = + this->GeneratorTarget->GetObjectDirectory(config); auto ispcSideEfffectObjects = detail::ComputeISPCExtraObjects( - objectName, ispcDirectory, ispcSuffixes); + objectName, rootObjectDir, ispcSuffixes); for (auto sideEffect : ispcSideEfffectObjects) { sideEffect = this->ConvertToNinjaPath(sideEffect); -- cgit v0.12 From 9af93fef11e9ea23d7d87a1c217254c482555262 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 7 Dec 2020 09:14:54 -0500 Subject: ISPC: Handle OBJECT sources in different directories --- Source/cmGeneratorTarget.cxx | 7 ++++++- Source/cmLocalGenerator.cxx | 23 ++++++++++++++++------- Tests/ISPC/ObjectLibrary/CMakeLists.txt | 2 +- Tests/ISPC/ObjectLibrary/extra.ispc | 12 ------------ Tests/ISPC/ObjectLibrary/subdir/extra.ispc | 12 ++++++++++++ 5 files changed, 35 insertions(+), 21 deletions(-) delete mode 100644 Tests/ISPC/ObjectLibrary/extra.ispc create mode 100644 Tests/ISPC/ObjectLibrary/subdir/extra.ispc diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e735897..c299dad 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5107,9 +5107,14 @@ void cmGeneratorTarget::GetTargetObjectNames( objects.push_back(map_it->second); } + // We need to compute the relative path from the root of + // of the object directory to handle subdirectory paths + std::string rootObjectDir = this->GetObjectDirectory(config); + rootObjectDir = cmSystemTools::CollapseFullPath(rootObjectDir); auto ispcObjects = this->GetGeneratedISPCObjects(config); for (std::string const& output : ispcObjects) { - objects.push_back(cmSystemTools::GetFilenameName(output)); + auto relativePathFromObjectDir = output.substr(rootObjectDir.size()); + objects.push_back(relativePathFromObjectDir); } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4e6010c..73e5431 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2434,9 +2434,10 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& config : configsList) { - std::string perConfigDir = target->GetObjectDirectory(config); + std::string rootObjectDir = target->GetObjectDirectory(config); + std::string headerDir = rootObjectDir; if (cmProp prop = target->GetProperty("ISPC_HEADER_DIRECTORY")) { - perConfigDir = cmSystemTools::CollapseFullPath( + headerDir = cmSystemTools::CollapseFullPath( cmStrCat(this->GetBinaryDirectory(), '/', *prop)); } @@ -2453,11 +2454,11 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); - auto headerPath = cmStrCat(perConfigDir, '/', ispcSource, ".h"); + auto headerPath = cmStrCat(headerDir, '/', ispcSource, ".h"); target->AddISPCGeneratedHeader(headerPath, config); if (extra_objects) { std::vector objs = detail::ComputeISPCExtraObjects( - objectName, perConfigDir, ispcSuffixes); + objectName, rootObjectDir, ispcSuffixes); target->AddISPCGeneratedObject(std::move(objs), config); } } @@ -4074,15 +4075,23 @@ std::vector ComputeISPCExtraObjects( std::string const& objectName, std::string const& buildDirectory, std::vector const& ispcSuffixes) { + auto normalizedDir = cmSystemTools::CollapseFullPath(buildDirectory); std::vector computedObjects; computedObjects.reserve(ispcSuffixes.size()); auto extension = cmSystemTools::GetFilenameLastExtension(objectName); - auto objNameNoExt = - cmSystemTools::GetFilenameWithoutLastExtension(objectName); + + // We can't use cmSystemTools::GetFilenameWithoutLastExtension as it + // drops any directories in objectName + auto objNameNoExt = objectName; + std::string::size_type dot_pos = objectName.rfind('.'); + if (dot_pos != std::string::npos) { + objNameNoExt.resize(dot_pos); + } + for (const auto& ispcTarget : ispcSuffixes) { computedObjects.emplace_back( - cmStrCat(buildDirectory, "/", objNameNoExt, "_", ispcTarget, extension)); + cmStrCat(normalizedDir, "/", objNameNoExt, "_", ispcTarget, extension)); } return computedObjects; diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt index 4767d7e..a4c81a9 100644 --- a/Tests/ISPC/ObjectLibrary/CMakeLists.txt +++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt @@ -8,7 +8,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) endif() -add_library(ispc_objects OBJECT simple.ispc extra.ispc) +add_library(ispc_objects OBJECT simple.ispc subdir/extra.ispc) set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(ispc_objects PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") diff --git a/Tests/ISPC/ObjectLibrary/extra.ispc b/Tests/ISPC/ObjectLibrary/extra.ispc deleted file mode 100644 index 5a4a442..0000000 --- a/Tests/ISPC/ObjectLibrary/extra.ispc +++ /dev/null @@ -1,12 +0,0 @@ - -export void extra(uniform float vin[], uniform float vout[], - uniform int count) { - foreach (index = 0 ... count) { - float v = vin[index]; - if (v < 3.) - v = v * v; - else - v = sqrt(v); - vout[index] = v; - } -} diff --git a/Tests/ISPC/ObjectLibrary/subdir/extra.ispc b/Tests/ISPC/ObjectLibrary/subdir/extra.ispc new file mode 100644 index 0000000..5a4a442 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/subdir/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} -- cgit v0.12 From cf0c71dae3009a75e08c91eb5d3138ffd488f7db Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 7 Dec 2020 09:50:39 -0500 Subject: Document CMP0112 covers $ Fixes #21559 --- Help/manual/cmake-generator-expressions.7.rst | 3 +++ Help/policy/CMP0112.rst | 1 + 2 files changed, 4 insertions(+) diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index ff9d1bf..482b14e 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -648,6 +648,9 @@ which is just the string ``tgt``. expression is evaluated on. ``$`` The ``tgt`` filename. + + Note that ``tgt`` is not added as a dependency of the target this + expression is evaluated on (see policy :policy:`CMP0112`). ``$`` Directory of the ``tgt`` binary file. diff --git a/Help/policy/CMP0112.rst b/Help/policy/CMP0112.rst index 78a9055..313a51e 100644 --- a/Help/policy/CMP0112.rst +++ b/Help/policy/CMP0112.rst @@ -8,6 +8,7 @@ Target file component generator expressions do not add target dependencies. The following target-based generator expressions that query for directory or file name components no longer add a dependency on the evaluated target. + - ``TARGET_FILE_NAME`` - ``TARGET_FILE_DIR`` - ``TARGET_LINKER_FILE_BASE_NAME`` - ``TARGET_LINKER_FILE_NAME`` -- cgit v0.12 From f0babb53b3b2f94b9286068b629237b7de60cb24 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 4 Dec 2020 08:40:48 -0500 Subject: Revert "Intel: Add Intel Clang compiler identification" Revert commit 5c3a93ab88 (Intel: Add Intel Clang compiler identification, 2020-09-29, v3.19.0-rc1~68^2). The compiler has already been released, and is more usable with CMake by pretending to be upstream Clang than by identifying it as a compiler for which we have not implemented support. Issue: #21551 --- Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 - Modules/CMakeCompilerIdDetection.cmake | 1 - Modules/Compiler/IntelClang-DetermineCompiler.cmake | 7 ------- 3 files changed, 9 deletions(-) delete mode 100644 Modules/Compiler/IntelClang-DetermineCompiler.cmake diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 99ff015..c495b71 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -26,7 +26,6 @@ include: IAR = IAR Systems (iar.com) Intel = Intel Compiler (intel.com) IntelDPCPP = Intel DPCPP Compiler (intel.com) - IntelClang = Intel Clang Compiler (intel.com) MSVC = Microsoft Visual Studio (microsoft.com) NVIDIA = NVIDIA CUDA Compiler (nvidia.com) OpenWatcom = Open Watcom (openwatcom.org) diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 26fb381..176e768 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -79,7 +79,6 @@ function(compiler_id_detection outvar lang) AppleClang ARMClang IntelDPCPP - IntelClang Clang GNU MSVC diff --git a/Modules/Compiler/IntelClang-DetermineCompiler.cmake b/Modules/Compiler/IntelClang-DetermineCompiler.cmake deleted file mode 100644 index 3544be3..0000000 --- a/Modules/Compiler/IntelClang-DetermineCompiler.cmake +++ /dev/null @@ -1,7 +0,0 @@ - -set(_compiler_id_pp_test "defined(__clang__) && defined(__INTEL_CLANG_COMPILER)") - -include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake") - -string(APPEND _compiler_id_version_compute " -# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__INTEL_CLANG_COMPILER)") -- cgit v0.12 From 41b69348a54b03372c4972e0b0d29aa0c7bca187 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 4 Dec 2020 08:40:57 -0500 Subject: Revert "Intel: Add Intel DPC++ compiler identification" Revert commit 887f3a88a6 (Intel: Add Intel DPC++ compiler identification, 2020-09-21, v3.19.0-rc1~124^2). The compiler has already been released, and is more usable with CMake by pretending to be upstream Clang than by identifying it as a compiler for which we have not implemented support. Fixes: #21551 --- Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 - Modules/CMakeCompilerIdDetection.cmake | 1 - Modules/Compiler/IntelDPCPP-DetermineCompiler.cmake | 7 ------- 3 files changed, 9 deletions(-) delete mode 100644 Modules/Compiler/IntelDPCPP-DetermineCompiler.cmake diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index c495b71..8eb4fb6 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -25,7 +25,6 @@ include: HP = Hewlett-Packard Compiler (hp.com) IAR = IAR Systems (iar.com) Intel = Intel Compiler (intel.com) - IntelDPCPP = Intel DPCPP Compiler (intel.com) MSVC = Microsoft Visual Studio (microsoft.com) NVIDIA = NVIDIA CUDA Compiler (nvidia.com) OpenWatcom = Open Watcom (openwatcom.org) diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 176e768..a0f0dfa 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -78,7 +78,6 @@ function(compiler_id_detection outvar lang) ARMCC AppleClang ARMClang - IntelDPCPP Clang GNU MSVC diff --git a/Modules/Compiler/IntelDPCPP-DetermineCompiler.cmake b/Modules/Compiler/IntelDPCPP-DetermineCompiler.cmake deleted file mode 100644 index 7bbb21c..0000000 --- a/Modules/Compiler/IntelDPCPP-DetermineCompiler.cmake +++ /dev/null @@ -1,7 +0,0 @@ - -set(_compiler_id_pp_test "defined(__clang__) && defined(__INTEL_DPCPP_COMPILER__)") - -include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake") - -string(APPEND _compiler_id_version_compute " -# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__INTEL_DPCPP_COMPILER__)") -- cgit v0.12 From 8da25e4a3c0583a940abcbfede8ceb915fd976e0 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 9 Dec 2020 10:55:30 -0500 Subject: ISPC: Treat system includes as '-I' includes ISPC doesn't have specific syntax for system includes. --- Modules/Compiler/Intel-ISPC.cmake | 2 -- Tests/ISPC/CMakeLists.txt | 1 + Tests/ISPC/SystemIncludes/CMakeLists.txt | 12 ++++++++++++ Tests/ISPC/SystemIncludes/main.cxx | 15 +++++++++++++++ Tests/ISPC/SystemIncludes/simple.ispc | 9 +++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Tests/ISPC/SystemIncludes/CMakeLists.txt create mode 100644 Tests/ISPC/SystemIncludes/main.cxx create mode 100644 Tests/ISPC/SystemIncludes/simple.ispc diff --git a/Modules/Compiler/Intel-ISPC.cmake b/Modules/Compiler/Intel-ISPC.cmake index 2e9792a..aa9ecea 100644 --- a/Modules/Compiler/Intel-ISPC.cmake +++ b/Modules/Compiler/Intel-ISPC.cmake @@ -14,8 +14,6 @@ string(APPEND CMAKE_ISPC_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") set(CMAKE_ISPC_COMPILE_OPTIONS_PIE --pic) set(CMAKE_ISPC_COMPILE_OPTIONS_PIC --pic) -set(CMAKE_INCLUDE_SYSTEM_FLAG_ISPC -isystem=) - set(CMAKE_ISPC_RESPONSE_FILE_FLAG "@") set(CMAKE_ISPC_USE_RESPONSE_FILE_FOR_INCLUDES 1) set(CMAKE_ISPC_USE_RESPONSE_FILE_FOR_LIBRARIES 1) diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt index c13271a..2c3651d 100644 --- a/Tests/ISPC/CMakeLists.txt +++ b/Tests/ISPC/CMakeLists.txt @@ -13,4 +13,5 @@ add_ispc_test_macro(ISPC.ObjectGenex ISPCObjectGenex) add_ispc_test_macro(ISPC.ObjectLibrary ISPCObjectLibrary) add_ispc_test_macro(ISPC.ResponseAndDefine ISPCResponseAndDefine) add_ispc_test_macro(ISPC.StaticLibrary ISPCStaticLibrary) +add_ispc_test_macro(ISPC.SystemIncludes ISPCSystemIncludes) add_ispc_test_macro(ISPC.TryCompile ISPCTryCompile) diff --git a/Tests/ISPC/SystemIncludes/CMakeLists.txt b/Tests/ISPC/SystemIncludes/CMakeLists.txt new file mode 100644 index 0000000..95959b2 --- /dev/null +++ b/Tests/ISPC/SystemIncludes/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.18) +project(ispc_spaces_in_path ISPC CXX) + + +add_executable(ISPCSystemIncludes main.cxx simple.ispc) +set_target_properties(ISPCSystemIncludes PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(ISPCSystemIncludes SYSTEM PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--target=sse2-i32x4>") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--arch=x86>") +endif() diff --git a/Tests/ISPC/SystemIncludes/main.cxx b/Tests/ISPC/SystemIncludes/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/SystemIncludes/main.cxx @@ -0,0 +1,15 @@ +#include + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/SystemIncludes/simple.ispc b/Tests/ISPC/SystemIncludes/simple.ispc new file mode 100644 index 0000000..d539bbe --- /dev/null +++ b/Tests/ISPC/SystemIncludes/simple.ispc @@ -0,0 +1,9 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + v = sqrt(v); + vout[index] = v; + } +} -- cgit v0.12 From c404d7f221f170f01bc10247438bf1d011d8997a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Dec 2020 13:06:25 -0500 Subject: Tests: Add cache entry to control XCTest deployment target --- Tests/CMakeLists.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4938681..8877115 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1833,11 +1833,22 @@ if(BUILD_TESTING) ) endif() - if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5 - AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") - set(XCTest_CTEST_OPTIONS --build-config $) - set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx) - ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $ -V) + if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5) + if(NOT CMake_TEST_XCTest_DEPLOYMENT_TARGET) + execute_process( + COMMAND sw_vers -productVersion + OUTPUT_VARIABLE OSX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(CMake_TEST_XCTest_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}") + endif() + endif() + if(CMake_TEST_XCTest_DEPLOYMENT_TARGET) + set(XCTest_CTEST_OPTIONS --build-config $) + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMake_TEST_XCTest_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=macosx) + ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $ -V) + endif() endif() add_test(linkorder1 ${CMAKE_CTEST_COMMAND} -- cgit v0.12 From 40877903ace8559f079b367c73b1a81485319d38 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Dec 2020 13:07:44 -0500 Subject: Tests: Remove outdated exclusion of tests on OS X 10.3 --- Tests/CMakeLists.txt | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8877115..02759d1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -301,18 +301,7 @@ if(BUILD_TESTING) set(CTEST_TEST_OSX_ARCH 0) set(CMake_TEST_XCODE_VERSION 0) if(APPLE) - execute_process( - COMMAND sw_vers -productVersion - OUTPUT_VARIABLE OSX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(OSX_VERSION VERSION_LESS 10.4) - message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4") - message(STATUS "OSX_VERSION='${OSX_VERSION}'") - set(CTEST_TEST_CPACK OFF) - else() - set(CTEST_TEST_OSX_ARCH 1) - endif() + set(CTEST_TEST_OSX_ARCH 1) if(XCODE_VERSION) set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}") else() -- cgit v0.12 From 55193c8013fbdf9a9bb211bb27833007a189a44c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Dec 2020 13:07:00 -0500 Subject: ci: Hard-code XCTest deployment target to 10.15 Avoid using the macOS version running on the CI job host that happens to run the build job. --- .gitlab/ci/configure_macos_common.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab/ci/configure_macos_common.cmake b/.gitlab/ci/configure_macos_common.cmake index 4bd3c7d..37cd51c 100644 --- a/.gitlab/ci/configure_macos_common.cmake +++ b/.gitlab/ci/configure_macos_common.cmake @@ -11,3 +11,8 @@ set(CMake_TEST_Java 0 CACHE FILEPATH "") set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF CACHE BOOL "") set(BUILD_QtDialog ON CACHE BOOL "") + +# The "XCTest" test uses an explicit deployment target chosen +# when CMake itself is configured. Use a version that is not +# newer than the macOS version running on any CI host. +set(CMake_TEST_XCTest_DEPLOYMENT_TARGET "10.15" CACHE STRING "") -- cgit v0.12 From e5a4ffaad166de7a8b907919ca2d805a3ec72c39 Mon Sep 17 00:00:00 2001 From: Asit Dhal Date: Tue, 8 Dec 2020 09:51:00 +0100 Subject: execute_process: Improve COMMAND_ERROR_IS_FATAL error capture scenarios 1. COMMAND_ERROR_IS_FATAL ANY will capture errors if the exit code is non zero, there is a timeout or an abnormal exit. 2. COMMAND_ERROR_IS_FATAL LAST will capture if only the last process has an exit code non zero, there is a timeout or an abnormal exit. Fixes: #21562 --- Source/cmExecuteProcessCommand.cxx | 118 +++++++++++++++------ Tests/RunCMake/CMakeLists.txt | 5 +- .../AnyCommandAbnormalExit-result.txt | 1 + .../AnyCommandAbnormalExit-stderr.txt | 4 + .../execute_process/AnyCommandAbnormalExit.cmake | 5 + .../execute_process/AnyCommandError-stderr.txt | 5 +- .../RunCMake/execute_process/AnyCommandError.cmake | 10 +- .../RunCMake/execute_process/AnyCommandGood.cmake | 4 + .../execute_process/AnyCommandTimeout-result.txt | 1 + .../execute_process/AnyCommandTimeout-stderr.txt | 2 + .../execute_process/AnyCommandTimeout.cmake | 15 +++ .../LastCommandAbnormalExit-1.cmake | 13 +++ .../LastCommandAbnormalExit-2-result.txt | 1 + .../LastCommandAbnormalExit-2-stderr.txt | 2 + .../LastCommandAbnormalExit-2.cmake | 13 +++ .../execute_process/LastCommandError-stderr.txt | 2 +- .../execute_process/LastCommandError.cmake | 13 ++- .../RunCMake/execute_process/LastCommandGood.cmake | 15 +++ .../execute_process/LastCommandTimeout-result.txt | 1 + .../execute_process/LastCommandTimeout-stderr.txt | 2 + .../execute_process/LastCommandTimeout.cmake | 15 +++ Tests/RunCMake/execute_process/RunCMakeTest.cmake | 12 ++- 22 files changed, 217 insertions(+), 42 deletions(-) create mode 100644 Tests/RunCMake/execute_process/AnyCommandAbnormalExit-result.txt create mode 100644 Tests/RunCMake/execute_process/AnyCommandAbnormalExit-stderr.txt create mode 100644 Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake create mode 100644 Tests/RunCMake/execute_process/AnyCommandGood.cmake create mode 100644 Tests/RunCMake/execute_process/AnyCommandTimeout-result.txt create mode 100644 Tests/RunCMake/execute_process/AnyCommandTimeout-stderr.txt create mode 100644 Tests/RunCMake/execute_process/AnyCommandTimeout.cmake create mode 100644 Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake create mode 100644 Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-result.txt create mode 100644 Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-stderr.txt create mode 100644 Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake create mode 100644 Tests/RunCMake/execute_process/LastCommandGood.cmake create mode 100644 Tests/RunCMake/execute_process/LastCommandTimeout-result.txt create mode 100644 Tests/RunCMake/execute_process/LastCommandTimeout-stderr.txt create mode 100644 Tests/RunCMake/execute_process/LastCommandTimeout.cmake diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 14147e0..5a85b7d 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -6,8 +6,10 @@ #include /* isspace */ #include #include +#include #include #include +#include #include #include @@ -375,47 +377,101 @@ bool cmExecuteProcessCommand(std::vector const& args, } } - if (arguments.CommandErrorIsFatal == "ANY"_s) { - if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) { - std::vector failedIndexes; - for (int i = 0; i < static_cast(arguments.Commands.size()); ++i) { - if (cmsysProcess_GetStateByIndex(cp, i) == - kwsysProcess_StateByIndex_Exited) { - int exitCode = cmsysProcess_GetExitValueByIndex(cp, i); - if (exitCode) { - failedIndexes.push_back(i); - } + auto queryProcessStatusByIndex = [&cp](int index) -> std::string { + std::string processStatus; + switch (cmsysProcess_GetStateByIndex(cp, static_cast(index))) { + case kwsysProcess_StateByIndex_Exited: { + int exitCode = cmsysProcess_GetExitValueByIndex(cp, index); + if (exitCode) { + processStatus = "Child return code: " + std::to_string(exitCode); } + } break; + case kwsysProcess_StateByIndex_Exception: { + processStatus = cmStrCat( + "Abnormal exit with child return code: ", + cmsysProcess_GetExceptionStringByIndex(cp, static_cast(index))); + break; } - if (!failedIndexes.empty()) { - std::ostringstream oss; - oss << "failed command indexes: "; - for (auto i = 0u; i < failedIndexes.size(); i++) { - if (i == failedIndexes.size() - 1) { - oss << failedIndexes[i] + 1; - } else { - oss << failedIndexes[i] + 1 << ", "; + case kwsysProcess_StateByIndex_Error: + default: + processStatus = "Error getting the child return code"; + break; + } + return processStatus; + }; + + if (arguments.CommandErrorIsFatal == "ANY"_s) { + bool ret = true; + switch (cmsysProcess_GetState(cp)) { + case cmsysProcess_State_Exited: { + std::map failureIndices; + for (int i = 0; i < static_cast(arguments.Commands.size()); ++i) { + std::string processStatus = queryProcessStatusByIndex(i); + if (!processStatus.empty()) { + failureIndices[i] = processStatus; + } + if (!failureIndices.empty()) { + std::ostringstream oss; + oss << "failed command indexes:\n"; + for (auto const& e : failureIndices) { + oss << " " << e.first + 1 << ": \"" << e.second << "\"\n"; + } + status.SetError(oss.str()); + ret = false; } } - status.SetError(oss.str()); - cmSystemTools::SetFatalErrorOccured(); - return false; - } + } break; + case cmsysProcess_State_Exception: + status.SetError( + cmStrCat("abnormal exit: ", cmsysProcess_GetExceptionString(cp))); + ret = false; + break; + case cmsysProcess_State_Error: + status.SetError(cmStrCat("error getting child return code: ", + cmsysProcess_GetErrorString(cp))); + ret = false; + break; + case cmsysProcess_State_Expired: + status.SetError("Process terminated due to timeout"); + ret = false; + break; + } + + if (!ret) { + cmSystemTools::SetFatalErrorOccured(); + return false; } } if (arguments.CommandErrorIsFatal == "LAST"_s) { - if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) { - int lastIndex = static_cast(arguments.Commands.size() - 1); - if (cmsysProcess_GetStateByIndex(cp, lastIndex) == - kwsysProcess_StateByIndex_Exited) { - int exitCode = cmsysProcess_GetExitValueByIndex(cp, lastIndex); - if (exitCode) { + bool ret = true; + switch (cmsysProcess_GetState(cp)) { + case cmsysProcess_State_Exited: { + int lastIndex = static_cast(arguments.Commands.size() - 1); + const std::string processStatus = queryProcessStatusByIndex(lastIndex); + if (!processStatus.empty()) { status.SetError("last command failed"); - cmSystemTools::SetFatalErrorOccured(); - return false; + ret = false; } - } + } break; + case cmsysProcess_State_Exception: + status.SetError( + cmStrCat("Abnormal exit: ", cmsysProcess_GetExceptionString(cp))); + ret = false; + break; + case cmsysProcess_State_Error: + status.SetError(cmStrCat("Error getting child return code: ", + cmsysProcess_GetErrorString(cp))); + ret = false; + break; + case cmsysProcess_State_Expired: + status.SetError("Process terminated due to timeout"); + ret = false; + break; + } + if (!ret) { + cmSystemTools::SetFatalErrorOccured(); + return false; } } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 615bf20..98d5d01 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -299,7 +299,10 @@ add_RunCMake_test(add_subdirectory) add_RunCMake_test(add_test) add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) -set(execute_process_ARGS -DEXIT_CODE_EXE=$) +set(execute_process_ARGS + -DEXIT_CODE_EXE=$ + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + ) if(NOT CMake_TEST_EXTERNAL_CMAKE) list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$) endif() diff --git a/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-result.txt b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-stderr.txt b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-stderr.txt new file mode 100644 index 0000000..9627872 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at .*AnyCommandAbnormalExit.cmake:[0-9]+ \(execute_process\): + execute_process failed command indexes: + + 1: "Abnormal exit with child return code: Segmentation fault diff --git a/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake new file mode 100644 index 0000000..5ac0c21 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake @@ -0,0 +1,5 @@ +execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + "import os; os.kill(os.getpid(),11)" + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL ANY + ) diff --git a/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt b/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt index 0380562..bf36391 100644 --- a/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt +++ b/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt @@ -1,2 +1,5 @@ CMake Error at .*AnyCommandError.cmake:1 \(execute_process\): - execute_process failed command indexes: 2, 3, 4 + execute_process failed command indexes: + + 2: "Child return code: 1" + 3: "Child return code: 1" diff --git a/Tests/RunCMake/execute_process/AnyCommandError.cmake b/Tests/RunCMake/execute_process/AnyCommandError.cmake index f8ec385..c9348cd 100644 --- a/Tests/RunCMake/execute_process/AnyCommandError.cmake +++ b/Tests/RunCMake/execute_process/AnyCommandError.cmake @@ -1,8 +1,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E true - COMMAND ${CMAKE_COMMAND} -E false - COMMAND ${CMAKE_COMMAND} -E false - COMMAND ${CMAKE_COMMAND} -E false - COMMAND ${CMAKE_COMMAND} -E true - COMMAND ${CMAKE_COMMAND} -E true - COMMAND_ERROR_IS_FATAL ANY + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL ANY ) diff --git a/Tests/RunCMake/execute_process/AnyCommandGood.cmake b/Tests/RunCMake/execute_process/AnyCommandGood.cmake new file mode 100644 index 0000000..27f0996 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandGood.cmake @@ -0,0 +1,4 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL ANY + ) diff --git a/Tests/RunCMake/execute_process/AnyCommandTimeout-result.txt b/Tests/RunCMake/execute_process/AnyCommandTimeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandTimeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/AnyCommandTimeout-stderr.txt b/Tests/RunCMake/execute_process/AnyCommandTimeout-stderr.txt new file mode 100644 index 0000000..10cc5f4 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandTimeout-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*AnyCommandTimeout.cmake:9 \(execute_process\): + execute_process Process terminated due to timeout diff --git a/Tests/RunCMake/execute_process/AnyCommandTimeout.cmake b/Tests/RunCMake/execute_process/AnyCommandTimeout.cmake new file mode 100644 index 0000000..a5a53fd --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandTimeout.cmake @@ -0,0 +1,15 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E sleep 10 + COMMAND ${CMAKE_COMMAND} -E true + TIMEOUT 1 + RESULT_VARIABLE result +) + +if(NOT result EQUAL "0") + execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E sleep 10 + COMMAND ${CMAKE_COMMAND} -E true + TIMEOUT 1 + COMMAND_ERROR_IS_FATAL ANY + ) +endif() diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake new file mode 100644 index 0000000..5a4574c --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake @@ -0,0 +1,13 @@ +execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + "import os; os.kill(os.getpid(),11)" + COMMAND ${CMAKE_COMMAND} -E true + RESULT_VARIABLE result + ) + +if(result EQUAL "0") + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + "import os; os.kill(os.getpid(),11)" + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL LAST + ) +endif() diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-result.txt b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-stderr.txt b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-stderr.txt new file mode 100644 index 0000000..c915e58 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*LastCommandAbnormalExit-2.cmake:[0-9]+ \(execute_process\): + execute_process Abnormal exit: Segmentation fault diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake new file mode 100644 index 0000000..b87e0f7 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake @@ -0,0 +1,13 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND "${PYTHON_EXECUTABLE}" -c + "import os; os.kill(os.getpid(),11)" + RESULT_VARIABLE result + ) + +if(NOT result EQUAL "0") + execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND "${PYTHON_EXECUTABLE}" -c + "import os; os.kill(os.getpid(),11)" + COMMAND_ERROR_IS_FATAL LAST + ) +endif() diff --git a/Tests/RunCMake/execute_process/LastCommandError-stderr.txt b/Tests/RunCMake/execute_process/LastCommandError-stderr.txt index ff191b3..335a771 100644 --- a/Tests/RunCMake/execute_process/LastCommandError-stderr.txt +++ b/Tests/RunCMake/execute_process/LastCommandError-stderr.txt @@ -1,2 +1,2 @@ -CMake Error at .*LastCommandError.cmake:1 \(execute_process\): +CMake Error at .*LastCommandError.cmake:11 \(execute_process\): execute_process last command failed diff --git a/Tests/RunCMake/execute_process/LastCommandError.cmake b/Tests/RunCMake/execute_process/LastCommandError.cmake index 6116a5c..9a925fe 100644 --- a/Tests/RunCMake/execute_process/LastCommandError.cmake +++ b/Tests/RunCMake/execute_process/LastCommandError.cmake @@ -1,8 +1,19 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + RESULT_VARIABLE result +) + +if(NOT result EQUAL "0") + execute_process(COMMAND ${CMAKE_COMMAND} -E true COMMAND ${CMAKE_COMMAND} -E false COMMAND ${CMAKE_COMMAND} -E false COMMAND ${CMAKE_COMMAND} -E false COMMAND ${CMAKE_COMMAND} -E true COMMAND ${CMAKE_COMMAND} -E false COMMAND_ERROR_IS_FATAL LAST -) + ) +endif() diff --git a/Tests/RunCMake/execute_process/LastCommandGood.cmake b/Tests/RunCMake/execute_process/LastCommandGood.cmake new file mode 100644 index 0000000..c22b49d --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandGood.cmake @@ -0,0 +1,15 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + RESULT_VARIABLE result + ) + +if(result EQUAL "0") + execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL LAST + ) +endif() diff --git a/Tests/RunCMake/execute_process/LastCommandTimeout-result.txt b/Tests/RunCMake/execute_process/LastCommandTimeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandTimeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/LastCommandTimeout-stderr.txt b/Tests/RunCMake/execute_process/LastCommandTimeout-stderr.txt new file mode 100644 index 0000000..1cd1546 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandTimeout-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*LastCommandTimeout.cmake:9 \(execute_process\): + execute_process Process terminated due to timeout diff --git a/Tests/RunCMake/execute_process/LastCommandTimeout.cmake b/Tests/RunCMake/execute_process/LastCommandTimeout.cmake new file mode 100644 index 0000000..9c1f444 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandTimeout.cmake @@ -0,0 +1,15 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E sleep 10 + COMMAND ${CMAKE_COMMAND} -E true + TIMEOUT 1 + RESULT_VARIABLE result +) + +if(NOT result EQUAL "0") + execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E sleep 10 + COMMAND ${CMAKE_COMMAND} -E true + TIMEOUT 1 + COMMAND_ERROR_IS_FATAL LAST + ) +endif() diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index f4c3d19..35712f6 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -27,6 +27,16 @@ run_cmake_command(EchoCommand3 ${CMAKE_COMMAND} run_cmake_command(EchoVariable ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/EchoVariable.cmake) +run_cmake_command(CommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CommandError.cmake) run_cmake_command(AnyCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/AnyCommandError.cmake) +run_cmake_command(AnyCommandTimeout ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/AnyCommandTimeout.cmake) +run_cmake_command(AnyCommandGood ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/AnyCommandGood.cmake) run_cmake_command(LastCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandError.cmake) -run_cmake_command(CommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CommandError.cmake) +run_cmake_command(LastCommandTimeout ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandTimeout.cmake) +run_cmake_command(LastCommandGood ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandGood.cmake) + +if(UNIX AND PYTHON_EXECUTABLE) + run_cmake_command(AnyCommandAbnormalExit ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/AnyCommandAbnormalExit.cmake) + run_cmake_command(LastCommandAbnormalExit-1 ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-1.cmake) + run_cmake_command(LastCommandAbnormalExit-2 ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-2.cmake) +endif() -- cgit v0.12 From b201dc0d4239aa0f2babf572b1ce75de3e7a05e6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Dec 2020 09:50:47 -0500 Subject: Utilities/Release: Add script to build Qt 5.9.9 macOS universal binaries These may be used to build a CMake universal binary for macOS that supports both architectures on Apple Silicon and is compatible with OS X 10.10. --- Utilities/Release/README.rst | 6 + .../macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash | 132 +++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100755 Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash diff --git a/Utilities/Release/README.rst b/Utilities/Release/README.rst index 2d3525d..6e55dff 100644 --- a/Utilities/Release/README.rst +++ b/Utilities/Release/README.rst @@ -74,3 +74,9 @@ Each ``//`` directory contains the following: argument specifying either ``x86_64`` or ``i386``. .. _`kitware/cmake Docker Hub Repository`: https://hub.docker.com/r/kitware/cmake + +macOS +----- + +The ``macos/`` directory contains scripts used to produce dependencies +for building CMake binaries on macOS. diff --git a/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash b/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash new file mode 100755 index 0000000..b0973f4 --- /dev/null +++ b/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash @@ -0,0 +1,132 @@ +#!/usr/bin/env bash + +# Run this script on a macOS x86_64 host to generate Qt universal binaries. +# +# This script requires the 'makeuniversal' tool from: +# +# https://github.com/fizzyade/makeuniversal +# +# Build it with an existing local Qt installation first. +# +# Set the PATH environment variable to contain the location of 'makeuniversal'. + +set -e +set -x + +# Verify that 'makeuniversal' is available in the PATH. +type -p makeuniversal >/dev/null + +# Download, verify, and extract sources. +curl -OL https://download.qt.io/archive/qt/5.9/5.9.9/single/qt-everywhere-opensource-src-5.9.9.tar.xz +shasum -a 256 qt-everywhere-opensource-src-5.9.9.tar.xz | grep -q 5ce285209290a157d7f42ec8eb22bf3f1d76f2e03a95fc0b99b553391be01642 +tar xjf qt-everywhere-opensource-src-5.9.9.tar.xz + +# Build the x86_64 variant. +mkdir qt-5.9.9-x86_64 +cd qt-5.9.9-x86_64 +../qt-everywhere-opensource-src-5.9.9/configure \ + --prefix=/ \ + -platform macx-clang \ + -device-option QMAKE_APPLE_DEVICE_ARCHS=x86_64 \ + -device-option QMAKE_MACOSX_DEPLOYMENT_TARGET=10.10 \ + -release \ + -opensource -confirm-license \ + -gui \ + -widgets \ + -no-gif \ + -no-icu \ + -no-pch \ + -no-angle \ + -no-opengl \ + -no-dbus \ + -no-harfbuzz \ + -skip declarative \ + -skip multimedia \ + -skip qtcanvas3d \ + -skip qtcharts \ + -skip qtconnectivity \ + -skip qtdeclarative \ + -skip qtgamepad \ + -skip qtlocation \ + -skip qtmultimedia \ + -skip qtnetworkauth \ + -skip qtpurchasing \ + -skip qtremoteobjects \ + -skip qtscript \ + -skip qtsensors \ + -skip qtserialbus \ + -skip qtserialport \ + -skip qtsvg \ + -skip qtwebchannel \ + -skip qtwebengine \ + -skip qtwebsockets \ + -skip qtxmlpatterns \ + -nomake examples \ + -nomake tests \ + -nomake tools +make -j 8 +cd .. + +# Build the arm64 variant. +mkdir qt-5.9.9-arm64 +cd qt-5.9.9-arm64 +../qt-everywhere-opensource-src-5.9.9/configure \ + --prefix=/ \ + -platform macx-clang \ + -device-option QMAKE_APPLE_DEVICE_ARCHS=arm64 \ + -device-option QMAKE_MACOSX_DEPLOYMENT_TARGET=10.10 \ + -release \ + -opensource -confirm-license \ + -gui \ + -widgets \ + -no-gif \ + -no-icu \ + -no-pch \ + -no-angle \ + -no-opengl \ + -no-dbus \ + -no-harfbuzz \ + -skip declarative \ + -skip multimedia \ + -skip qtcanvas3d \ + -skip qtcharts \ + -skip qtconnectivity \ + -skip qtdeclarative \ + -skip qtgamepad \ + -skip qtlocation \ + -skip qtmultimedia \ + -skip qtnetworkauth \ + -skip qtpurchasing \ + -skip qtremoteobjects \ + -skip qtscript \ + -skip qtsensors \ + -skip qtserialbus \ + -skip qtserialport \ + -skip qtsvg \ + -skip qtwebchannel \ + -skip qtwebengine \ + -skip qtwebsockets \ + -skip qtxmlpatterns \ + -nomake examples \ + -nomake tests \ + -nomake tools +# Some executables fail to link due to architecture mismatch. +# Build what we can first. +make -j 8 -k || true +# Provide needed executables using the x86_64 variants. +cp ../qt-5.9.9-x86_64/qtbase/bin/uic qtbase/bin/uic +install_name_tool -add_rpath @executable_path/../../../qt-5.9.9-x86_64/qtbase/lib qtbase/bin/uic +cp ../qt-5.9.9-x86_64/qtbase/bin/qlalr qtbase/bin/qlalr +install_name_tool -add_rpath @executable_path/../../../qt-5.9.9-x86_64/qtbase/lib qtbase/bin/qlalr +# Some parts still fail to build, but the parts we need can finish. +make -j 8 -k || true +cd .. + +# Combine the two builds into universal binaries. +makeuniversal qt-5.9.9-univ qt-5.9.9-x86_64 qt-5.9.9-arm64 +cd qt-5.9.9-univ +make install -j 8 INSTALL_ROOT=/tmp/qt-5.9.9-macosx10.10-x86_64-arm64 +cd .. + +# Create the final tarball containing universal binaries. +tar cjf qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz -C /tmp qt-5.9.9-macosx10.10-x86_64-arm64 -- cgit v0.12 From 41bddf1028689981d736b39665242fa0f91c99f8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Dec 2020 10:08:15 -0500 Subject: ci: update to pre-built Qt 5.9.9 universal binaries for macOS packages --- .gitlab/ci/download_qt.cmake | 4 ++-- .gitlab/ci/download_qt_hashes.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/download_qt.cmake b/.gitlab/ci/download_qt.cmake index c7e3717..4a33f12 100644 --- a/.gitlab/ci/download_qt.cmake +++ b/.gitlab/ci/download_qt.cmake @@ -50,8 +50,8 @@ if (qt_platform STREQUAL "windows_x86") elseif (qt_platform STREQUAL "mac_x64") if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package") list(APPEND qt_files - "qt-5.6.2-macosx10.7-x86_64.tar.xz") - set(qt_subdir "qt-5.6.2-macosx10.7-x86_64") + "qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz") + set(qt_subdir "qt-5.9.9-macosx10.10-x86_64-arm64") else () set(qt_build_stamp "202009071110") set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}") diff --git a/.gitlab/ci/download_qt_hashes.cmake b/.gitlab/ci/download_qt_hashes.cmake index 02a6fdd..0d286b5 100644 --- a/.gitlab/ci/download_qt_hashes.cmake +++ b/.gitlab/ci/download_qt_hashes.cmake @@ -10,4 +10,4 @@ set("5.15.1-0-202009071110qtwinextras-Windows-Windows_10-MSVC2015-Windows-Window set("5.15.1-0-202009071110qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" df2813ce7c6cb4287abd7956cd1cb9d08312e4ac1208b6cb57af4df11b8ebba1) -set("qt-5.6.2-macosx10.7-x86_64.tar.xz_hash" 2b60373ea60037ce356d4c9f5a8c1df9854127a2c55118252e1a2f5a5f4e0010) +set("qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz_hash" aa6229bc6bd01a44d18b07023417698fdf4de7a02b14e971b473d80956a57a1c) -- cgit v0.12 From b184cc256b4eb0c140accc913dd3e62e08650c74 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Dec 2020 10:30:30 -0500 Subject: ci: do not use sccache for macOS packaging It is not compatible with building for multiple architectures. --- .gitlab/ci/configure_common.cmake | 4 +++- .gitlab/ci/configure_macos_package.cmake | 4 ++++ .gitlab/os-macos.yml | 5 ----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake index df49b2d..436e582 100644 --- a/.gitlab/ci/configure_common.cmake +++ b/.gitlab/ci/configure_common.cmake @@ -10,4 +10,6 @@ if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "$ENV{CMAKE_BUILD_TYPE}" CACHE STRING "") endif () -include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake") +if (NOT configure_no_sccache) + include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake") +endif() diff --git a/.gitlab/ci/configure_macos_package.cmake b/.gitlab/ci/configure_macos_package.cmake index 424bc2b..18ef309 100644 --- a/.gitlab/ci/configure_macos_package.cmake +++ b/.gitlab/ci/configure_macos_package.cmake @@ -20,5 +20,9 @@ set(CMake_INSTALL_DEPENDENCIES "ON" CACHE BOOL "") set(CMAKE_SKIP_RPATH "TRUE" CACHE BOOL "") set(CMake_TEST_NO_FindPackageModeMakefileTest "TRUE" CACHE BOOL "") +# XXX(sccache): restore sccache when it works for multiple architectures: +# https://github.com/mozilla/sccache/issues/847 +set(configure_no_sccache 1) + include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake") include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index d9df621..8a006b1 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -115,13 +115,8 @@ script: - *before_script_macos - - .gitlab/ci/sccache.sh - # Allow the server to already be running. - - "sccache --start-server || :" - - sccache --show-stats - ctest -VV -S .gitlab/ci/ctest_configure.cmake - ctest -VV -S .gitlab/ci/ctest_build.cmake - - sccache --show-stats - cd build - cpack -G TGZ - cpack -G DragNDrop -- cgit v0.12 From 56a075eb5df3fc6a1bc400e1c1322985dc1ca3c9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Dec 2020 10:17:27 -0500 Subject: ci: update macOS package to produce universal binaries Update our deployment target to macOS 10.10. This is required by Qt 5.9. Fixes: #21565 Issue: #20825 --- .gitlab/artifacts.yml | 2 +- .gitlab/ci/configure_macos_package.cmake | 6 +++--- Help/release/3.19.rst | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index 0506e99..589b16c 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -74,7 +74,7 @@ paths: # Any packages made. - build/cmake-*-Linux-x86_64.* - - build/cmake-*-Darwin-x86_64.* + - build/cmake-*-macos-universal.* # Any source packages made. - build/cmake-*.tar.gz - build/cmake-*.zip diff --git a/.gitlab/ci/configure_macos_package.cmake b/.gitlab/ci/configure_macos_package.cmake index 18ef309..a1dbdb9 100644 --- a/.gitlab/ci/configure_macos_package.cmake +++ b/.gitlab/ci/configure_macos_package.cmake @@ -9,10 +9,10 @@ set(CPACK_DMG_FORMAT "UDBZ" CACHE STRING "") set(CMAKE_CXX_FLAGS "-stdlib=libc++" CACHE STRING "") set(CMAKE_C_STANDARD "11" CACHE STRING "") set(CMAKE_CXX_STANDARD "14" CACHE STRING "") -set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "") -set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "") +set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "") +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "") set(CMAKE_SKIP_BOOTSTRAP_TEST "TRUE" CACHE STRING "") -set(CPACK_SYSTEM_NAME "Darwin-x86_64" CACHE STRING "") +set(CPACK_SYSTEM_NAME "macos-universal" CACHE STRING "") set(BUILD_CursesDialog "ON" CACHE BOOL "") set(BUILD_QtDialog "TRUE" CACHE BOOL "") set(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL "3" CACHE STRING "") diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index a29dc07..899e745 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -348,3 +348,12 @@ Changes made since CMake 3.19.0 include the following. been reverted to restore behavior from CMake 3.18 and below. * CUDA 11.1 support for Clang. + +3.19.2 +------ + +* The precompiled macOS binary provided on ``cmake.org`` is now a + universal binary with ``x86_64`` and ``arm64`` architectures. + It requires macOS 10.10 or newer. + The package file naming pattern has been changed from + ``cmake-$ver-Darwin-x86_64`` to ``cmake-$ver-macos-universal``. -- cgit v0.12 From 5f882f6ce518a9f90600ae5c73f633ca5c15a7e5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 8 Dec 2020 15:20:01 -0500 Subject: macOS: Offer control over host architecture on Apple Silicon hosts Since commit b6c60f14b6 (macOS: Default to arm64 architecture on Apple Silicon hosts, 2020-09-28, v3.19.0-rc1~63^2) we use `sysctl` to detect that we are running on Apple Silicon in a way that pierces Rosetta. This always sets `CMAKE_HOST_SYSTEM_PROCESSOR` to be `arm64` on such hosts. However, macOS offers strong support for running processes under an emulated `x86_64` architecture. Teach CMake to select either `arm64` or `x86_64` as the host architecture on Apple Silicon based on the architecture of its own process. When CMake is built as a universal binary, macOS will select whichever slice (architecture) is appropriate under the user's shell, and `CMAKE_HOST_SYSTEM_PROCESSOR` will match. Also offer a `CMAKE_APPLE_SILICON_PROCESSOR` variable and environment variable to provide users with explicit control over the host architecture selection regardless of CMake's own architecture. Finally, if `CMAKE_OSX_ARCHITECTURES` is not set, pass explicit flags to the toolchain to use selected host architecture instead of letting the toolchain pick. Fixes: #21554 --- Help/envvar/CMAKE_APPLE_SILICON_PROCESSOR.rst | 13 +++++++++ Help/manual/cmake-env-variables.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/release/3.19.rst | 24 ++++++++++++++++ Help/variable/CMAKE_APPLE_SILICON_PROCESSOR.rst | 15 ++++++++++ Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst | 33 ++++++++++++++++++++-- Modules/CMakeDetermineSystem.cmake | 37 +++++++++++++++++++------ Modules/Platform/Darwin-Initialize.cmake | 17 +++++++++--- 8 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 Help/envvar/CMAKE_APPLE_SILICON_PROCESSOR.rst create mode 100644 Help/variable/CMAKE_APPLE_SILICON_PROCESSOR.rst diff --git a/Help/envvar/CMAKE_APPLE_SILICON_PROCESSOR.rst b/Help/envvar/CMAKE_APPLE_SILICON_PROCESSOR.rst new file mode 100644 index 0000000..adecb72 --- /dev/null +++ b/Help/envvar/CMAKE_APPLE_SILICON_PROCESSOR.rst @@ -0,0 +1,13 @@ +CMAKE_APPLE_SILICON_PROCESSOR +----------------------------- + +.. versionadded:: 3.19.2 + +.. include:: ENV_VAR.txt + +On Apple Silicon hosts running macOS, set this environment variable to tell +CMake what architecture to use for :variable:`CMAKE_HOST_SYSTEM_PROCESSOR`. +The value must be either ``arm64`` or ``x86_64``. + +The :variable:`CMAKE_APPLE_SILICON_PROCESSOR` normal variable, if set, +overrides this environment variable. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index 13e0d39..d9cfa7a 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -28,6 +28,7 @@ Environment Variables that Control the Build .. toctree:: :maxdepth: 1 + /envvar/CMAKE_APPLE_SILICON_PROCESSOR /envvar/CMAKE_BUILD_PARALLEL_LEVEL /envvar/CMAKE_CONFIG_TYPE /envvar/CMAKE_EXPORT_COMPILE_COMMANDS diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 17d0882..daae7f7 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -353,6 +353,7 @@ Variables that Control the Build /variable/CMAKE_ANDROID_SKIP_ANT_STEP /variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN /variable/CMAKE_ANDROID_STL_TYPE + /variable/CMAKE_APPLE_SILICON_PROCESSOR /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index 899e745..4f26058 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -53,6 +53,22 @@ Languages * ``CUDA`` language support now works on QNX. +Platforms +--------- + +* Apple Silicon is now supported (since CMake 3.19.2): + + * The :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` is selected using ``uname -m``. + Since this may vary based on CMake's own architecture and that of + the invoking process tree, the :variable:`CMAKE_APPLE_SILICON_PROCESSOR` + variable or :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment + variable may be set to specify a host architecture explicitly. + + * If :variable:`CMAKE_OSX_ARCHITECTURES` is not set, CMake adds explicit + flags to tell the compiler to build for the + :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` so the toolchain does not + have to guess based on the process tree's architecture. + File-Based API -------------- @@ -357,3 +373,11 @@ Changes made since CMake 3.19.0 include the following. It requires macOS 10.10 or newer. The package file naming pattern has been changed from ``cmake-$ver-Darwin-x86_64`` to ``cmake-$ver-macos-universal``. + +* Apple Silicon host architecture selection support was updated. + CMake 3.19.0 and 3.19.1 always chose ``arm64`` as the host architecture. + CMake 3.19.2 returns to using ``uname -m`` as CMake 3.18 and below did. + Since this may vary based on CMake's own architecture and that of + the invoking process tree, the :variable:`CMAKE_APPLE_SILICON_PROCESSOR` + variable or :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment + variable may be set to specify a host architecture explicitly. diff --git a/Help/variable/CMAKE_APPLE_SILICON_PROCESSOR.rst b/Help/variable/CMAKE_APPLE_SILICON_PROCESSOR.rst new file mode 100644 index 0000000..ad297c3 --- /dev/null +++ b/Help/variable/CMAKE_APPLE_SILICON_PROCESSOR.rst @@ -0,0 +1,15 @@ +CMAKE_APPLE_SILICON_PROCESSOR +----------------------------- + +.. versionadded:: 3.19.2 + +On Apple Silicon hosts running macOS, set this variable to tell +CMake what architecture to use for :variable:`CMAKE_HOST_SYSTEM_PROCESSOR`. +The value must be either ``arm64`` or ``x86_64``. + +The value of this variable should never be modified by project code. +It is meant to be set by a toolchain file specified by the +:variable:`CMAKE_TOOLCHAIN_FILE` variable, or as a cache entry +provided by the user, e.g. via ``-DCMAKE_APPLE_SILICON_PROCESSOR=...``. + +See also the :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment variable. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst index 5f08728..c305779 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst @@ -3,13 +3,40 @@ CMAKE_HOST_SYSTEM_PROCESSOR The name of the CPU CMake is running on. +Windows Platforms +^^^^^^^^^^^^^^^^^ + On Windows, this variable is set to the value of the environment variable -``PROCESSOR_ARCHITECTURE``. On systems that support ``uname``, this variable is -set to the output of: +``PROCESSOR_ARCHITECTURE``. + +Unix Platforms +^^^^^^^^^^^^^^ + +On systems that support ``uname``, this variable is set to the output of: -- ``uname -m`` on GNU, Linux, Cygwin, Darwin, Android, or +- ``uname -m`` on GNU, Linux, Cygwin, Android, or - ``arch`` on OpenBSD, or - on other systems, * ``uname -p`` if its exit code is nonzero, or * ``uname -m`` otherwise. + +macOS Platforms +^^^^^^^^^^^^^^^ + +The value of ``uname -m`` is used by default. + +On Apple Silicon hosts, the architecture printed by ``uname -m`` may vary +based on CMake's own architecture and that of the invoking process tree. + +.. versionadded:: 3.19.2 + + On Apple Silicon hosts: + + * The :variable:`CMAKE_APPLE_SILICON_PROCESSOR` variable or + the :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment variable + may be set to specify the host architecture explicitly. + + * If :variable:`CMAKE_OSX_ARCHITECTURES` is not set, CMake adds explicit + flags to tell the compiler to build for the host architecture so the + toolchain does not have to guess based on the process tree's architecture. diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index cb4421a..bae270d 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -43,25 +43,44 @@ if(CMAKE_HOST_UNIX) else() exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) endif() - if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$|Android") + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|^GNU$|Android") exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") - if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") - # Check whether we are running under Rosetta on arm64 hardware. + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + # If we are running on Apple Silicon, honor CMAKE_APPLE_SILICON_PROCESSOR. + if(DEFINED CMAKE_APPLE_SILICON_PROCESSOR) + set(_CMAKE_APPLE_SILICON_PROCESSOR "${CMAKE_APPLE_SILICON_PROCESSOR}") + elseif(DEFINED ENV{CMAKE_APPLE_SILICON_PROCESSOR}) + set(_CMAKE_APPLE_SILICON_PROCESSOR "$ENV{CMAKE_APPLE_SILICON_PROCESSOR}") + else() + set(_CMAKE_APPLE_SILICON_PROCESSOR "") + endif() + if(_CMAKE_APPLE_SILICON_PROCESSOR) + if(";${_CMAKE_APPLE_SILICON_PROCESSOR};" MATCHES "^;(arm64|x86_64);$") execute_process(COMMAND sysctl -q hw.optional.arm64 OUTPUT_VARIABLE _sysctl_stdout ERROR_VARIABLE _sysctl_stderr RESULT_VARIABLE _sysctl_result ) - if(_sysctl_result EQUAL 0 AND _sysctl_stdout MATCHES "hw.optional.arm64: 1") - set(CMAKE_HOST_SYSTEM_PROCESSOR "arm64") + if(NOT _sysctl_result EQUAL 0 OR NOT _sysctl_stdout MATCHES "hw.optional.arm64: 1") + set(_CMAKE_APPLE_SILICON_PROCESSOR "") endif() - elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") - # OS X ppc 'uname -m' may report 'Power Macintosh' instead of 'powerpc' - set(CMAKE_HOST_SYSTEM_PROCESSOR "powerpc") + unset(_sysctl_result) + unset(_sysctl_stderr) + unset(_sysctl_stdout) endif() endif() + if(_CMAKE_APPLE_SILICON_PROCESSOR) + set(CMAKE_HOST_SYSTEM_PROCESSOR "${_CMAKE_APPLE_SILICON_PROCESSOR}") + else() + exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RETURN_VALUE val) + endif() + unset(_CMAKE_APPLE_SILICON_PROCESSOR) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") + # OS X ppc 'uname -m' may report 'Power Macintosh' instead of 'powerpc' + set(CMAKE_HOST_SYSTEM_PROCESSOR "powerpc") + endif() elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD") exec_program(arch ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index 213f71b..c2f1851 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -22,13 +22,22 @@ set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND - CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" AND - CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") - # When building on Apple Silicon (arm64), we need to explicitly specify + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm64|x86_64)$") + execute_process(COMMAND sysctl -q hw.optional.arm64 + OUTPUT_VARIABLE _sysctl_stdout + ERROR_VARIABLE _sysctl_stderr + RESULT_VARIABLE _sysctl_result + ) + # When building on an Apple Silicon host, we need to explicitly specify # the architecture to the toolchain since it will otherwise guess the # architecture based on that of the build system tool. # Set an *internal variable* to tell the generators to do this. - set(_CMAKE_APPLE_ARCHS_DEFAULT "arm64") + if(_sysctl_result EQUAL 0 AND _sysctl_stdout MATCHES "hw.optional.arm64: 1") + set(_CMAKE_APPLE_ARCHS_DEFAULT "${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + unset(_sysctl_result) + unset(_sysctl_stderr) + unset(_sysctl_stdout) endif() # macOS, iOS, tvOS, and watchOS should lookup compilers from -- cgit v0.12 From b7f0327dcd4032c6a118825adcfdc8dab6295e7f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Dec 2020 10:28:03 -0500 Subject: Tests: Cover macOS host architecture selection on Apple Silicon hosts Add test cases verifying that `CMAKE_APPLE_SILICON_PROCESSOR` set as either a cache or environment variable causes that to be selected as the host architecture. Also verify that sources compile using whatever is selected as the host architecture, even when the explicit setting is not used. Issue: #21554 --- Tests/CMakeLists.txt | 16 +++++++++++++++ Tests/RunCMake/AppleSilicon/CMakeLists.txt | 3 +++ Tests/RunCMake/AppleSilicon/RunCMakeTest.cmake | 27 +++++++++++++++++++++++++ Tests/RunCMake/AppleSilicon/arm64-common.cmake | 10 +++++++++ Tests/RunCMake/AppleSilicon/arm64-env.cmake | 1 + Tests/RunCMake/AppleSilicon/arm64-var.cmake | 1 + Tests/RunCMake/AppleSilicon/arm64.c | 9 +++++++++ Tests/RunCMake/AppleSilicon/default.c | 14 +++++++++++++ Tests/RunCMake/AppleSilicon/default.cmake | 15 ++++++++++++++ Tests/RunCMake/AppleSilicon/x86_64-common.cmake | 10 +++++++++ Tests/RunCMake/AppleSilicon/x86_64-env.cmake | 1 + Tests/RunCMake/AppleSilicon/x86_64-var.cmake | 1 + Tests/RunCMake/AppleSilicon/x86_64.c | 9 +++++++++ Tests/RunCMake/CMakeLists.txt | 3 +++ 14 files changed, 120 insertions(+) create mode 100644 Tests/RunCMake/AppleSilicon/CMakeLists.txt create mode 100644 Tests/RunCMake/AppleSilicon/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/AppleSilicon/arm64-common.cmake create mode 100644 Tests/RunCMake/AppleSilicon/arm64-env.cmake create mode 100644 Tests/RunCMake/AppleSilicon/arm64-var.cmake create mode 100644 Tests/RunCMake/AppleSilicon/arm64.c create mode 100644 Tests/RunCMake/AppleSilicon/default.c create mode 100644 Tests/RunCMake/AppleSilicon/default.cmake create mode 100644 Tests/RunCMake/AppleSilicon/x86_64-common.cmake create mode 100644 Tests/RunCMake/AppleSilicon/x86_64-env.cmake create mode 100644 Tests/RunCMake/AppleSilicon/x86_64-var.cmake create mode 100644 Tests/RunCMake/AppleSilicon/x86_64.c diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 02759d1..1fb47cb 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -228,6 +228,22 @@ if(BUILD_TESTING) endif() endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT DEFINED CMake_TEST_APPLE_SILICON) + execute_process(COMMAND sysctl -q hw.optional.arm64 + OUTPUT_VARIABLE _sysctl_stdout + ERROR_VARIABLE _sysctl_stderr + RESULT_VARIABLE _sysctl_result + ) + if(_sysctl_result EQUAL 0 AND _sysctl_stdout MATCHES "hw.optional.arm64: 1") + set(CMake_TEST_APPLE_SILICON 1) + else() + set(CMake_TEST_APPLE_SILICON 0) + endif() + unset(_sysctl_result) + unset(_sysctl_stderr) + unset(_sysctl_stdout) + endif() + #--------------------------------------------------------------------------- # Add tests below here. diff --git a/Tests/RunCMake/AppleSilicon/CMakeLists.txt b/Tests/RunCMake/AppleSilicon/CMakeLists.txt new file mode 100644 index 0000000..ab1a20c --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.19) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/AppleSilicon/RunCMakeTest.cmake b/Tests/RunCMake/AppleSilicon/RunCMakeTest.cmake new file mode 100644 index 0000000..39e462e --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/RunCMakeTest.cmake @@ -0,0 +1,27 @@ +include(RunCMake) + +# Isolate from caller's environment. +set(ENV{CMAKE_APPLE_SILICON_PROCESSOR} "") +set(ENV{CMAKE_OSX_ARCHITECTURES} "") + +function(run_arch case) + set(RunCMake_TEST_OPTIONS ${ARGN}) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") + run_cmake(${case}) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() + +run_arch(default) + +run_arch(arm64-var -DCMAKE_APPLE_SILICON_PROCESSOR=arm64) +run_arch(x86_64-var -DCMAKE_APPLE_SILICON_PROCESSOR=x86_64) + +set(ENV{CMAKE_APPLE_SILICON_PROCESSOR} "arm64") +run_arch(arm64-env) + +set(ENV{CMAKE_APPLE_SILICON_PROCESSOR} "x86_64") +run_arch(x86_64-env) + +set(ENV{CMAKE_APPLE_SILICON_PROCESSOR} "") diff --git a/Tests/RunCMake/AppleSilicon/arm64-common.cmake b/Tests/RunCMake/AppleSilicon/arm64-common.cmake new file mode 100644 index 0000000..5a13728 --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/arm64-common.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_PROCESSOR is '${CMAKE_HOST_SYSTEM_PROCESSOR}', not 'arm64'") +endif() +if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES is '${CMAKE_OSX_ARCHITECTURES}', not empty ''") +endif() + +add_library(arm64 arm64.c) diff --git a/Tests/RunCMake/AppleSilicon/arm64-env.cmake b/Tests/RunCMake/AppleSilicon/arm64-env.cmake new file mode 100644 index 0000000..8cb9dbc --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/arm64-env.cmake @@ -0,0 +1 @@ +include(arm64-common.cmake) diff --git a/Tests/RunCMake/AppleSilicon/arm64-var.cmake b/Tests/RunCMake/AppleSilicon/arm64-var.cmake new file mode 100644 index 0000000..8cb9dbc --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/arm64-var.cmake @@ -0,0 +1 @@ +include(arm64-common.cmake) diff --git a/Tests/RunCMake/AppleSilicon/arm64.c b/Tests/RunCMake/AppleSilicon/arm64.c new file mode 100644 index 0000000..d5f65fe --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/arm64.c @@ -0,0 +1,9 @@ +#ifndef __aarch64__ +# error "Not compiling as arm64" +#endif +#ifdef __x86_64__ +# error "Incorrectly compiling as x86_64" +#endif +void arm64_arch(void) +{ +} diff --git a/Tests/RunCMake/AppleSilicon/default.c b/Tests/RunCMake/AppleSilicon/default.c new file mode 100644 index 0000000..7b0535b --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/default.c @@ -0,0 +1,14 @@ +#if defined(HOST_ARM64) +# if !defined(__aarch64__) +# error "Not compiling as host arm64" +# endif +#elif defined(HOST_X86_64) +# if !defined(__x86_64__) +# error "Not compiling as host x86_64" +# endif +#else +# error "One of HOST_ARM64 or HOST_X86_64 must be defined." +#endif +void default_arch(void) +{ +} diff --git a/Tests/RunCMake/AppleSilicon/default.cmake b/Tests/RunCMake/AppleSilicon/default.cmake new file mode 100644 index 0000000..f160e25 --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/default.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") + set(host_def HOST_ARM64) +elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(host_def HOST_X86_64) +else() + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_PROCESSOR is '${CMAKE_HOST_SYSTEM_PROCESSOR}', not 'arm64' or 'x86_64'") +endif() +if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES is '${CMAKE_OSX_ARCHITECTURES}', not empty ''") +endif() + +add_library(default default.c) +target_compile_definitions(default PRIVATE ${host_def}) diff --git a/Tests/RunCMake/AppleSilicon/x86_64-common.cmake b/Tests/RunCMake/AppleSilicon/x86_64-common.cmake new file mode 100644 index 0000000..602bf92 --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/x86_64-common.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_PROCESSOR is '${CMAKE_HOST_SYSTEM_PROCESSOR}', not 'x86_64'") +endif() +if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES is '${CMAKE_OSX_ARCHITECTURES}', not empty ''") +endif() + +add_library(x86_64 x86_64.c) diff --git a/Tests/RunCMake/AppleSilicon/x86_64-env.cmake b/Tests/RunCMake/AppleSilicon/x86_64-env.cmake new file mode 100644 index 0000000..a44eaa4 --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/x86_64-env.cmake @@ -0,0 +1 @@ +include(x86_64-common.cmake) diff --git a/Tests/RunCMake/AppleSilicon/x86_64-var.cmake b/Tests/RunCMake/AppleSilicon/x86_64-var.cmake new file mode 100644 index 0000000..a44eaa4 --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/x86_64-var.cmake @@ -0,0 +1 @@ +include(x86_64-common.cmake) diff --git a/Tests/RunCMake/AppleSilicon/x86_64.c b/Tests/RunCMake/AppleSilicon/x86_64.c new file mode 100644 index 0000000..cd3cc9b --- /dev/null +++ b/Tests/RunCMake/AppleSilicon/x86_64.c @@ -0,0 +1,9 @@ +#ifndef __x86_64__ +# error "Not compiling as x86_64" +#endif +#ifdef __aarch64__ +# error "Incorrectly compiling as arm64" +#endif +void x86_64_arch(void) +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 615bf20..4f1a9f7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -176,6 +176,9 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() add_RunCMake_test(AndroidTestUtilities) +if(CMake_TEST_APPLE_SILICON) + add_RunCMake_test(AppleSilicon) +endif() set(autogen_with_qt5 FALSE) if(CMake_TEST_Qt5) find_package(Qt5Widgets QUIET NO_MODULE) -- cgit v0.12 From 08164823027f16b0839e705103226a1a7e33cb9f Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 11 Dec 2020 11:11:29 +1100 Subject: Help: xref variable that cmake_minimum_required() sets The CMAKE_MINIMUM_REQUIRED_VERSION has long been set by the cmake_minimum_required() command, but the command docs never mentioned this. Only the variable's own docs stated this but the variable isn't very discoverable without it being mentioned in the command's docs as well. --- Help/command/cmake_minimum_required.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst index e6ebcf0..f3326b8 100644 --- a/Help/command/cmake_minimum_required.rst +++ b/Help/command/cmake_minimum_required.rst @@ -22,6 +22,9 @@ dots will be seen as version component separators, resulting in the ``...`` part being ignored and preserving the pre-3.12 behavior of basing policies on ````. +This command will set the value of the +:variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable to ````. + The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and higher. It should be specified so CMake versions 2.4 and lower fail with an error instead of just a warning. -- cgit v0.12 From 2c33949c64230547bb15265f015f6b6eb1fb9493 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sun, 29 Nov 2020 18:51:08 +1100 Subject: Help: Mention how OPTIMIZE_DEPENDENCIES is initialized --- Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst b/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst index 2fdf1a9..d17251f 100644 --- a/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst +++ b/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst @@ -38,3 +38,6 @@ side effects that are relevant for the Fortran library. However, if you build the middle C library, the bottom Fortran library will also build, even though it does not have any side effects that are relevant to the C library, since the C library does not have optimization enabled. + +This property is initialized by the value of the +:variable:`CMAKE_OPTIMIZE_DEPENDENCIES` variable when the target is created. -- cgit v0.12 From b4c02a0a1d4ab285ba0594fc830cf5f0114464d9 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 11 Dec 2020 11:17:08 +1100 Subject: Help: Re-sort indexes in the manuals --- Help/manual/cmake-modules.7.rst | 34 ++++++++--------- Help/manual/cmake-properties.7.rst | 78 +++++++++++++++++++------------------- Help/manual/cmake-variables.7.rst | 8 ++-- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 14af149..431797f 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -19,6 +19,7 @@ These modules are loaded using the :command:`include` command. /module/AndroidTestUtilities /module/BundleUtilities /module/CheckCCompilerFlag + /module/CheckCompilerFlag /module/CheckCSourceCompiles /module/CheckCSourceRuns /module/CheckCXXCompilerFlag @@ -30,10 +31,10 @@ These modules are loaded using the :command:`include` command. /module/CheckFortranSourceCompiles /module/CheckFortranSourceRuns /module/CheckFunctionExists - /module/CheckIPOSupported /module/CheckIncludeFileCXX /module/CheckIncludeFile /module/CheckIncludeFiles + /module/CheckIPOSupported /module/CheckLanguage /module/CheckLibraryExists /module/CheckLinkerFlag @@ -45,7 +46,6 @@ These modules are loaded using the :command:`include` command. /module/CheckOBJCXXSourceRuns /module/CheckPIESupported /module/CheckPrototypeDefinition - /module/CheckCompilerFlag /module/CheckSourceCompiles /module/CheckSourceRuns /module/CheckStructHasMember @@ -64,10 +64,10 @@ These modules are loaded using the :command:`include` command. /module/CMakePrintSystemInformation /module/CMakePushCheckState /module/CMakeVerifyManifest + /module/CPack /module/CPackComponent /module/CPackIFW /module/CPackIFWConfigureFile - /module/CPack /module/CSharpUtilities /module/CTest /module/CTestCoverageCollectGCOV @@ -97,8 +97,8 @@ These modules are loaded using the :command:`include` command. /module/TestForSSTREAM /module/TestForSTDNamespace /module/UseEcos - /module/UseJavaClassFilelist /module/UseJava + /module/UseJavaClassFilelist /module/UseJavaSymlinks /module/UseSWIG /module/UsewxWidgets @@ -117,16 +117,16 @@ They are normally called through the :command:`find_package` command. /module/FindArmadillo /module/FindASPELL /module/FindAVIFile + /module/FindBacktrace /module/FindBISON /module/FindBLAS - /module/FindBacktrace /module/FindBoost /module/FindBullet /module/FindBZip2 /module/FindCABLE /module/FindCoin3D - /module/FindCups /module/FindCUDAToolkit + /module/FindCups /module/FindCURL /module/FindCurses /module/FindCVS @@ -139,8 +139,8 @@ They are normally called through the :command:`find_package` command. /module/FindEnvModules /module/FindEXPAT /module/FindFLEX - /module/FindFLTK2 /module/FindFLTK + /module/FindFLTK2 /module/FindFontconfig /module/FindFreetype /module/FindGCCXML @@ -154,17 +154,17 @@ They are normally called through the :command:`find_package` command. /module/FindGnuTLS /module/FindGSL /module/FindGTest - /module/FindGTK2 /module/FindGTK + /module/FindGTK2 /module/FindHDF5 /module/FindHg /module/FindHSPELL /module/FindHTMLHelp /module/FindIce + /module/FindIconv /module/FindIcotool /module/FindICU /module/FindImageMagick - /module/FindIconv /module/FindIntl /module/FindITK /module/FindJasper @@ -181,14 +181,14 @@ They are normally called through the :command:`find_package` command. /module/FindLibXml2 /module/FindLibXslt /module/FindLTTngUST + /module/FindLua /module/FindLua50 /module/FindLua51 - /module/FindLua /module/FindMatlab /module/FindMFC /module/FindMotif - /module/FindMPEG2 /module/FindMPEG + /module/FindMPEG2 /module/FindMPI /module/FindODBC /module/FindOpenACC @@ -199,9 +199,10 @@ They are normally called through the :command:`find_package` command. /module/FindOpenSceneGraph /module/FindOpenSSL /module/FindOpenThreads + /module/Findosg + /module/Findosg_functions /module/FindosgAnimation /module/FindosgDB - /module/Findosg_functions /module/FindosgFX /module/FindosgGA /module/FindosgIntrospection @@ -210,7 +211,6 @@ They are normally called through the :command:`find_package` command. /module/FindosgPresentation /module/FindosgProducer /module/FindosgQt - /module/Findosg /module/FindosgShadow /module/FindosgSim /module/FindosgTerrain @@ -220,8 +220,8 @@ They are normally called through the :command:`find_package` command. /module/FindosgVolume /module/FindosgWidget /module/FindPatch - /module/FindPerlLibs /module/FindPerl + /module/FindPerlLibs /module/FindPHP4 /module/FindPhysFS /module/FindPike @@ -238,10 +238,10 @@ They are normally called through the :command:`find_package` command. /module/FindQuickTime /module/FindRTI /module/FindRuby + /module/FindSDL /module/FindSDL_image /module/FindSDL_mixer /module/FindSDL_net - /module/FindSDL /module/FindSDL_sound /module/FindSDL_ttf /module/FindSelfPackers @@ -260,10 +260,10 @@ They are normally called through the :command:`find_package` command. /module/FindWget /module/FindWish /module/FindwxWidgets - /module/FindXCTest + /module/FindX11 /module/FindXalanC + /module/FindXCTest /module/FindXercesC - /module/FindX11 /module/FindXMLRPC /module/FindZLIB diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index cb9579e..bd6e5c6 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -75,8 +75,8 @@ Properties on Directories /prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM /prop_dir/INCLUDE_DIRECTORIES /prop_dir/INCLUDE_REGULAR_EXPRESSION - /prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_dir/INTERPROCEDURAL_OPTIMIZATION + /prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_dir/LABELS /prop_dir/LINK_DIRECTORIES /prop_dir/LINK_OPTIONS @@ -124,10 +124,10 @@ Properties on Targets /prop_tgt/ANDROID_SECURE_PROPS_PATH /prop_tgt/ANDROID_SKIP_ANT_STEP /prop_tgt/ANDROID_STL_TYPE - /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY - /prop_tgt/ARCHIVE_OUTPUT_NAME_CONFIG + /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG /prop_tgt/ARCHIVE_OUTPUT_NAME + /prop_tgt/ARCHIVE_OUTPUT_NAME_CONFIG /prop_tgt/AUTOGEN_BUILD_DIR /prop_tgt/AUTOGEN_ORIGIN_DEPENDS /prop_tgt/AUTOGEN_PARALLEL @@ -151,8 +151,8 @@ Properties on Targets /prop_tgt/BUILD_RPATH_USE_ORIGIN /prop_tgt/BUILD_WITH_INSTALL_NAME_DIR /prop_tgt/BUILD_WITH_INSTALL_RPATH - /prop_tgt/BUNDLE_EXTENSION /prop_tgt/BUNDLE + /prop_tgt/BUNDLE_EXTENSION /prop_tgt/C_EXTENSIONS /prop_tgt/C_STANDARD /prop_tgt/C_STANDARD_REQUIRED @@ -173,11 +173,11 @@ Properties on Targets /prop_tgt/CONFIG_POSTFIX /prop_tgt/CROSSCOMPILING_EMULATOR /prop_tgt/CUDA_ARCHITECTURES + /prop_tgt/CUDA_EXTENSIONS /prop_tgt/CUDA_PTX_COMPILATION - /prop_tgt/CUDA_SEPARABLE_COMPILATION /prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS /prop_tgt/CUDA_RUNTIME_LIBRARY - /prop_tgt/CUDA_EXTENSIONS + /prop_tgt/CUDA_SEPARABLE_COMPILATION /prop_tgt/CUDA_STANDARD /prop_tgt/CUDA_STANDARD_REQUIRED /prop_tgt/CXX_EXTENSIONS @@ -185,8 +185,8 @@ Properties on Targets /prop_tgt/CXX_STANDARD_REQUIRED /prop_tgt/DEBUG_POSTFIX /prop_tgt/DEFINE_SYMBOL - /prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY /prop_tgt/DEPLOYMENT_ADDITIONAL_FILES + /prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY /prop_tgt/DEPRECATION /prop_tgt/DISABLE_PRECOMPILE_HEADERS /prop_tgt/DOTNET_TARGET_FRAMEWORK @@ -194,8 +194,8 @@ Properties on Targets /prop_tgt/EchoString /prop_tgt/ENABLE_EXPORTS /prop_tgt/EXCLUDE_FROM_ALL - /prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG /prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD + /prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG /prop_tgt/EXPORT_NAME /prop_tgt/EXPORT_PROPERTIES /prop_tgt/FOLDER @@ -211,30 +211,30 @@ Properties on Targets /prop_tgt/GNUtoMS /prop_tgt/HAS_CXX /prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM + /prop_tgt/IMPORTED /prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME /prop_tgt/IMPORTED_CONFIGURATIONS /prop_tgt/IMPORTED_GLOBAL - /prop_tgt/IMPORTED_IMPLIB_CONFIG /prop_tgt/IMPORTED_IMPLIB - /prop_tgt/IMPORTED_LIBNAME_CONFIG + /prop_tgt/IMPORTED_IMPLIB_CONFIG /prop_tgt/IMPORTED_LIBNAME - /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG + /prop_tgt/IMPORTED_LIBNAME_CONFIG /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES - /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG + /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES - /prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG + /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG /prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES - /prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG + /prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG /prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY - /prop_tgt/IMPORTED_LOCATION_CONFIG + /prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG /prop_tgt/IMPORTED_LOCATION - /prop_tgt/IMPORTED_NO_SONAME_CONFIG + /prop_tgt/IMPORTED_LOCATION_CONFIG /prop_tgt/IMPORTED_NO_SONAME - /prop_tgt/IMPORTED_OBJECTS_CONFIG + /prop_tgt/IMPORTED_NO_SONAME_CONFIG /prop_tgt/IMPORTED_OBJECTS - /prop_tgt/IMPORTED - /prop_tgt/IMPORTED_SONAME_CONFIG + /prop_tgt/IMPORTED_OBJECTS_CONFIG /prop_tgt/IMPORTED_SONAME + /prop_tgt/IMPORTED_SONAME_CONFIG /prop_tgt/IMPORT_PREFIX /prop_tgt/IMPORT_SUFFIX /prop_tgt/INCLUDE_DIRECTORIES @@ -251,12 +251,12 @@ Properties on Targets /prop_tgt/INTERFACE_LINK_DIRECTORIES /prop_tgt/INTERFACE_LINK_LIBRARIES /prop_tgt/INTERFACE_LINK_OPTIONS - /prop_tgt/INTERFACE_PRECOMPILE_HEADERS /prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE + /prop_tgt/INTERFACE_PRECOMPILE_HEADERS /prop_tgt/INTERFACE_SOURCES /prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES - /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/INTERPROCEDURAL_OPTIMIZATION + /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/IOS_INSTALL_COMBINED /prop_tgt/ISPC_HEADER_DIRECTORY /prop_tgt/ISPC_INSTRUCTION_SETS @@ -270,31 +270,31 @@ Properties on Targets /prop_tgt/LANG_CPPLINT /prop_tgt/LANG_INCLUDE_WHAT_YOU_USE /prop_tgt/LANG_VISIBILITY_PRESET - /prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG /prop_tgt/LIBRARY_OUTPUT_DIRECTORY - /prop_tgt/LIBRARY_OUTPUT_NAME_CONFIG + /prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG /prop_tgt/LIBRARY_OUTPUT_NAME - /prop_tgt/LINK_DEPENDS_NO_SHARED + /prop_tgt/LIBRARY_OUTPUT_NAME_CONFIG /prop_tgt/LINK_DEPENDS - /prop_tgt/LINKER_LANGUAGE + /prop_tgt/LINK_DEPENDS_NO_SHARED /prop_tgt/LINK_DIRECTORIES - /prop_tgt/LINK_FLAGS_CONFIG /prop_tgt/LINK_FLAGS - /prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG + /prop_tgt/LINK_FLAGS_CONFIG /prop_tgt/LINK_INTERFACE_LIBRARIES - /prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG + /prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG /prop_tgt/LINK_INTERFACE_MULTIPLICITY + /prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG /prop_tgt/LINK_LIBRARIES /prop_tgt/LINK_OPTIONS /prop_tgt/LINK_SEARCH_END_STATIC /prop_tgt/LINK_SEARCH_START_STATIC /prop_tgt/LINK_WHAT_YOU_USE - /prop_tgt/LOCATION_CONFIG + /prop_tgt/LINKER_LANGUAGE /prop_tgt/LOCATION + /prop_tgt/LOCATION_CONFIG /prop_tgt/MACHO_COMPATIBILITY_VERSION /prop_tgt/MACHO_CURRENT_VERSION - /prop_tgt/MACOSX_BUNDLE_INFO_PLIST /prop_tgt/MACOSX_BUNDLE + /prop_tgt/MACOSX_BUNDLE_INFO_PLIST /prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST /prop_tgt/MACOSX_RPATH /prop_tgt/MANUALLY_ADDED_DEPENDENCIES @@ -310,16 +310,16 @@ Properties on Targets /prop_tgt/OBJCXX_STANDARD /prop_tgt/OBJCXX_STANDARD_REQUIRED /prop_tgt/OPTIMIZE_DEPENDENCIES - /prop_tgt/OSX_ARCHITECTURES_CONFIG /prop_tgt/OSX_ARCHITECTURES - /prop_tgt/OUTPUT_NAME_CONFIG + /prop_tgt/OSX_ARCHITECTURES_CONFIG /prop_tgt/OUTPUT_NAME + /prop_tgt/OUTPUT_NAME_CONFIG /prop_tgt/PCH_WARN_INVALID /prop_tgt/PCH_INSTANTIATE_TEMPLATES - /prop_tgt/PDB_NAME_CONFIG /prop_tgt/PDB_NAME - /prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG + /prop_tgt/PDB_NAME_CONFIG /prop_tgt/PDB_OUTPUT_DIRECTORY + /prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/POSITION_INDEPENDENT_CODE /prop_tgt/PRECOMPILE_HEADERS /prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM @@ -331,16 +331,16 @@ Properties on Targets /prop_tgt/RULE_LAUNCH_COMPILE /prop_tgt/RULE_LAUNCH_CUSTOM /prop_tgt/RULE_LAUNCH_LINK - /prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG /prop_tgt/RUNTIME_OUTPUT_DIRECTORY - /prop_tgt/RUNTIME_OUTPUT_NAME_CONFIG + /prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG /prop_tgt/RUNTIME_OUTPUT_NAME + /prop_tgt/RUNTIME_OUTPUT_NAME_CONFIG /prop_tgt/SKIP_BUILD_RPATH /prop_tgt/SOURCE_DIR /prop_tgt/SOURCES /prop_tgt/SOVERSION - /prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG /prop_tgt/STATIC_LIBRARY_FLAGS + /prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG /prop_tgt/STATIC_LIBRARY_OPTIONS /prop_tgt/SUFFIX /prop_tgt/Swift_DEPENDENCIES_FILE @@ -361,12 +361,12 @@ Properties on Targets /prop_tgt/VS_DEBUGGER_ENVIRONMENT /prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY /prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION + /prop_tgt/VS_DOTNET_DOCUMENTATION_FILE /prop_tgt/VS_DOTNET_REFERENCE_refname /prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname /prop_tgt/VS_DOTNET_REFERENCES /prop_tgt/VS_DOTNET_REFERENCES_COPY_LOCAL /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION - /prop_tgt/VS_DOTNET_DOCUMENTATION_FILE /prop_tgt/VS_DPI_AWARE /prop_tgt/VS_GLOBAL_KEYWORD /prop_tgt/VS_GLOBAL_PROJECT_TYPES @@ -431,8 +431,8 @@ Properties on Tests .. toctree:: :maxdepth: 1 - /prop_test/ATTACHED_FILES_ON_FAIL /prop_test/ATTACHED_FILES + /prop_test/ATTACHED_FILES_ON_FAIL /prop_test/COST /prop_test/DEPENDS /prop_test/DISABLED diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 17d0882..ecf0fa4 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -27,10 +27,10 @@ Variables that Provide Information /variable/CMAKE_ARGV0 /variable/CMAKE_BINARY_DIR /variable/CMAKE_BUILD_TOOL - /variable/CMAKE_CACHEFILE_DIR /variable/CMAKE_CACHE_MAJOR_VERSION /variable/CMAKE_CACHE_MINOR_VERSION /variable/CMAKE_CACHE_PATCH_VERSION + /variable/CMAKE_CACHEFILE_DIR /variable/CMAKE_CFG_INTDIR /variable/CMAKE_COMMAND /variable/CMAKE_CPACK_COMMAND @@ -378,9 +378,9 @@ Variables that Control the Build /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_CROSS_CONFIGS /variable/CMAKE_CTEST_ARGUMENTS - /variable/CMAKE_CUDA_SEPARABLE_COMPILATION /variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS /variable/CMAKE_CUDA_RUNTIME_LIBRARY + /variable/CMAKE_CUDA_SEPARABLE_COMPILATION /variable/CMAKE_DEBUG_POSTFIX /variable/CMAKE_DEFAULT_BUILD_TYPE /variable/CMAKE_DEFAULT_CONFIGS @@ -497,8 +497,8 @@ Variables for Languages /variable/CMAKE_COMPILER_IS_GNUG77 /variable/CMAKE_CUDA_ARCHITECTURES /variable/CMAKE_CUDA_COMPILE_FEATURES - /variable/CMAKE_CUDA_HOST_COMPILER /variable/CMAKE_CUDA_EXTENSIONS + /variable/CMAKE_CUDA_HOST_COMPILER /variable/CMAKE_CUDA_STANDARD /variable/CMAKE_CUDA_STANDARD_REQUIRED /variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES @@ -550,11 +550,11 @@ Variables for Languages /variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES /variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES /variable/CMAKE_LANG_LIBRARY_ARCHITECTURE + /variable/CMAKE_LANG_LINK_EXECUTABLE /variable/CMAKE_LANG_LINKER_PREFERENCE /variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES /variable/CMAKE_LANG_LINKER_WRAPPER_FLAG /variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP - /variable/CMAKE_LANG_LINK_EXECUTABLE /variable/CMAKE_LANG_OUTPUT_EXTENSION /variable/CMAKE_LANG_SIMULATE_ID /variable/CMAKE_LANG_SIMULATE_VERSION -- cgit v0.12 From ff4d1d44f217bcbd90ba97f0fc41806cccb34e57 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 11 Dec 2020 18:25:42 +1100 Subject: Help: Clarify scope details of deferred call ids for cmake_language() Fixes: #21586 --- Help/command/cmake_language.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Help/command/cmake_language.rst b/Help/command/cmake_language.rst index 40a45e3..99f874b 100644 --- a/Help/command/cmake_language.rst +++ b/Help/command/cmake_language.rst @@ -150,7 +150,12 @@ The currently scheduled list of deferred calls may be retrieved: cmake_language(DEFER [DIRECTORY ] GET_CALL_IDS ) This will store in ```` a :ref:`semicolon-separated list ` of deferred call ids. +Lists>` of deferred call ids. The ids are for the directory scope in which +the calls have been deferred to (i.e. where they will be executed), which can +be different to the scope in which they were created. The ``DIRECTORY`` +option can be used to specify the scope for which to retrieve the call ids. +If that option is not given, the call ids for the current directory scope will +be returned. Details of a specific call may be retrieved from its id: @@ -163,8 +168,9 @@ Lists>` in which the first element is the name of the command to be called, and the remaining elements are its unevaluated arguments (any contained ``;`` characters are included literally and cannot be distinguished from multiple arguments). If multiple calls are scheduled with the same id, -this retrieves the first one. If no call is scheduled with the given id, -this stores an empty string in the variable. +this retrieves the first one. If no call is scheduled with the given id in +the specified ``DIRECTORY`` scope (or the current directory scope if no +``DIRECTORY`` option is given), this stores an empty string in the variable. Deferred calls may be canceled by their id: @@ -172,8 +178,9 @@ Deferred calls may be canceled by their id: cmake_language(DEFER [DIRECTORY ] CANCEL_CALL ...) -This cancels all deferred calls matching any of the given ids. -Unknown ids are silently ignored. +This cancels all deferred calls matching any of the given ids in the specified +``DIRECTORY`` scope (or the current directory scope if no ``DIRECTORY`` option +is given). Unknown ids are silently ignored. Deferred Call Examples """""""""""""""""""""" -- cgit v0.12 From d29d034e2e1a867bf769529b5f5f20090402f469 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 11 Dec 2020 10:49:01 -0500 Subject: FindGLUT: Handle Mojave and Big Sur 'tbd' framework files --- Modules/FindGLUT.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index a22bf5b..15561d6 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -64,8 +64,12 @@ else () add_library(GLUT::Cocoa UNKNOWN IMPORTED) # Cocoa should always be a Framework, but we check to make sure. if(GLUT_cocoa_LIBRARY MATCHES "/([^/]+)\\.framework$") + set(_glut_cocoa "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") + if(EXISTS "${_glut_cocoa}.tbd") + string(APPEND _glut_cocoa ".tbd") + endif() set_target_properties(GLUT::Cocoa PROPERTIES - IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") + IMPORTED_LOCATION "${_glut_cocoa}") else() set_target_properties(GLUT::Cocoa PROPERTIES IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}") @@ -146,8 +150,12 @@ if (GLUT_FOUND) set_target_properties(GLUT::GLUT PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLUT_INCLUDE_DIR}") if(GLUT_glut_LIBRARY MATCHES "/([^/]+)\\.framework$") + set(_glut_glut "${GLUT_glut_LIBRARY}/${CMAKE_MATCH_1}") + if(EXISTS "${_glut_glut}.tbd") + string(APPEND _glut_glut ".tbd") + endif() set_target_properties(GLUT::GLUT PROPERTIES - IMPORTED_LOCATION "${GLUT_glut_LIBRARY}/${CMAKE_MATCH_1}") + IMPORTED_LOCATION "${_glut_glut}") else() if(GLUT_glut_LIBRARY_RELEASE) set_property(TARGET GLUT::GLUT APPEND PROPERTY -- cgit v0.12 From 63db7ae9c40a806494dc81b9ae2940fe91a6aad7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Dec 2020 12:27:42 -0500 Subject: cmake: Clear INSTALL file properties between runs Do not keep state across separate project configurations. This is particularly important in `cmake-gui` where those configurations can be for separate projects. Fixes: #21580 --- Source/cmake.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 60a493c..e655634 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -286,6 +286,8 @@ void cmake::CleanupCommandsAndMacros() this->CurrentSnapshot = this->State->Reset(); this->State->RemoveUserDefinedCommands(); this->CurrentSnapshot.SetDefaultDefinitions(); + // FIXME: InstalledFiles probably belongs in the global generator. + this->InstalledFiles.clear(); } #ifndef CMAKE_BOOTSTRAP -- cgit v0.12 From 1a5c1a68b6a3ffdee2a2ae106af6724eb2d4786a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Dec 2020 10:53:00 -0500 Subject: macOS: Add /opt/homebrew to CMAKE_SYSTEM_PREFIX_PATH on Apple Silicon According to https://brew.sh/2020/12/01/homebrew-2.6.0/ the `/opt/homebrew` directory is recommended for installing ARM architecture brew packages. Fixes: #21585 --- Modules/Platform/Darwin.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index c6de3b0..80595ea 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -216,6 +216,13 @@ set(CMAKE_SYSTEM_APPBUNDLE_PATH unset(_apps_paths) include(Platform/UnixPaths) + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + list(PREPEND CMAKE_SYSTEM_PREFIX_PATH + /opt/homebrew # Brew on Apple Silicon + ) +endif() + if(_CMAKE_OSX_SYSROOT_PATH) if(EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) list(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 ${_CMAKE_OSX_SYSROOT_PATH}/usr) -- cgit v0.12 From 7f447609916d4faed8fc5b055ac337a89a47979a Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 14 Dec 2020 14:33:50 +0100 Subject: CMakePackageConfigHelpers: Relax restrictions on version range --- .../BasicConfigVersion-SameMajorVersion.cmake.in | 33 ++++-- .../BasicConfigVersion-SameMinorVersion.cmake.in | 40 ++++--- Modules/CMakePackageConfigHelpers.cmake | 9 +- .../RunCMake/WriteBasicConfigVersionFile/All.cmake | 125 ++++++++++++++++++--- 4 files changed, 160 insertions(+), 47 deletions(-) diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index 662900d..dc04e54 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -9,13 +9,6 @@ # The variable CVF_VERSION must be set before calling configure_file(). -if (PACKAGE_FIND_VERSION_RANGE) - message(AUTHOR_WARNING - "`find_package()` specify a version range but the version strategy " - "(SameMajorVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " - "with this request. Only the lower endpoint of the range will be used.") -endif() - set(PACKAGE_VERSION "@CVF_VERSION@") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) @@ -28,14 +21,30 @@ else() set(CVF_VERSION_MAJOR "@CVF_VERSION@") endif() - if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) - set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major version + math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") + if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) + endif() endif() endif() diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in index bddf4ce..9bb2efc 100644 --- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in @@ -10,13 +10,6 @@ # The variable CVF_VERSION must be set before calling configure_file(). -if (PACKAGE_FIND_VERSION_RANGE) - message(AUTHOR_WARNING - "`find_package()` specify a version range but the version strategy " - "(SameMinorVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " - "with this request. Only the lower endpoint of the range will be used.") -endif() - set(PACKAGE_VERSION "@CVF_VERSION@") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) @@ -31,15 +24,36 @@ else() set(CVF_VERSION_MINOR "") endif() - if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND - (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR)) - set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major and minor versions + math (EXPR CVF_VERSION_MINOR_NEXT "${CVF_VERSION_MINOR} + 1") + if (NOT (PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND PACKAGE_FIND_VERSION_MIN_MINOR STREQUAL CVF_VERSION_MINOR) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" + AND NOT (PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR + AND PACKAGE_FIND_VERSION_MAX_MINOR STREQUAL CVF_VERSION_MINOR)) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" + AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL ${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR_NEXT}))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND PACKAGE_FIND_VERSION_MIN_MINOR STREQUAL CVF_VERSION_MINOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() + if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND + (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR)) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) + endif() endif() endif() diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 1a7f9cf..36f2f7f 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -159,10 +159,11 @@ If your project has more elaborated version matching rules, you will need to write your own custom ``ConfigVersion.cmake`` file instead of using this macro. -.. note:: ``COMPATIBILITY_MODE`` ``AnyNewerVersion`` handles the version range - if any is specified (see :command:`find_package` command for the details). - All other modes are incompatible with version ranges and will display an - author warning if one is specified. +.. note:: ``COMPATIBILITY_MODE`` ``AnyNewerVersion``, ``SameMajorVersion`` and + ``SameMinorVersion`` handle the version range if any is specified (see + :command:`find_package` command for the details). ``ExactVersion`` is + incompatible with version ranges and will display an author warning if one is + specified. If ``ARCH_INDEPENDENT`` is given, the installed package version will be considered compatible even if it was built for a different architecture than diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake index 4253652..c32c92d 100644 --- a/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake +++ b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake @@ -3,16 +3,16 @@ set(CMAKE_SIZEOF_VOID_P 4) include(WriteBasicConfigVersionFile) -set(_compatibilities AnyNewerVersion - SameMajorVersion - SameMinorVersion - ExactVersion) +set(COMPATIBILITIES AnyNewerVersion + SameMajorVersion + SameMinorVersion + ExactVersion) function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE_PREPARE _version_installed) set(_same_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) set(_no_CMAKE_SIZEOF_VOID_P "") math(EXPR _diff_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P} + 1") - foreach(_compat ${_compatibilities}) + foreach(_compat ${COMPATIBILITIES}) set(_pkg ${_compat}${_version_installed}) string(REPLACE "." "" _pkg ${_pkg}) set(_filename "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}ConfigVersion.cmake") @@ -71,20 +71,58 @@ function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE _version_installed _expected_compatible_SameMajorVersion _expected_compatible_SameMinorVersion _expected_compatible_ExactVersion) - set(PACKAGE_FIND_VERSION ${_version_requested}) - if("${PACKAGE_FIND_VERSION}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) - set(PACKAGE_FIND_VERSION_MAJOR "${CMAKE_MATCH_2}") - set(PACKAGE_FIND_VERSION_MINOR "${CMAKE_MATCH_4}") - set(PACKAGE_FIND_VERSION_PATCH "${CMAKE_MATCH_6}") - set(PACKAGE_FIND_VERSION_TWEAK "${CMAKE_MATCH_8}") - else() - message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version number") - endif() - - if ("${_version_installed}" STREQUAL "${_version_requested}") - set(_expected_exact 1) - else() + if("${_version_requested}" MATCHES [[^([0-9]+(\.[0-9]+)*)\.\.\.(<)?([0-9]+(\.[0-9]+)*)$]]) + set (_compatibilities ${COMPATIBILITIES}) + # ExactVersion must not be tested + list(POP_BACK _compatibilities) + set(PACKAGE_FIND_VERSION_RANGE TRUE) + set(PACKAGE_FIND_VERSION_RANGE_MIN INCLUDE) + if ("${CMAKE_MATCH_3}" STREQUAL "<") + set(PACKAGE_FIND_VERSION_RANGE_MAX EXCLUDE) + else() + set(PACKAGE_FIND_VERSION_RANGE_MAX INCLUDE) + endif() + set(PACKAGE_FIND_VERSION_MIN "${CMAKE_MATCH_1}") + set(PACKAGE_FIND_VERSION_MAX "${CMAKE_MATCH_4}") + if("${PACKAGE_FIND_VERSION_MIN}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MIN_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MIN_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_MIN_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_MIN_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version range") + endif() + set(PACKAGE_FIND_VERSION "${PACKAGE_FIND_VERSION_MIN}") + set(PACKAGE_FIND_VERSION_MAJOR "${PACKAGE_FIND_VERSION_MIN_MAJOR}") + set(PACKAGE_FIND_VERSION_MINOR "${PACKAGE_FIND_VERSION_MIN_MINOR}") + set(PACKAGE_FIND_VERSION_PATCH "${PACKAGE_FIND_VERSION_MIN_PATCH}") + set(PACKAGE_FIND_VERSION_TWEAK "${PACKAGE_FIND_VERSION_MIN_TWEAK}") + if("${PACKAGE_FIND_VERSION_MAX}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MAX_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MAX_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_MAX_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_MAX_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version range") + endif() set(_expected_exact 0) + else() + set (_compatibilities ${COMPATIBILITIES}) + set(PACKAGE_FIND_VERSION ${_version_requested}) + if("${PACKAGE_FIND_VERSION}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version number") + endif() + + if ("${_version_installed}" STREQUAL "${_version_requested}") + set(_expected_exact 1) + else() + set(_expected_exact 0) + endif() endif() unset(PACKAGE_VERSION_COMPATIBLE) @@ -882,3 +920,54 @@ test_write_basic_config_version_file(4.5.6.7 9.9.9.0 0 0 0 0) # Request [ne test_write_basic_config_version_file(4.5.6.7 9.9.9.2 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[older tweak] test_write_basic_config_version_file(4.5.6.7 9.9.9.7 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[same tweak] test_write_basic_config_version_file(4.5.6.7 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak] + +test_write_basic_config_version_file(4 0...5 1 0 0 0) +test_write_basic_config_version_file(4 2...5 1 0 0 0) +test_write_basic_config_version_file(4 2...4 1 0 0 0) +test_write_basic_config_version_file(4 4...<5 1 1 0 0) +test_write_basic_config_version_file(4 9...10 0 0 0 0) + +test_write_basic_config_version_file(4 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4 2.1...4 1 0 0 0) +test_write_basic_config_version_file(4 2.8...4 1 0 0 0) +test_write_basic_config_version_file(4 4.0...<5 1 1 0 0) +test_write_basic_config_version_file(4 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4 4.1...5 0 0 0 0) +test_write_basic_config_version_file(4 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4 9.8...10 0 0 0 0) + + +test_write_basic_config_version_file(4.5 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.1...4 0 0 0 0) +test_write_basic_config_version_file(4.5 2.8...4 0 0 0 0) +test_write_basic_config_version_file(4.5 2.8...4.8 1 0 0 0) +test_write_basic_config_version_file(4.5 4.1...<5 1 1 0 0) +test_write_basic_config_version_file(4.5 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4.5 4.5...4.5.8 1 1 1 0) +test_write_basic_config_version_file(4.5 4.5...<4.6 1 1 1 0) +test_write_basic_config_version_file(4.5 4.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4.5 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4.5 9.8...10 0 0 0 0) + + +test_write_basic_config_version_file(4.5.6 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.1...4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...4.8 1 0 0 0) +test_write_basic_config_version_file(4.5.6 4.1...<5 1 1 0 0) +test_write_basic_config_version_file(4.5.6 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4.5.6 4.5...4.5.4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 4.5...4.5.8 1 1 1 0) +test_write_basic_config_version_file(4.5.6 4.5...<4.6 1 1 1 0) +test_write_basic_config_version_file(4.5.6 4.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4.5.6 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4.5.6 9.8...10 0 0 0 0) -- cgit v0.12 From 73a961eaba84c622480eff84671c7e3f6a7f61c4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Dec 2020 10:06:26 -0500 Subject: Ninja: Remove cleandead on regeneration Remove the `cleandead` tool invocation added by commit fb18215904 (Ninja: clean ninja metadata once generated, 2019-05-13, v3.17.0-rc1~207^2). The tool deletes files that were not previously deleted by regenerating the build system. Also, there are use cases where no-longer-generated files should not be removed, such as Qt's TS files. Fixes: #21549 --- Source/cmGlobalNinjaGenerator.cxx | 14 +------------- Source/cmGlobalNinjaGenerator.h | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b6c343c..a911139 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -573,18 +573,9 @@ void cmGlobalNinjaGenerator::CleanMetaData() // Skip some ninja tools if they need 'build.ninja' but it is missing. bool const missingBuildManifest = expectBuildManifest && - (this->NinjaSupportsCleanDeadTool || - this->NinjaSupportsUnconditionalRecompactTool) && + this->NinjaSupportsUnconditionalRecompactTool && !cmSystemTools::FileExists("build.ninja"); - // The `cleandead` tool needs to know about all outputs in the build we just - // wrote out. Ninja-Multi doesn't have a single `build.ninja` we can use that - // is the union of all generated configurations, so we can't run it reliably - // in that case. - if (this->NinjaSupportsCleanDeadTool && expectBuildManifest && - !missingBuildManifest) { - run_ninja_tool({ "cleandead" }); - } // The `recompact` tool loads the manifest. As above, we don't have a single // `build.ninja` to load for this in Ninja-Multi. This may be relaxed in the // future pending further investigation into how Ninja works upstream @@ -671,9 +662,6 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() } } } - this->NinjaSupportsCleanDeadTool = !cmSystemTools::VersionCompare( - cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), - RequiredNinjaVersionForCleanDeadTool().c_str()); this->NinjaSupportsUnconditionalRecompactTool = !cmSystemTools::VersionCompare( cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 44e632f..8373de3 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -370,7 +370,6 @@ public: { return "1.10"; } - static std::string RequiredNinjaVersionForCleanDeadTool() { return "1.10"; } bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; @@ -533,7 +532,6 @@ private: bool NinjaSupportsDyndeps = false; bool NinjaSupportsRestatTool = false; bool NinjaSupportsUnconditionalRecompactTool = false; - bool NinjaSupportsCleanDeadTool = false; private: void InitOutputPathPrefix(); -- cgit v0.12 From 18ee6d7e32b1ab7f9081f331912541bd913be243 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 11 Dec 2020 21:20:57 +0100 Subject: llvm-rc: Add CMAKE_VFS_OVERLAY to the preprocessing flags Issue: #20658 --- Source/cmLocalGenerator.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 368f278..49f23f8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1940,9 +1940,11 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, this->AddConfigVariableFlags(flags, cmStrCat("CMAKE_", lang, "_FLAGS"), config); - std::string const& compiler = this->Makefile->GetSafeDefinition( + std::string compiler = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_COMPILER_ID")); + std::string compilerSimulateId = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); if (lang == "Swift") { if (cmProp v = target->GetProperty("Swift_LANGUAGE_VERSION")) { if (cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, @@ -1957,14 +1959,24 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, target->AddCUDAToolkitFlags(flags); } else if (lang == "ISPC") { target->AddISPCTargetFlags(flags); + } else if (lang == "RC" && + this->Makefile->GetSafeDefinition("CMAKE_RC_COMPILER") + .find("llvm-rc") != std::string::npos) { + compiler = this->Makefile->GetSafeDefinition("CMAKE_C_COMPILER_ID"); + if (!compiler.empty()) { + compilerSimulateId = + this->Makefile->GetSafeDefinition("CMAKE_C_SIMULATE_ID"); + } else { + compiler = this->Makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"); + compilerSimulateId = + this->Makefile->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"); + } } + // Add VFS Overlay for Clang compiliers if (compiler == "Clang") { if (cmProp vfsOverlay = this->Makefile->GetDefinition("CMAKE_CLANG_VFS_OVERLAY")) { - std::string const& compilerSimulateId = - this->Makefile->GetSafeDefinition( - cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); if (compilerSimulateId == "MSVC") { this->AppendCompileOptions( flags, -- cgit v0.12 From 23de43054562bf5a478988ca68fcbc3e03565379 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Dec 2020 09:46:24 -0500 Subject: Utilities/Release: Update macOS Qt 5.9 build for platform versioning Backport the upstream Qt patch [1] to link Qt binaries using the `-isysroot` flag instead of `-Wl,-syslibroot`. This is needed so that the binaries have a SDK version set, which is needed for runtime validation on modern macOS versions. [1] https://code.qt.io/cgit/qt/qtbase.git/commit/?id=6387138a7991b4588639dc48847f175b5afaff84 --- .gitlab/ci/download_qt_hashes.cmake | 2 +- .../macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash | 1 + Utilities/Release/macos/qt-5.9.9.patch | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Utilities/Release/macos/qt-5.9.9.patch diff --git a/.gitlab/ci/download_qt_hashes.cmake b/.gitlab/ci/download_qt_hashes.cmake index 0d286b5..832fa98 100644 --- a/.gitlab/ci/download_qt_hashes.cmake +++ b/.gitlab/ci/download_qt_hashes.cmake @@ -10,4 +10,4 @@ set("5.15.1-0-202009071110qtwinextras-Windows-Windows_10-MSVC2015-Windows-Window set("5.15.1-0-202009071110qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" df2813ce7c6cb4287abd7956cd1cb9d08312e4ac1208b6cb57af4df11b8ebba1) -set("qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz_hash" aa6229bc6bd01a44d18b07023417698fdf4de7a02b14e971b473d80956a57a1c) +set("qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz_hash" d4449771afa0bc6a809c14f1e6d939e7732494cf059503ae451e2bfe8fc60cc1) diff --git a/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash b/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash index b0973f4..a61e114 100755 --- a/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash +++ b/Utilities/Release/macos/qt-5.9.9-macosx10.10-x86_64-arm64.bash @@ -20,6 +20,7 @@ type -p makeuniversal >/dev/null curl -OL https://download.qt.io/archive/qt/5.9/5.9.9/single/qt-everywhere-opensource-src-5.9.9.tar.xz shasum -a 256 qt-everywhere-opensource-src-5.9.9.tar.xz | grep -q 5ce285209290a157d7f42ec8eb22bf3f1d76f2e03a95fc0b99b553391be01642 tar xjf qt-everywhere-opensource-src-5.9.9.tar.xz +patch -p0 < "${BASH_SOURCE%/*}/qt-5.9.9.patch" # Build the x86_64 variant. mkdir qt-5.9.9-x86_64 diff --git a/Utilities/Release/macos/qt-5.9.9.patch b/Utilities/Release/macos/qt-5.9.9.patch new file mode 100644 index 0000000..dfcbbdd --- /dev/null +++ b/Utilities/Release/macos/qt-5.9.9.patch @@ -0,0 +1,20 @@ +--- qt-everywhere-opensource-src-5.9.9/qtbase/mkspecs/features/mac/default_post.prf.orig 2019-12-03 07:50:08.000000000 -0500 ++++ qt-everywhere-opensource-src-5.9.9/qtbase/mkspecs/features/mac/default_post.prf 2020-12-14 09:45:11.000000000 -0500 +@@ -130,7 +130,7 @@ + -isysroot$$xcodeSDKInfo(Path, $$sdk) + QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \ + -Xarch_$${arch} \ +- -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk) ++ -isysroot$$xcodeSDKInfo(Path, $$sdk) + + QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch}) + QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch}) +@@ -151,7 +151,7 @@ + version_min_flag = -m$${version_identifier}-version-min=$$deployment_target + QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag + QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag +- QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag ++ QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag + } + + # Enable precompiled headers for multiple architectures -- cgit v0.12 From c9a50f35565dcc1df8bd82126ecced95e60c29e4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 10 Dec 2020 16:08:24 -0500 Subject: ISPC: Generated Headers suffix configurable with a better default The target property `ISPC_HEADER_SUFFIX` and associated global variable now can control the suffix used when generating the C/C++ interoperability ISPC headers. In addition the default suffix is now "_ispc.h" which matches the common convention that the ISPC compiler team uses and recommends. --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/ISPC_HEADER_SUFFIX.rst | 14 ++++++++++++++ Help/release/3.19.rst | 4 ++++ Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst | 10 ++++++++++ Source/cmCoreTryCompile.cxx | 2 ++ Source/cmLocalGenerator.cxx | 16 ++++++++++++---- Source/cmMakefileTargetGenerator.cxx | 7 ++++++- Source/cmNinjaTargetGenerator.cxx | 7 ++++++- Source/cmTarget.cxx | 1 + Tests/ISPC/CMakeLists.txt | 1 + Tests/ISPC/ChainedStaticLibraries/extra.cxx | 2 +- Tests/ISPC/ChainedStaticLibraries/main.cxx | 2 +- Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt | 23 +++++++++++++++++++++++ Tests/ISPC/CustomHeaderSuffix/extra.cxx | 17 +++++++++++++++++ Tests/ISPC/CustomHeaderSuffix/extra.ispc | 12 ++++++++++++ Tests/ISPC/CustomHeaderSuffix/main.cxx | 15 +++++++++++++++ Tests/ISPC/CustomHeaderSuffix/simple.ispc | 12 ++++++++++++ Tests/ISPC/Defines/main.cxx | 2 +- Tests/ISPC/DynamicLibrary/extra.cxx | 2 +- Tests/ISPC/DynamicLibrary/simple.cxx | 2 +- Tests/ISPC/ObjectLibrary/extra.cxx | 2 +- Tests/ISPC/ObjectLibrary/main.cxx | 2 +- Tests/ISPC/ResponseAndDefine/main.cxx | 2 +- Tests/ISPC/StaticLibrary/main.cxx | 2 +- Tests/ISPC/SystemIncludes/CMakeLists.txt | 2 ++ 26 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 Help/prop_tgt/ISPC_HEADER_SUFFIX.rst create mode 100644 Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst create mode 100644 Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt create mode 100644 Tests/ISPC/CustomHeaderSuffix/extra.cxx create mode 100644 Tests/ISPC/CustomHeaderSuffix/extra.ispc create mode 100644 Tests/ISPC/CustomHeaderSuffix/main.cxx create mode 100644 Tests/ISPC/CustomHeaderSuffix/simple.ispc diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index bd6e5c6..5c8a05a 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -259,6 +259,7 @@ Properties on Targets /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/IOS_INSTALL_COMBINED /prop_tgt/ISPC_HEADER_DIRECTORY + /prop_tgt/ISPC_HEADER_SUFFIX /prop_tgt/ISPC_INSTRUCTION_SETS /prop_tgt/JOB_POOL_COMPILE /prop_tgt/JOB_POOL_LINK diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 3f0fb03..56239ac 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -515,6 +515,7 @@ Variables for Languages /variable/CMAKE_Fortran_MODDIR_FLAG /variable/CMAKE_Fortran_MODOUT_FLAG /variable/CMAKE_ISPC_HEADER_DIRECTORY + /variable/CMAKE_ISPC_HEADER_SUFFIX /variable/CMAKE_ISPC_INSTRUCTION_SETS /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX diff --git a/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst b/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst new file mode 100644 index 0000000..6397e55 --- /dev/null +++ b/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst @@ -0,0 +1,14 @@ +ISPC_HEADER_SUFFIX +------------------ + +.. versionadded:: 3.19.2 + +Specify output suffix to be used for ISPC generated headers provided by the target. + +This property is initialized by the value of the :variable:`CMAKE_ISPC_HEADER_SUFFIX` +variable if it is set when a target is created. + +If the target contains ISPC source files, this specifies the header suffix to +be used for the generated headers. + +The default value is ``_ispc.h``. diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index 4f26058..60a8ecc 100644 --- a/Help/release/3.19.rst +++ b/Help/release/3.19.rst @@ -381,3 +381,7 @@ Changes made since CMake 3.19.0 include the following. the invoking process tree, the :variable:`CMAKE_APPLE_SILICON_PROCESSOR` variable or :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment variable may be set to specify a host architecture explicitly. + +* The :variable:`CMAKE_ISPC_HEADER_SUFFIX` variable and corresponding + :prop_tgt:`ISPC_HEADER_SUFFIX` target property were added to control + the header suffix used by ``ISPC`` compiler generated headers. diff --git a/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst b/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst new file mode 100644 index 0000000..c9fb709 --- /dev/null +++ b/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst @@ -0,0 +1,10 @@ +CMAKE_ISPC_HEADER_SUFFIX +------------------------ + +.. versionadded:: 3.19.2 + +Output suffix to be used for ISPC generated headers. + +This variable is used to initialize the :prop_tgt:`ISPC_HEADER_SUFFIX` +property on all the targets. See the target property for additional +information. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 77a6d4b..6672aa6 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -201,6 +201,7 @@ std::string const kCMAKE_CUDA_ARCHITECTURES = "CMAKE_CUDA_ARCHITECTURES"; std::string const kCMAKE_CUDA_RUNTIME_LIBRARY = "CMAKE_CUDA_RUNTIME_LIBRARY"; std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS"; std::string const kCMAKE_ISPC_INSTRUCTION_SETS = "CMAKE_ISPC_INSTRUCTION_SETS"; +std::string const kCMAKE_ISPC_HEADER_SUFFIX = "CMAKE_ISPC_HEADER_SUFFIX"; std::string const kCMAKE_LINK_SEARCH_END_STATIC = "CMAKE_LINK_SEARCH_END_STATIC"; std::string const kCMAKE_LINK_SEARCH_START_STATIC = @@ -718,6 +719,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, vars.insert(kCMAKE_CUDA_RUNTIME_LIBRARY); vars.insert(kCMAKE_ENABLE_EXPORTS); vars.insert(kCMAKE_ISPC_INSTRUCTION_SETS); + vars.insert(kCMAKE_ISPC_HEADER_SUFFIX); vars.insert(kCMAKE_LINK_SEARCH_END_STATIC); vars.insert(kCMAKE_LINK_SEARCH_START_STATIC); vars.insert(kCMAKE_OSX_ARCHITECTURES); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 368f278..884d15d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2426,9 +2426,12 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) return; } - std::vector ispcSuffixes = + cmProp ispcHeaderSuffixProp = target->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcHeaderSuffixProp != nullptr); + + std::vector ispcArchSuffixes = detail::ComputeISPCObjectSuffixes(target); - const bool extra_objects = (ispcSuffixes.size() > 1); + const bool extra_objects = (ispcArchSuffixes.size() > 1); std::vector configsList = this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); @@ -2451,14 +2454,19 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) const std::string& lang = sf->GetLanguage(); if (lang == "ISPC") { std::string const& objectName = target->GetObjectName(sf); + + // Drop both ".obj" and the source file extension std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = + cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); - auto headerPath = cmStrCat(headerDir, '/', ispcSource, ".h"); + auto headerPath = + cmStrCat(headerDir, '/', ispcSource, *ispcHeaderSuffixProp); target->AddISPCGeneratedHeader(headerPath, config); if (extra_objects) { std::vector objs = detail::ComputeISPCExtraObjects( - objectName, rootObjectDir, ispcSuffixes); + objectName, rootObjectDir, ispcArchSuffixes); target->AddISPCGeneratedObject(std::move(objs), config); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3776fec..c6d6c99 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -591,6 +591,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( if (lang == "ISPC") { std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); + + cmProp ispcSuffixProp = + this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcSuffixProp != nullptr); std::string directory = this->GeneratorTarget->GetObjectDirectory(config); if (cmProp prop = @@ -598,7 +603,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( directory = cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop); } - ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, ".h"); + ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, *ispcSuffixProp); ispcHeaderForShell = this->LocalGenerator->ConvertToOutputFormat( ispcHeaderRelative, cmOutputConverter::SHELL); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 662399e..d41cbd2 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1374,6 +1374,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->GeneratorTarget->GetObjectName(source); std::string ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(objectName); + ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); + + cmProp ispcSuffixProp = + this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX"); + assert(ispcSuffixProp != nullptr); std::string ispcHeaderDirectory = this->GeneratorTarget->GetObjectDirectory(config); @@ -1384,7 +1389,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } std::string ispcHeader = - cmStrCat(ispcHeaderDirectory, '/', ispcSource, ".h"); + cmStrCat(ispcHeaderDirectory, '/', ispcSource, *ispcSuffixProp); ispcHeader = this->ConvertToNinjaPath(ispcHeader); // Make sure ninja knows what command generates the header diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d26de9c..bda2b30 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -369,6 +369,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("JOB_POOL_PRECOMPILE_HEADER"); initProp("ISPC_COMPILER_LAUNCHER"); initProp("ISPC_HEADER_DIRECTORY"); + initPropValue("ISPC_HEADER_SUFFIX", "_ispc.h"); initProp("ISPC_INSTRUCTION_SETS"); initProp("LINK_SEARCH_START_STATIC"); initProp("LINK_SEARCH_END_STATIC"); diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt index 2c3651d..c993275 100644 --- a/Tests/ISPC/CMakeLists.txt +++ b/Tests/ISPC/CMakeLists.txt @@ -7,6 +7,7 @@ macro (add_ispc_test_macro name) endmacro () add_ispc_test_macro(ISPC.ChainedStaticLibraries ISPCChainedStaticLibraries) +add_ispc_test_macro(ISPC.CustomHeaderSuffix ISPCCustomHeaderSuffix) add_ispc_test_macro(ISPC.Defines ISPCDefines) add_ispc_test_macro(ISPC.DynamicLibrary ISPCDynamicLibrary) add_ispc_test_macro(ISPC.ObjectGenex ISPCObjectGenex) diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.cxx b/Tests/ISPC/ChainedStaticLibraries/extra.cxx index 88ef3a7..9f50df4 100644 --- a/Tests/ISPC/ChainedStaticLibraries/extra.cxx +++ b/Tests/ISPC/ChainedStaticLibraries/extra.cxx @@ -1,6 +1,6 @@ #include -#include "extra.ispc.h" +#include "extra_ispc.h" int extra() { diff --git a/Tests/ISPC/ChainedStaticLibraries/main.cxx b/Tests/ISPC/ChainedStaticLibraries/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ChainedStaticLibraries/main.cxx +++ b/Tests/ISPC/ChainedStaticLibraries/main.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt new file mode 100644 index 0000000..d20f88e --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCCustomHeaderSuffix CXX ISPC) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") + +set(CMAKE_ISPC_HEADER_SUFFIX ".ispc.h") + +add_library(ispc_suffix_1 OBJECT simple.ispc) +add_library(ispc_suffix_2 OBJECT extra.ispc) + +set_target_properties(ispc_suffix_2 PROPERTIES ISPC_HEADER_SUFFIX "___ispc.h") + +set_target_properties(ispc_suffix_1 ispc_suffix_2 + PROPERTIES POSITION_INDEPENDENT_CODE ON +) + +add_executable(ISPCCustomHeaderSuffix main.cxx extra.cxx) +target_link_libraries(ISPCCustomHeaderSuffix PRIVATE ispc_suffix_1 ispc_suffix_2) diff --git a/Tests/ISPC/CustomHeaderSuffix/extra.cxx b/Tests/ISPC/CustomHeaderSuffix/extra.cxx new file mode 100644 index 0000000..0354e2d --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/extra.cxx @@ -0,0 +1,17 @@ +#include + +#include "extra___ispc.h" + +int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/CustomHeaderSuffix/extra.ispc b/Tests/ISPC/CustomHeaderSuffix/extra.ispc new file mode 100644 index 0000000..5a4a442 --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/CustomHeaderSuffix/main.cxx b/Tests/ISPC/CustomHeaderSuffix/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/main.cxx @@ -0,0 +1,15 @@ +#include + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/CustomHeaderSuffix/simple.ispc b/Tests/ISPC/CustomHeaderSuffix/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/Defines/main.cxx +++ b/Tests/ISPC/Defines/main.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx index b3623d1..a3d89ed 100644 --- a/Tests/ISPC/DynamicLibrary/extra.cxx +++ b/Tests/ISPC/DynamicLibrary/extra.cxx @@ -1,6 +1,6 @@ #include -#include "extra.ispc.h" +#include "extra_ispc.h" #ifdef _WIN32 # define EXPORT __declspec(dllexport) diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx index cb5a779..bc78bda 100644 --- a/Tests/ISPC/DynamicLibrary/simple.cxx +++ b/Tests/ISPC/DynamicLibrary/simple.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" #ifdef _WIN32 # define EXPORT __declspec(dllexport) diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx index 88ef3a7..9f50df4 100644 --- a/Tests/ISPC/ObjectLibrary/extra.cxx +++ b/Tests/ISPC/ObjectLibrary/extra.cxx @@ -1,6 +1,6 @@ #include -#include "extra.ispc.h" +#include "extra_ispc.h" int extra() { diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ObjectLibrary/main.cxx +++ b/Tests/ISPC/ObjectLibrary/main.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ResponseAndDefine/main.cxx +++ b/Tests/ISPC/ResponseAndDefine/main.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/StaticLibrary/main.cxx +++ b/Tests/ISPC/StaticLibrary/main.cxx @@ -1,6 +1,6 @@ #include -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/SystemIncludes/CMakeLists.txt b/Tests/ISPC/SystemIncludes/CMakeLists.txt index 95959b2..d94e75e 100644 --- a/Tests/ISPC/SystemIncludes/CMakeLists.txt +++ b/Tests/ISPC/SystemIncludes/CMakeLists.txt @@ -4,8 +4,10 @@ project(ispc_spaces_in_path ISPC CXX) add_executable(ISPCSystemIncludes main.cxx simple.ispc) set_target_properties(ISPCSystemIncludes PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(ISPCSystemIncludes PROPERTIES ISPC_HEADER_SUFFIX ".ispc.h") target_include_directories(ISPCSystemIncludes SYSTEM PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--target=sse2-i32x4>") if(CMAKE_SIZEOF_VOID_P EQUAL 4) target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--arch=x86>") -- cgit v0.12 From 854f5ea1cbc7f3b015150e91f6b6371004128faa Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Dec 2020 08:29:50 -0500 Subject: cmake-gui: Restore completion during path editing Revert commit 0fc1818831 (QCMakeWidgets: replace QDirModel, 2020-06-15, v3.19.0-rc1~696^2). `QFileSystemModel` is not a drop-in replacement for `QDirModel`. Additional changes are needed to make it work fully. Revert the change and suppress the `QDirModel` deprecation warning pending further investigation. Fixes: #21589 --- Source/QtDialog/QCMakeWidgets.cxx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 1fc839f..e68faba 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -1,12 +1,17 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ + +// FIXME: Port to QFileSystemModel from the deprecated QDirModel. +// Be sure completion works when incrementally editing existing paths. +#define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION_CHECK(5, 14, 0) + #include "QCMakeWidgets.h" #include +#include #include #include -#include #include #include @@ -88,20 +93,20 @@ void QCMakePathEditor::chooseFile() } } -// use same QFileSystemModel for all completers -static QFileSystemModel* fileDirModel() +// use same QDirModel for all completers +static QDirModel* fileDirModel() { - static QFileSystemModel* m = nullptr; + static QDirModel* m = nullptr; if (!m) { - m = new QFileSystemModel(); + m = new QDirModel(); } return m; } -static QFileSystemModel* pathDirModel() +static QDirModel* pathDirModel() { - static QFileSystemModel* m = nullptr; + static QDirModel* m = nullptr; if (!m) { - m = new QFileSystemModel(); + m = new QDirModel(); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); } return m; @@ -110,7 +115,7 @@ static QFileSystemModel* pathDirModel() QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) : QCompleter(o) { - QFileSystemModel* m = dirs ? pathDirModel() : fileDirModel(); + QDirModel* m = dirs ? pathDirModel() : fileDirModel(); this->setModel(m); } -- cgit v0.12 From 0932b1c2b29f4ad1228fa71bf4f5c089474d9882 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Dec 2020 07:35:29 -0500 Subject: CMake 3.19.2 --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e57e02e..799b2fc 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 19) -set(CMake_VERSION_PATCH 1) +set(CMake_VERSION_PATCH 2) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12