diff options
40 files changed, 751 insertions, 594 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5795af8..a8b31da 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,17 @@ -.only_settings: &only_settings - - merge_requests - - branches@cmake/cmake - - tags@cmake/cmake +.manual_rules_settings: &manual_rules_settings + - if: '$CI_PROJECT_PATH == "cmake/cmake"' + when: delayed + start_in: 5 minutes + - if: '$CI_MERGE_REQUEST_ID' + when: manual + - when: never + +.rules_settings: &rules_settings + - if: '$CI_PROJECT_PATH == "cmake/cmake"' + when: always + - if: '$CI_MERGE_REQUEST_ID' + when: always + - when: never .fedora31: &fedora31 image: "kitware/cmake:ci-fedora31-x86_64-2020-05-08" @@ -104,9 +114,17 @@ variables: CMAKE_CONFIGURATION: windows_vs2019_x64_ninja - VCVARSALL: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Auxiliary\\Build\\vcvarsall.bat" + VCVARSALL: "${VS160COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" VCVARSPLATFORM: x64 +.windows_vs2019_x64: &windows_vs2019_x64 + extends: .windows + + variables: + CMAKE_CONFIGURATION: windows_vs2019_x64 + CMAKE_GENERATOR: "Visual Studio 16 2019" + CMAKE_GENERATOR_PLATFORM: "x64" + .linux_builder_tags: &linux_builder_tags tags: - build @@ -149,7 +167,6 @@ .cmake_build_unix: &cmake_build_unix stage: build - only: *only_settings script: - *before_script_unix @@ -165,11 +182,10 @@ .cmake_build_windows: &cmake_build_windows stage: build - only: *only_settings script: - *before_script_windows - - Invoke-Expression -Command .gitlab/ci/sccache.ps1 + - Set-Item -Force -Path "env:PATH" -Value "$env:PATH;$env:SCCACHE_PATH" - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - sccache --start-server - sccache --show-stats @@ -253,7 +269,6 @@ .cmake_test_unix: &cmake_test_unix stage: test - only: *only_settings script: - *before_script_unix @@ -263,7 +278,6 @@ .cmake_test_windows: &cmake_test_windows stage: test - only: *only_settings script: - *before_script_windows @@ -272,27 +286,39 @@ interruptible: true +.cmake_test_windows_external: &cmake_test_windows_external + stage: test-ext + + script: + - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake + + interruptible: true + stages: - build - test + - test-ext build:debian10-iwyu: <<: - *debian10_iwyu - *cmake_build_unix - *linux_builder_tags + rules: *rules_settings build:fedora31-tidy: <<: - *fedora31_tidy - *cmake_build_unix - *linux_builder_tags + rules: *rules_settings build:fedora31-sphinx: <<: - *fedora31_sphinx - *cmake_build_unix - *linux_builder_tags_qt + rules: *rules_settings build:fedora31-ninja: <<: @@ -300,13 +326,14 @@ build:fedora31-ninja: - *cmake_build_unix - *cmake_build_artifacts - *linux_builder_tags - when: manual + rules: *manual_rules_settings test:fedora31-ninja: <<: - *fedora31_ninja - *cmake_test_unix - *linux_builder_tags_qt + rules: *rules_settings dependencies: - build:fedora31-ninja needs: @@ -318,13 +345,14 @@ build:fedora31-makefiles: - *cmake_build_unix - *cmake_build_artifacts - *linux_builder_tags - when: manual + rules: *manual_rules_settings test:fedora31-makefiles: <<: - *fedora31_makefiles - *cmake_test_unix - *linux_builder_tags_qt + rules: *rules_settings dependencies: - build:fedora31-makefiles needs: @@ -336,13 +364,14 @@ build:macos-ninja: - *cmake_build_unix - *cmake_build_artifacts - *macos_builder_tags - when: manual + rules: *manual_rules_settings test:macos-ninja: <<: - *macos_ninja - *cmake_test_unix - *macos_builder_tags + rules: *rules_settings dependencies: - build:macos-ninja needs: @@ -354,13 +383,14 @@ build:macos-makefiles: - *cmake_build_unix - *cmake_build_artifacts - *macos_builder_tags - when: manual + rules: *manual_rules_settings test:macos-makefiles: <<: - *macos_makefiles - *cmake_test_unix - *macos_builder_tags + rules: *rules_settings dependencies: - build:macos-makefiles needs: @@ -372,14 +402,27 @@ build:windows-vs2019-x64-ninja: - *cmake_build_windows - *cmake_build_artifacts - *windows_builder_tags - when: manual + rules: *manual_rules_settings test:windows-vs2019-x64-ninja: <<: - *windows_vs2019_x64_ninja - *cmake_test_windows - *windows_builder_tags + - *cmake_test_artifacts + rules: *rules_settings dependencies: - build:windows-vs2019-x64-ninja needs: - build:windows-vs2019-x64-ninja + +test:windows-vs2019-x64: + <<: + - *windows_vs2019_x64 + - *cmake_test_windows_external + - *windows_builder_tags + rules: *rules_settings + dependencies: + - test:windows-vs2019-x64-ninja + needs: + - test:windows-vs2019-x64-ninja diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake index 4585224..df49b2d 100644 --- a/.gitlab/ci/configure_common.cmake +++ b/.gitlab/ci/configure_common.cmake @@ -1,7 +1,7 @@ -set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "") +set(CTEST_USE_LAUNCHERS "ON" CACHE BOOL "") # We run the install right after the build. Avoid rerunning it when installing. -set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY "ON" CACHE STRING "") +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY "ON" CACHE BOOL "") # Install CMake under the build tree. set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "") set(CMake_TEST_INSTALL "OFF" CACHE BOOL "") diff --git a/.gitlab/ci/configure_external_test.cmake b/.gitlab/ci/configure_external_test.cmake new file mode 100644 index 0000000..71397d1 --- /dev/null +++ b/.gitlab/ci/configure_external_test.cmake @@ -0,0 +1,3 @@ +set(CMake_TEST_HOST_CMAKE "ON" CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_windows_vs2019_x64.cmake b/.gitlab/ci/configure_windows_vs2019_x64.cmake new file mode 100644 index 0000000..f6ece57 --- /dev/null +++ b/.gitlab/ci/configure_windows_vs2019_x64.cmake @@ -0,0 +1,3 @@ +set(CMake_TEST_WIX_NO_VERIFY "ON" CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index d8980f6..eb9b724 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -1,6 +1,15 @@ set(test_exclusions ) +if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio") + list(APPEND test_exclusions + # This test takes around 5 minutes with Visual Studio. + # https://gitlab.kitware.com/cmake/cmake/-/issues/20733 + "^ExternalProjectUpdate$" + # This test is a dependency of the above and is only required for it. + "^ExternalProjectUpdateSetup$") +endif () + string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) set(test_exclusions "(${test_exclusions})") diff --git a/.gitlab/ci/ctest_test_external.cmake b/.gitlab/ci/ctest_test_external.cmake new file mode 100644 index 0000000..1e61d52 --- /dev/null +++ b/.gitlab/ci/ctest_test_external.cmake @@ -0,0 +1,66 @@ +cmake_minimum_required(VERSION 3.8) + +include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake") + +set(cmake_args + -C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake") + +# Create an entry in CDash. +ctest_start(Experimental TRACK "${ctest_track}") + +# Gather update information. +find_package(Git) +set(CTEST_UPDATE_VERSION_ONLY ON) +set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}") +ctest_update() + +# Configure the project. +ctest_configure( + OPTIONS "${cmake_args}" + RETURN_VALUE configure_result) + +# Read the files from the build directory. +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# We can now submit because we've configured. This is a cmb-superbuild-ism. +ctest_submit(PARTS Update) +ctest_submit(PARTS Configure) + +if (configure_result) + message(FATAL_ERROR + "Failed to configure") +endif () + +include(ProcessorCount) +ProcessorCount(nproc) + +if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles") + set(CTEST_BUILD_FLAGS "-j${nproc}") +endif () + +ctest_build( + NUMBER_WARNINGS num_warnings + RETURN_VALUE build_result) +ctest_submit(PARTS Build) + +if (build_result) + message(FATAL_ERROR + "Failed to build") +endif () + +if ("$ENV{CTEST_NO_WARNINGS_ALLOWED}" AND num_warnings GREATER 0) + message(FATAL_ERROR + "Found ${num_warnings} warnings (treating as fatal).") +endif () + +include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake") +ctest_test( + PARALLEL_LEVEL "${nproc}" + RETURN_VALUE test_result + EXCLUDE "${test_exclusions}") +ctest_submit(PARTS Test) + +if (test_result) + message(FATAL_ERROR + "Failed to test") +endif () diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake index b49f51d..e9c9f80 100644 --- a/.gitlab/ci/gitlab_ci.cmake +++ b/.gitlab/ci/gitlab_ci.cmake @@ -27,6 +27,7 @@ endif () if (NOT CTEST_BUILD_CONFIGURATION) set(CTEST_BUILD_CONFIGURATION "Release") endif () +set(CTEST_CONFIGURATION_TYPE "${CTEST_BUILD_CONFIGURATION}") # Default to using Ninja. if (NOT "$ENV{CMAKE_GENERATOR}" STREQUAL "") @@ -36,6 +37,14 @@ if (NOT CTEST_CMAKE_GENERATOR) set(CTEST_CMAKE_GENERATOR "Ninja") endif () +# Set the toolset and platform if requested. +if (NOT "$ENV{CMAKE_GENERATOR_PLATFORM}" STREQUAL "") + set(CTEST_CMAKE_GENERATOR_PLATFORM "$ENV{CMAKE_GENERATOR_PLATFORM}") +endif () +if (NOT "$ENV{CMAKE_GENERATOR_TOOLSET}" STREQUAL "") + set(CTEST_CMAKE_GENERATOR_TOOLSET "$ENV{CMAKE_GENERATOR_TOOLSET}") +endif () + # Determine the track to submit to. set(ctest_track "Experimental") if (NOT "$ENV{CI_MERGE_REQUEST_ID}" STREQUAL "") diff --git a/Help/command/add_compile_definitions.rst b/Help/command/add_compile_definitions.rst index 8225da7..e10aba0 100644 --- a/Help/command/add_compile_definitions.rst +++ b/Help/command/add_compile_definitions.rst @@ -7,10 +7,12 @@ Add preprocessor definitions to the compilation of source files. add_compile_definitions(<definition> ...) -Adds preprocessor definitions to the compiler command line for targets in the -current directory and below (whether added before or after this command is -invoked). See documentation of the :prop_dir:`directory <COMPILE_DEFINITIONS>` -and :prop_tgt:`target <COMPILE_DEFINITIONS>` ``COMPILE_DEFINITIONS`` properties. +Adds preprocessor definitions to the compiler command line. + +The preprocessor definitions are added to the :prop_dir:`COMPILE_DEFINITIONS` +directory property for the current ``CMakeLists`` file. They are also added to +the :prop_tgt:`COMPILE_DEFINITIONS` target property for each target in the +current ``CMakeLists`` file. Definitions are specified using the syntax ``VAR`` or ``VAR=value``. Function-style definitions are not supported. CMake will automatically diff --git a/Help/command/add_definitions.rst b/Help/command/add_definitions.rst index d06b01c..fe69188 100644 --- a/Help/command/add_definitions.rst +++ b/Help/command/add_definitions.rst @@ -8,9 +8,9 @@ Add -D define flags to the compilation of source files. add_definitions(-DFOO -DBAR ...) Adds definitions to the compiler command line for targets in the current -directory and below (whether added before or after this command is invoked). -This command can be used to add any flags, but it is intended to add -preprocessor definitions. +directory, whether added before or after this command is invoked, and for +the ones in sub-directories added after. This command can be used to add any +flags, but it is intended to add preprocessor definitions. .. note:: diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index e1b3c52..50d5cd1 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -65,10 +65,13 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # Move result from cache to normal variable. set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED}) unset(CMAKE_${lang}_ABI_COMPILED CACHE) + if(CMAKE_${lang}_ABI_COMPILED AND _copy_error) + set(CMAKE_${lang}_ABI_COMPILED 0) + endif() set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED} PARENT_SCOPE) # Load the resulting information strings. - if(CMAKE_${lang}_ABI_COMPILED AND NOT _copy_error) + if(CMAKE_${lang}_ABI_COMPILED) message(CHECK_PASS "done") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index eadea89..3734ec4 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -21,6 +21,15 @@ endif() # We now store this in CMakeCCompiler.cmake. unset(CMAKE_C_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeCCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) +if(CMAKE_C_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_C_COMPILER_WORKS TRUE) + message(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected C compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -47,49 +56,41 @@ if(NOT CMAKE_C_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) unset(CMAKE_C_COMPILER_WORKS CACHE) - set(C_TEST_WAS_RUN 1) __TestCompiler_restoreTryCompileTargetType() -endif() - -if(NOT CMAKE_C_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the C compiler works failed with " - "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${__CMAKE_C_COMPILER_OUTPUT}") - message(FATAL_ERROR "The C compiler\n \"${CMAKE_C_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(C_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C compiler works passed with " + if(NOT CMAKE_C_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the C compiler works failed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_C_COMPILER_OUTPUT}") + message(FATAL_ERROR "The C compiler\n \"${CMAKE_C_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the C compiler works passed with " + "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeCCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) - # Try to identify the compiler features - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) - CMAKE_DETERMINE_COMPILE_FEATURES(C) +# Try to identify the compiler features +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) +CMAKE_DETERMINE_COMPILE_FEATURES(C) - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake) +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake) - if(CMAKE_C_SIZEOF_DATA_PTR) - foreach(f ${CMAKE_C_ABI_FILES}) - include(${f}) - endforeach() - unset(CMAKE_C_ABI_FILES) - endif() +if(CMAKE_C_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_C_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_C_ABI_FILES) endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index 6d39d3e..a18947b 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -14,6 +14,15 @@ include(CMakeTestCompilerCommon) # We now store this in CMakeCUDACompiler.cmake. unset(CMAKE_CUDA_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeCUDACompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu) +if(CMAKE_CUDA_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_CUDA_COMPILER_WORKS TRUE) + message(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected cuda compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -34,65 +43,56 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS}) unset(CMAKE_CUDA_COMPILER_WORKS CACHE) - set(CUDA_TEST_WAS_RUN 1) -endif() - -if(NOT CMAKE_CUDA_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the CUDA compiler works failed with " - "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}") - message(FATAL_ERROR "The CUDA compiler\n \"${CMAKE_CUDA_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(CUDA_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the CUDA compiler works passed with " + if(NOT CMAKE_CUDA_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the CUDA compiler works failed with " "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}") + message(FATAL_ERROR "The CUDA compiler\n \"${CMAKE_CUDA_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the CUDA compiler works passed with " + "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeCUDACompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu) - # Try to identify the compiler features - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) - CMAKE_DETERMINE_COMPILE_FEATURES(CUDA) +# Try to identify the compiler features +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) +CMAKE_DETERMINE_COMPILE_FEATURES(CUDA) - if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") - set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}") - set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}") - endif() +if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}") + set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}") +endif() - # Filter out implicit link libraries that should not be passed unconditionally. - # See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler. - list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) +# Filter out implicit link libraries that should not be passed unconditionally. +# See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler. +list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") - # Remove the CUDA Toolkit include directories from the set of - # implicit system include directories. - # This resolves the issue that NVCC doesn't specify these - # includes as SYSTEM includes when compiling device code, and sometimes - # they contain headers that generate warnings, so let users mark them - # as SYSTEM explicitly - if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) - list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES - ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} - ) - endif() +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + # Remove the CUDA Toolkit include directories from the set of + # implicit system include directories. + # This resolves the issue that NVCC doesn't specify these + # includes as SYSTEM includes when compiling device code, and sometimes + # they contain headers that generate warnings, so let users mark them + # as SYSTEM explicitly + if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) + list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES + ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} + ) endif() - - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake) endif() +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake) unset(__CMAKE_CUDA_COMPILER_OUTPUT) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index bd42153..b9cb1dd 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -21,6 +21,15 @@ endif() # We now store this in CMakeCXXCompiler.cmake. unset(CMAKE_CXX_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeCXXCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) +if(CMAKE_CXX_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_CXX_COMPILER_WORKS TRUE) + message(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected C++ compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -40,49 +49,41 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) unset(CMAKE_CXX_COMPILER_WORKS CACHE) - set(CXX_TEST_WAS_RUN 1) __TestCompiler_restoreTryCompileTargetType() -endif() - -if(NOT CMAKE_CXX_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the CXX compiler works failed with " - "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}") - message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(CXX_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the CXX compiler works passed with " + if(NOT CMAKE_CXX_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the CXX compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}") + message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the CXX compiler works passed with " + "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) - # Try to identify the compiler features - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) - CMAKE_DETERMINE_COMPILE_FEATURES(CXX) +# Try to identify the compiler features +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) +CMAKE_DETERMINE_COMPILE_FEATURES(CXX) - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake) +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake) - if(CMAKE_CXX_SIZEOF_DATA_PTR) - foreach(f ${CMAKE_CXX_ABI_FILES}) - include(${f}) - endforeach() - unset(CMAKE_CXX_ABI_FILES) - endif() +if(CMAKE_CXX_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_CXX_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_CXX_ABI_FILES) endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 7461f9c..10fb0a7 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -15,6 +15,15 @@ include(CMakeTestCompilerCommon) # We now store this in CMakeFortranCompiler.cmake. unset(CMAKE_Fortran_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeFortranCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) +if(CMAKE_Fortran_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_Fortran_COMPILER_WORKS TRUE) + message(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected Fortran compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -33,70 +42,61 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) unset(CMAKE_Fortran_COMPILER_WORKS CACHE) - set(FORTRAN_TEST_WAS_RUN 1) -endif() - -if(NOT CMAKE_Fortran_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Fortran compiler works failed with " - "the following output:\n${OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${OUTPUT}") - message(FATAL_ERROR "The Fortran compiler\n \"${CMAKE_Fortran_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(FORTRAN_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Fortran compiler works passed with " + if(NOT CMAKE_Fortran_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran compiler works failed with " "the following output:\n${OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${OUTPUT}") + message(FATAL_ERROR "The Fortran compiler\n \"${CMAKE_Fortran_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran compiler works passed with " + "the following output:\n${OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeFortranCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) - - # Test for Fortran 90 support by using an f90-specific construct. - if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " - PROGRAM TESTFortran90 - integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do - END PROGRAM TESTFortran90 +# Test for Fortran 90 support by using an f90-specific construct. +if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " + PROGRAM TESTFortran90 + integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do + END PROGRAM TESTFortran90 ") - try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 - OUTPUT_VARIABLE OUTPUT) - if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(CHECK_PASS "yes") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Fortran compiler supports Fortran 90 passed with " - "the following output:\n${OUTPUT}\n\n") - set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) - else() - message(CHECK_FAIL "no") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Fortran compiler supports Fortran 90 failed with " - "the following output:\n${OUTPUT}\n\n") - set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) - endif() - unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) + try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + OUTPUT_VARIABLE OUTPUT) + if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + message(CHECK_PASS "yes") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran compiler supports Fortran 90 passed with " + "the following output:\n${OUTPUT}\n\n") + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) + else() + message(CHECK_FAIL "no") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran compiler supports Fortran 90 failed with " + "the following output:\n${OUTPUT}\n\n") + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) endif() + unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) +endif() - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake) +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake) - if(CMAKE_Fortran_SIZEOF_DATA_PTR) - foreach(f ${CMAKE_Fortran_ABI_FILES}) - include(${f}) - endforeach() - unset(CMAKE_Fortran_ABI_FILES) - endif() +if(CMAKE_Fortran_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_Fortran_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_Fortran_ABI_FILES) endif() diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index bcc6fae..0e333c0 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -21,6 +21,15 @@ endif() # We now store this in CMakeCCompiler.cmake. unset(CMAKE_OBJC_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m) +if(CMAKE_OBJC_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_OBJC_COMPILER_WORKS TRUE) + message(STATUS "Check for working OBJC compiler: ${CMAKE_OBJC_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected Objective-C compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -44,49 +53,41 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) unset(CMAKE_OBJC_COMPILER_WORKS CACHE) - set(OBJC_TEST_WAS_RUN 1) __TestCompiler_restoreTryCompileTargetType() -endif() - -if(NOT CMAKE_OBJC_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Objective-C compiler works failed with " - "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}") - message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(OBJC_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Objective-C compiler works passed with " + if(NOT CMAKE_OBJC_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Objective-C compiler works failed with " "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}") + message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Objective-C compiler works passed with " + "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m) - # Try to identify the compiler features - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) - CMAKE_DETERMINE_COMPILE_FEATURES(OBJC) +# Try to identify the compiler features +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) +CMAKE_DETERMINE_COMPILE_FEATURES(OBJC) - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake) +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake) - if(CMAKE_OBJC_SIZEOF_DATA_PTR) - foreach(f ${CMAKE_OBJC_ABI_FILES}) - include(${f}) - endforeach() - unset(CMAKE_OBJC_ABI_FILES) - endif() +if(CMAKE_OBJC_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJC_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJC_ABI_FILES) endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index 83227d5..dc153a7 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -21,6 +21,15 @@ endif() # We now store this in CMakeOBJCXXCompiler.cmake. unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) +# Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm) +if(CMAKE_OBJCXX_ABI_COMPILED) + # The compiler worked so skip dedicated test below. + set(CMAKE_OBJCXX_COMPILER_WORKS TRUE) + message(STATUS "Check for working OBJCXX compiler: ${CMAKE_OBJCXX_COMPILER} - skipped") +endif() + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected Objective-C++ compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -43,49 +52,41 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) # Move result from cache to normal variable. set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) - set(OBJCXX_TEST_WAS_RUN 1) __TestCompiler_restoreTryCompileTargetType() -endif() - -if(NOT CMAKE_OBJCXX_COMPILER_WORKS) - PrintTestCompilerResult(CHECK_FAIL "broken") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Objective-C++ compiler works failed with " - "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") - string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}") - message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n" - "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${_output}\n\n" - "CMake will not be able to correctly generate this project.") -else() - if(OBJCXX_TEST_WAS_RUN) - PrintTestCompilerResult(CHECK_PASS "works") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Objective-C++ compiler works passed with " + if(NOT CMAKE_OBJCXX_COMPILER_WORKS) + PrintTestCompilerResult(CHECK_FAIL "broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Objective-C++ compiler works failed with " "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}") + message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") endif() + PrintTestCompilerResult(CHECK_PASS "works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Objective-C++ compiler works passed with " + "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") +endif() - # Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm) - # Try to identify the compiler features - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) - CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX) +# Try to identify the compiler features +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) +CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX) - # Re-configure to save learned information. - configure_file( - ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake - @ONLY - ) - include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake) +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake) - if(CMAKE_OBJCXX_SIZEOF_DATA_PTR) - foreach(f ${CMAKE_OBJCXX_ABI_FILES}) - include(${f}) - endforeach() - unset(CMAKE_OBJCXX_ABI_FILES) - endif() +if(CMAKE_OBJCXX_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJCXX_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJCXX_ABI_FILES) endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 9b1963f..e366b80 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1787,7 +1787,11 @@ function(_ep_get_build_command name step cmd_var) get_target_property(args ${name} _EP_${step}_ARGS) endif() - list(APPEND cmd ${args}) + if(NOT "${args}" STREQUAL "") + # args could have empty items, so we must quote it to prevent them + # from being silently removed + list(APPEND cmd "${args}") + endif() set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction() @@ -2103,17 +2107,23 @@ function(ExternalProject_Add_Step name step) set(command ${CMAKE_COMMAND} -E echo_append) endif() - add_custom_command( - OUTPUT ${stamp_file} - BYPRODUCTS ${byproducts} - COMMENT ${comment} - COMMAND ${command} - COMMAND ${touch} - DEPENDS ${depends} - WORKING_DIRECTORY ${work_dir} - VERBATIM - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS command) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + add_custom_command( + OUTPUT \${stamp_file} + BYPRODUCTS \${byproducts} + COMMENT \${comment} + COMMAND ${__cmdQuoted} + COMMAND \${touch} + DEPENDS \${depends} + WORKING_DIRECTORY \${work_dir} + VERBATIM + ${uses_terminal} + )" + ) set_property(TARGET ${name} APPEND PROPERTY _EP_STEPS ${step}) # Add custom "step target"? @@ -2568,15 +2578,21 @@ function(_ep_add_download_command name) set(uses_terminal "") endif() - ExternalProject_Add_Step(${name} download - COMMENT ${comment} - COMMAND ${cmd} - WORKING_DIRECTORY ${work_dir} - DEPENDS ${depends} - DEPENDEES mkdir - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(\${name} download + COMMENT \${comment} + COMMAND ${__cmdQuoted} + WORKING_DIRECTORY \${work_dir} + DEPENDS \${depends} + DEPENDEES mkdir + ${log} + ${uses_terminal} + )" + ) endfunction() function(_ep_get_update_disconnected var name) @@ -2725,16 +2741,22 @@ Update to Mercurial >= 2.1.1. set(uses_terminal "") endif() - ExternalProject_Add_Step(${name} update - COMMENT ${comment} - COMMAND ${cmd} - ALWAYS ${always} - EXCLUDE_FROM_MAIN ${update_disconnected} - WORKING_DIRECTORY ${work_dir} - DEPENDEES download - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} update + COMMENT \${comment} + COMMAND ${__cmdQuoted} + ALWAYS \${always} + EXCLUDE_FROM_MAIN \${update_disconnected} + WORKING_DIRECTORY \${work_dir} + DEPENDEES download + ${log} + ${uses_terminal} + )" + ) if(update_disconnected) _ep_get_step_stampfile(${name} skip-update skip-update_stamp_file) @@ -2780,12 +2802,18 @@ function(_ep_add_patch_command name) set(update_dep update) endif() - ExternalProject_Add_Step(${name} patch - COMMAND ${cmd} - WORKING_DIRECTORY ${work_dir} - DEPENDEES download ${update_dep} - ${log} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} patch + COMMAND ${__cmdQuoted} + WORKING_DIRECTORY \${work_dir} + DEPENDEES download \${update_dep} + ${log} + )" + ) endfunction() @@ -2945,14 +2973,20 @@ function(_ep_add_configure_command name) set(update_dep update) endif() - ExternalProject_Add_Step(${name} configure - COMMAND ${cmd} - WORKING_DIRECTORY ${binary_dir} - DEPENDEES ${update_dep} patch - DEPENDS ${file_deps} - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} configure + COMMAND ${__cmdQuoted} + WORKING_DIRECTORY \${binary_dir} + DEPENDEES \${update_dep} patch + DEPENDS \${file_deps} + ${log} + ${uses_terminal} + )" + ) endfunction() @@ -2990,15 +3024,21 @@ function(_ep_add_build_command name) get_property(build_byproducts TARGET ${name} PROPERTY _EP_BUILD_BYPRODUCTS) - ExternalProject_Add_Step(${name} build - COMMAND ${cmd} - BYPRODUCTS ${build_byproducts} - WORKING_DIRECTORY ${binary_dir} - DEPENDEES configure - ALWAYS ${always} - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} build + COMMAND ${__cmdQuoted} + BYPRODUCTS \${build_byproducts} + WORKING_DIRECTORY \${binary_dir} + DEPENDEES configure + ALWAYS \${always} + ${log} + ${uses_terminal} + )" + ) endfunction() @@ -3027,13 +3067,19 @@ function(_ep_add_install_command name) set(uses_terminal "") endif() - ExternalProject_Add_Step(${name} install - COMMAND ${cmd} - WORKING_DIRECTORY ${binary_dir} - DEPENDEES build - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} install + COMMAND ${__cmdQuoted} + WORKING_DIRECTORY \${binary_dir} + DEPENDEES build + ${log} + ${uses_terminal} + )" + ) endfunction() @@ -3088,15 +3134,21 @@ function(_ep_add_test_command name) set(uses_terminal "") endif() - ExternalProject_Add_Step(${name} test - COMMAND ${cmd} - WORKING_DIRECTORY ${binary_dir} - ${dependees_args} - ${dependers_args} - ${exclude_args} - ${log} - ${uses_terminal} - ) + set(__cmdQuoted) + foreach(__item IN LISTS cmd) + string(APPEND __cmdQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + ExternalProject_Add_Step(${name} test + COMMAND ${__cmdQuoted} + WORKING_DIRECTORY \${binary_dir} + ${dependees_args} + ${dependers_args} + ${exclude_args} + ${log} + ${uses_terminal} + )" + ) endif() endfunction() diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 45b50d4..69f2513 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -656,7 +656,12 @@ function(__FetchContent_declareDetails contentName) BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()" FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}" ) - set_property(GLOBAL PROPERTY ${propertyName} ${ARGN}) + set(__cmdArgs) + foreach(__item IN LISTS ARGN) + string(APPEND __cmdArgs " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE + "set_property(GLOBAL PROPERTY ${propertyName} ${__cmdArgs})") endif() endfunction() @@ -689,7 +694,8 @@ function(FetchContent_Declare contentName) set(oneValueArgs SVN_REPOSITORY) set(multiValueArgs "") - cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(PARSE_ARGV 1 ARG + "${options}" "${oneValueArgs}" "${multiValueArgs}") unset(srcDirSuffix) unset(svnRepoArgs) @@ -707,13 +713,20 @@ function(FetchContent_Declare contentName) endif() string(TOLOWER ${contentName} contentNameLower) - __FetchContent_declareDetails( - ${contentNameLower} - SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src${srcDirSuffix}" - BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build" - ${svnRepoArgs} - # List these last so they can override things we set above - ${ARG_UNPARSED_ARGUMENTS} + + set(__argsQuoted) + foreach(__item IN LISTS ARG_UNPARSED_ARGUMENTS) + string(APPEND __argsQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + __FetchContent_declareDetails( + ${contentNameLower} + SOURCE_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src${srcDirSuffix}\" + BINARY_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build\" + \${svnRepoArgs} + # List these last so they can override things we set above + ${__argsQuoted} + )" ) endfunction() @@ -844,7 +857,8 @@ function(__FetchContent_directPopulate contentName) ) set(multiValueArgs "") - cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(PARSE_ARGV 1 ARG + "${options}" "${oneValueArgs}" "${multiValueArgs}") if(NOT ARG_SUBBUILD_DIR) message(FATAL_ERROR "Internal error: SUBBUILD_DIR not set") @@ -1056,17 +1070,23 @@ function(FetchContent_Populate contentName) message(FATAL_ERROR "No details have been set for content: ${contentName}") endif() - __FetchContent_directPopulate( - ${contentNameLower} - ${quietFlag} - UPDATE_DISCONNECTED ${disconnectUpdates} - SUBBUILD_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-subbuild" - SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src" - BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build" - # Put the saved details last so they can override any of the - # the options we set above (this can include SOURCE_DIR or - # BUILD_DIR) - ${contentDetails} + set(__detailsQuoted) + foreach(__item IN LISTS contentDetails) + string(APPEND __detailsQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + __FetchContent_directPopulate( + ${contentNameLower} + ${quietFlag} + UPDATE_DISCONNECTED ${disconnectUpdates} + SUBBUILD_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-subbuild\" + SOURCE_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src\" + BINARY_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build\" + # Put the saved details last so they can override any of the + # the options we set above (this can include SOURCE_DIR or + # BUILD_DIR) + ${__detailsQuoted} + )" ) endif() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index e9b6bd2..786bcc8 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1154,7 +1154,7 @@ macro(_MPI_create_imported_target LANG) endif() # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'. - string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread" + string(REPLACE "-pthread" "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler >-pthread" _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") unset(_MPI_${LANG}_COMPILE_OPTIONS) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index f97e5c8..ee49867 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -238,8 +238,8 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads) if(THREADS_HAVE_PTHREAD_ARG) set_property(TARGET Threads::Threads - PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>" - "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>") + PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler -pthread>" + "$<$<NOT:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>>:-pthread>") endif() if(CMAKE_THREAD_LIBS_INIT) diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index 47bfd62..db78b61 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -81,10 +81,14 @@ endif() if(NOT XercesC_LIBRARY) # Find all XercesC libraries find_library(XercesC_LIBRARY_RELEASE - NAMES "xerces-c" "xerces-c_${XercesC_VERSION_MAJOR}" + NAMES "xerces-c" + "xerces-c_${XercesC_VERSION_MAJOR}" + "xerces-c-${XercesC_VERSION_MAJOR}.${XercesC_VERSION_MINOR}" DOC "Xerces-C++ libraries (release)") find_library(XercesC_LIBRARY_DEBUG - NAMES "xerces-cd" "xerces-c_${XercesC_VERSION_MAJOR}D" "xerces-c_${XercesC_VERSION_MAJOR}_${XercesC_VERSION_MINOR}D" + NAMES "xerces-cd" + "xerces-c_${XercesC_VERSION_MAJOR}D" + "xerces-c_${XercesC_VERSION_MAJOR}_${XercesC_VERSION_MINOR}D" DOC "Xerces-C++ libraries (debug)") include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(XercesC) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index feb55e8..60846d4 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 17) -set(CMake_VERSION_PATCH 20200525) +set(CMake_VERSION_PATCH 20200527) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ba7d47e..2c8e385 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -344,6 +344,11 @@ bool cmCTestRunTest::NeedsToRepeat() if (this->NumberOfRunsLeft == 0) { return false; } + // If a test is marked as NOT_RUN it will not be repeated + // no matter the repeat settings, so just record it as-is. + if (this->TestResult.Status == cmCTestTestHandler::NOT_RUN) { + return false; + } // if number of runs left is not 0, and we are running until // we find a failed (or passed) test, then return true so the test can be // restarted diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 983f7e4..868eb24 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -416,7 +416,7 @@ endif() if(TARGET ctresalloc) add_RunCMake_test(CTestResourceAllocation -DCTRESALLOC_COMMAND=$<TARGET_FILE:ctresalloc>) else() - message(WARNING "Could not find or build ctresalloc") + message(STATUS "Could not find ctresalloc") endif() find_package(Qt4 QUIET) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt index 4cb051d..928d88a 100644 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt @@ -2,7 +2,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "configure" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) @@ -12,7 +12,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "build" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) @@ -22,7 +22,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "install" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt new file mode 100644 index 0000000..0e21b8f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt @@ -0,0 +1,21 @@ +.*-- Number of arguments for download: 6 +.*-- download argument 4: '' +.*-- download argument 5: 'after' +.*-- Number of arguments for update: 6 +.*-- update argument 4: '' +.*-- update argument 5: 'after' +.*-- Number of arguments for patch: 6 +.*-- patch argument 4: '' +.*-- patch argument 5: 'after' +.*-- Number of arguments for configure: 6 +.*-- configure argument 4: '' +.*-- configure argument 5: 'after' +.*-- Number of arguments for build: 6 +.*-- build argument 4: '' +.*-- build argument 5: 'after' +.*-- Number of arguments for install: 6 +.*-- install argument 4: '' +.*-- install argument 5: 'after' +.*-- Number of arguments for test: 6 +.*-- test argument 4: '' +.*-- test argument 5: 'after' diff --git a/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..ded1000 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(ExternalProject) + +set(script "${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake") +ExternalProject_Add( + blankChecker + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P "${script}" download "" after + UPDATE_COMMAND ${CMAKE_COMMAND} -P "${script}" update "" after + PATCH_COMMAND ${CMAKE_COMMAND} -P "${script}" patch "" after + CONFIGURE_COMMAND ${CMAKE_COMMAND} -P "${script}" configure "" after + BUILD_COMMAND ${CMAKE_COMMAND} -P "${script}" build "" after + INSTALL_COMMAND ${CMAKE_COMMAND} -P "${script}" install "" after + TEST_COMMAND ${CMAKE_COMMAND} -P "${script}" test "" after +) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index caaf0d2..0d1da26 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -29,6 +29,10 @@ endfunction() __ep_test_with_build(MultiCommand) +set(RunCMake_TEST_OUTPUT_MERGE 1) +__ep_test_with_build(PreserveEmptyArgs) +set(RunCMake_TEST_OUTPUT_MERGE 0) + # Output is not predictable enough to be able to verify it reliably # when using the various different Visual Studio generators if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") diff --git a/Tests/RunCMake/ExternalProject/countArgs.cmake b/Tests/RunCMake/ExternalProject/countArgs.cmake new file mode 100644 index 0000000..ee6429a --- /dev/null +++ b/Tests/RunCMake/ExternalProject/countArgs.cmake @@ -0,0 +1,5 @@ +message(STATUS "Number of arguments for ${CMAKE_ARGV3}: ${CMAKE_ARGC}") +math(EXPR last "${CMAKE_ARGC} - 1") +foreach(n RANGE 4 ${last}) + message(STATUS "${CMAKE_ARGV3} argument ${n}: '${CMAKE_ARGV${n}}'") +endforeach() diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt new file mode 100644 index 0000000..a72d914 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt @@ -0,0 +1,4 @@ +.*-- Number of arguments: 6 +.*-- Argument 3: 'before' +.*-- Argument 4: '' +.*-- Argument 5: 'after' diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..4f35448 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(FetchContent) + +# Need to see the download command output +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + t1 + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake + before "" after +) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 5e2e5e1..f3ed3e2 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -16,6 +16,10 @@ run_cmake(MakeAvailable) run_cmake(MakeAvailableTwice) run_cmake(MakeAvailableUndeclared) +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_cmake(PreserveEmptyArgs) +set(RunCMake_TEST_OUTPUT_MERGE 0) + # We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM # to ensure the test can run on machines where the build tool # isn't on the PATH. Some build slaves explicitly test with such diff --git a/Tests/RunCMake/FetchContent/countArgs.cmake b/Tests/RunCMake/FetchContent/countArgs.cmake new file mode 100644 index 0000000..7542af4 --- /dev/null +++ b/Tests/RunCMake/FetchContent/countArgs.cmake @@ -0,0 +1,5 @@ +message(STATUS "Number of arguments: ${CMAKE_ARGC}") +math(EXPR last "${CMAKE_ARGC} - 1") +foreach(n RANGE 3 ${last}) + message(STATUS "Argument ${n}: '${CMAKE_ARGV${n}}'") +endforeach() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 18ae793..b82335f 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -81,20 +81,46 @@ run_TestOutputSize() run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) -function(run_TestRepeat case) - set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion ${ARGN}) - string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ +function(run_TestRepeat case return_value ) + set(CASE_CTEST_TEST_ARGS RETURN_VALUE result EXCLUDE RunCMakeVersion ${ARGN}) + string(CONCAT suffix_code [[ add_test(NAME testRepeat COMMAND ${CMAKE_COMMAND} -D COUNT_FILE=${CMAKE_CURRENT_BINARY_DIR}/count.cmake -P "]] "${RunCMake_SOURCE_DIR}/TestRepeat${case}" [[.cmake") set_property(TEST testRepeat PROPERTY TIMEOUT 5) ]]) + string(APPEND CASE_CMAKELISTS_SUFFIX_CODE "${suffix_code}") run_ctest(TestRepeat${case}) + + #write to end of the test file logic to Verify we get the expected + #return code + string(REPLACE "RETURN_VALUE:" "" return_value "${return_value}" ) + file(APPEND "${RunCMake_BINARY_DIR}/TestRepeat${case}/test.cmake" +" + + set(expected_result ${return_value}) + message(STATUS \${result}) + if(NOT result EQUAL expected_result) + message(FATAL_ERROR \"expected a return value of: \${expected_result}, + instead got: \${result}\") + endif() +" + ) endfunction() -run_TestRepeat(UntilFail REPEAT UNTIL_FAIL:3) -run_TestRepeat(UntilPass REPEAT UNTIL_PASS:3) -run_TestRepeat(AfterTimeout REPEAT AFTER_TIMEOUT:3) + +run_TestRepeat(UntilFail RETURN_VALUE:1 REPEAT UNTIL_FAIL:3) +run_TestRepeat(UntilPass RETURN_VALUE:0 REPEAT UNTIL_PASS:3) +run_TestRepeat(AfterTimeout RETURN_VALUE:0 REPEAT AFTER_TIMEOUT:3) + +# test repeat and not run tests interact correctly +set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME testNotRun + COMMAND ${CMAKE_COMMAND}/doesnt_exist) + set_property(TEST testNotRun PROPERTY TIMEOUT 5) + ]]) +run_TestRepeat(NotRun RETURN_VALUE:1 REPEAT UNTIL_PASS:3) +unset(CASE_CMAKELISTS_SUFFIX_CODE) # test --stop-on-failure function(run_stop_on_failure) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt new file mode 100644 index 0000000..a69932d --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt @@ -0,0 +1 @@ +.*Unable to find executable.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt new file mode 100644 index 0000000..72c98bc --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt @@ -0,0 +1,5 @@ +.* +50% tests passed, 1 tests failed out of 2 +.* +The following tests FAILED: +.*testNotRun.*Not Run.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake new file mode 100644 index 0000000..abde4f0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake @@ -0,0 +1,10 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt index b443fd6..6b6fae6 100644 --- a/Utilities/cmliblzma/CMakeLists.txt +++ b/Utilities/cmliblzma/CMakeLists.txt @@ -7,11 +7,10 @@ include(CheckTypeSize) include(TestBigEndian) CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H) -CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H) CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H) -CHECK_INCLUDE_FILE(string.h HAVE_STRING_H) +set(HAVE_STRING_H 1) CHECK_INCLUDE_FILE(sys/sysctl.h HAVE_SYS_SYSCTL_H) CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) @@ -60,40 +59,6 @@ set(HAVE_MF_BT4 1) set(HAVE_MF_HC3 1) set(HAVE_MF_HC4 1) -CHECK_TYPE_SIZE(int16_t INT16_T) -CHECK_TYPE_SIZE(int32_t INT32_T) -CHECK_TYPE_SIZE(int64_t INT64_T) -CHECK_TYPE_SIZE(intmax_t INTMAX_T) -CHECK_TYPE_SIZE(uint8_t UINT8_T) -CHECK_TYPE_SIZE(uint16_t UINT16_T) -CHECK_TYPE_SIZE(uint32_t UINT32_T) -CHECK_TYPE_SIZE(uint64_t UINT64_T) -CHECK_TYPE_SIZE(uintmax_t UINTMAX_T) - -CHECK_TYPE_SIZE("short" SIZE_OF_SHORT) -CHECK_TYPE_SIZE("int" SIZE_OF_INT) -CHECK_TYPE_SIZE("long" SIZE_OF_LONG) -CHECK_TYPE_SIZE("long long" SIZE_OF_LONG_LONG) - -CHECK_TYPE_SIZE("unsigned short" SIZE_OF_UNSIGNED_SHORT) -CHECK_TYPE_SIZE("unsigned" SIZE_OF_UNSIGNED) -CHECK_TYPE_SIZE("unsigned long" SIZE_OF_UNSIGNED_LONG) -CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG) -CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T) - -CHECK_TYPE_SIZE("__int64" __INT64) -CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64) - -CHECK_TYPE_SIZE(uintptr_t UINTPTR_T) -IF(NOT HAVE_UINTPTR_T) - IF("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - SET(uintptr_t "uint64_t") - ELSE() - SET(uintptr_t "uint32_t") - ENDIF() -ENDIF() - - SET(LZMA_SRCS common/sysdefs.h common/tuklib_integer.h diff --git a/Utilities/cmliblzma/config.h.in b/Utilities/cmliblzma/config.h.in index 06f7fcb..8e4dc93 100644 --- a/Utilities/cmliblzma/config.h.in +++ b/Utilities/cmliblzma/config.h.in @@ -3,183 +3,36 @@ * Ensure we have C99-style int64_t, etc, all defined. */ -/* First, we need to know if the system has already defined them. */ -#cmakedefine HAVE_INT16_T -#cmakedefine HAVE_INT32_T -#cmakedefine HAVE_INT64_T -#cmakedefine HAVE_INTMAX_T +#include <cm3p/kwiml/int.h> -#cmakedefine HAVE_UINT8_T -#cmakedefine HAVE_UINT16_T -#cmakedefine HAVE_UINT32_T -#cmakedefine HAVE_UINT64_T -#cmakedefine HAVE_UINTMAX_T - -/* We might have the types we want under other spellings. */ -#cmakedefine HAVE___INT64 -#cmakedefine HAVE_U_INT64_T -#cmakedefine HAVE_UNSIGNED___INT64 - -/* The sizes of various standard integer types. */ -@SIZE_OF_SHORT_CODE@ -@SIZE_OF_INT_CODE@ -@SIZE_OF_LONG_CODE@ -@SIZE_OF_LONG_LONG_CODE@ -@SIZE_OF_UNSIGNED_SHORT_CODE@ -@SIZE_OF_UNSIGNED_CODE@ -@SIZE_OF_UNSIGNED_LONG_CODE@ -@SIZE_OF_UNSIGNED_LONG_LONG_CODE@ -@SIZEOF_SIZE_T_CODE@ - -/* - * If we lack int64_t, define it to the first of __int64, int, long, and long long - * that exists and is the right size. - */ -#if !defined(HAVE_INT64_T) && defined(HAVE___INT64) -typedef __int64 int64_t; -#define HAVE_INT64_T -#endif - -#if !defined(HAVE_INT64_T) && SIZE_OF_INT == 8 -typedef int int64_t; -#define HAVE_INT64_T -#endif - -#if !defined(HAVE_INT64_T) && SIZE_OF_LONG == 8 -typedef long int64_t; -#define HAVE_INT64_T -#endif - -#if !defined(HAVE_INT64_T) && SIZE_OF_LONG_LONG == 8 -typedef long long int64_t; -#define HAVE_INT64_T -#endif - -#if !defined(HAVE_INT64_T) -#error No 64-bit integer type was found. -#endif - -/* - * Similarly for int32_t - */ -#if !defined(HAVE_INT32_T) && SIZE_OF_INT == 4 -typedef int int32_t; -#define HAVE_INT32_T -#endif - -#if !defined(HAVE_INT32_T) && SIZE_OF_LONG == 4 -typedef long int32_t; -#define HAVE_INT32_T +#ifndef KWIML_INT_HAVE_INT64_T +# define int64_t KWIML_INT_int64_t #endif - -#if !defined(HAVE_INT32_T) -#error No 32-bit integer type was found. +#ifndef KWIML_INT_HAVE_INT32_T +# define int32_t KWIML_INT_int32_t #endif - -/* - * Similarly for int16_t - */ -#if !defined(HAVE_INT16_T) && SIZE_OF_INT == 2 -typedef int int16_t; -#define HAVE_INT16_T +#ifndef KWIML_INT_HAVE_INT16_T +# define int16_t KWIML_INT_int16_t #endif - -#if !defined(HAVE_INT16_T) && SIZE_OF_SHORT == 2 -typedef short int16_t; -#define HAVE_INT16_T +#ifndef KWIML_INT_HAVE_INT8_T +# define int8_t KWIML_INT_int8_t #endif - -#if !defined(HAVE_INT16_T) -#error No 16-bit integer type was found. +#ifndef KWIML_INT_HAVE_UINT64_T +# define uint64_t KWIML_INT_uint64_t #endif - -/* - * Similarly for uint64_t - */ -#if !defined(HAVE_UINT64_T) && defined(HAVE_UNSIGNED___INT64) -typedef unsigned __int64 uint64_t; -#define HAVE_UINT64_T +#ifndef KWIML_INT_HAVE_UINT32_T +# define uint32_t KWIML_INT_uint32_t #endif - -#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED == 8 -typedef unsigned uint64_t; -#define HAVE_UINT64_T +#ifndef KWIML_INT_HAVE_UINT16_T +# define uint16_t KWIML_INT_uint16_t #endif - -#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED_LONG == 8 -typedef unsigned long uint64_t; -#define HAVE_UINT64_T +#ifndef KWIML_INT_HAVE_UINT8_T +# define uint8_t KWIML_INT_uint8_t #endif - -#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED_LONG_LONG == 8 -typedef unsigned long long uint64_t; -#define HAVE_UINT64_T +#ifndef KWIML_INT_HAVE_UINTPTR_T +# define uintptr_t KWIML_INT_uintptr_t #endif -#if !defined(HAVE_UINT64_T) -#error No 64-bit unsigned integer type was found. -#endif - -/* - * Similarly for uint32_t - */ -#if !defined(HAVE_UINT32_T) && SIZE_OF_UNSIGNED == 4 -typedef unsigned uint32_t; -#define HAVE_UINT32_T -#endif - -#if !defined(HAVE_UINT32_T) && SIZE_OF_UNSIGNED_LONG == 4 -typedef unsigned long uint32_t; -#define HAVE_UINT32_T -#endif - -#if !defined(HAVE_UINT32_T) -#error No 32-bit unsigned integer type was found. -#endif - -/* - * Similarly for uint16_t - */ -#if !defined(HAVE_UINT16_T) && SIZE_OF_UNSIGNED == 2 -typedef unsigned uint16_t; -#define HAVE_UINT16_T -#endif - -#if !defined(HAVE_UINT16_T) && SIZE_OF_UNSIGNED_SHORT == 2 -typedef unsigned short uint16_t; -#define HAVE_UINT16_T -#endif - -#if !defined(HAVE_UINT16_T) -#error No 16-bit unsigned integer type was found. -#endif - -/* - * Similarly for uint8_t - */ -#if !defined(HAVE_UINT8_T) -typedef unsigned char uint8_t; -#define HAVE_UINT8_T -#endif - -#if !defined(HAVE_UINT16_T) -#error No 8-bit unsigned integer type was found. -#endif - -/* Define intmax_t and uintmax_t if they are not already defined. */ -#if !defined(HAVE_INTMAX_T) -typedef int64_t intmax_t; -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#endif - -#if !defined(HAVE_UINTMAX_T) -typedef uint64_t uintmax_t; -#endif - - -#cmakedefine uintptr_t @uintptr_t@ - #cmakedefine WORDS_BIGENDIAN 1 #cmakedefine HAVE_BYTESWAP_H 1 @@ -219,7 +72,9 @@ typedef uint64_t uintmax_t; #define HAVE_MF_HC4 1 /* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H 1 +#ifdef KWIML_INT_HAVE_INTTYPES_H +# define HAVE_INTTYPES_H 1 +#endif /* Define to 1 if you have the <limits.h> header file. */ #cmakedefine HAVE_LIMITS_H 1 @@ -231,7 +86,9 @@ typedef uint64_t uintmax_t; #cmakedefine HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 +#ifdef KWIML_INT_HAVE_STDINT_H +# define HAVE_STDINT_H 1 +#endif /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H 1 |