diff options
Diffstat (limited to 'Tests')
24 files changed, 174 insertions, 43 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index a574c4e..0a2c819 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -9,7 +9,7 @@ set(SRCS) # and also generate assembler files from C: if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode|Ninja" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ";") - if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND UNIX) + if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID MATCHES "Intel" AND UNIX) AND NOT (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")) set(C_FLAGS "${CMAKE_C_FLAGS}") separate_arguments(C_FLAGS) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d28d89f..4ed902c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -429,6 +429,10 @@ if(BUILD_TESTING) set(CMAKE_SKIP_VSGNUFortran TRUE) endif() endif() + if(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM) + message(STATUS "Skip VSGNUFortran for ifx until DLLEXPORT support is implemented") + set(CMAKE_SKIP_VSGNUFortran TRUE) + endif() if((CMAKE_C_COMPILER MATCHES lsb) AND (CMAKE_Fortran_COMPILER MATCHES ifort)) message(STATUS "Skip VSGNUFortran for ifort and lsb compilers") @@ -1948,7 +1952,7 @@ if(BUILD_TESTING) if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") ADD_TEST_MACRO(ForceInclude foo) endif() - if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") + if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") ADD_TEST_MACRO(PrecompiledHeader foo) endif() set(MSVCRuntimeLibrary_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) @@ -2014,12 +2018,19 @@ if(BUILD_TESTING) endif() endif() - # For the Watcom WMake generator, avoid the MFC test by default. if(CTEST_RUN_MFC) + # For the Watcom WMake generator, avoid the MFC test by default. if("${CMAKE_GENERATOR}" MATCHES "WMake") message(STATUS "using the Watcom WMake generator, avoiding MFC test") set(CTEST_RUN_MFC OFF) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM") + # clang-cl cannot deal with implicit dependencies in UTF16 files + # (see #18311). IntelLLVM inherits this behavior from Clang. + # TODO: maybe clang should also skip the MFC test + message(STATUS + "using generator other than Visual Studio with clang-cl, avoiding MFC test") + set(CTEST_RUN_MFC OFF) endif() endif() diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in index 1818888..a36f374 100644 --- a/Tests/CTestCoverageCollectGCOV/test.cmake.in +++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in @@ -29,6 +29,20 @@ set(expected_out uncovered/uncovered2.cpp ) +# A symbolic link in the path can cause tar to put an equivalent, but not +# minimal file name to some files in the tar file. Convert paths to absolute +# then back to relative to get them in canonical form (or maybe this is a bug +# in how the tarball is generated?) +function(to_relative_paths real_paths paths) + foreach(file ${paths}) + file(REAL_PATH "${file}" real_path BASE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + file(RELATIVE_PATH relative_path "${CTEST_BINARY_DIRECTORY}" "${real_path}") + list(APPEND local_real_paths "${relative_path}") + message(DEBUG "${file} -> ${real_path} -> ${relative_path}") + endforeach() + set("${real_paths}" "${local_real_paths}" PARENT_SCOPE) +endfunction() + #------------------------------------------------------------------------------# # Test 1: with standard arguments #------------------------------------------------------------------------------# @@ -50,6 +64,7 @@ execute_process(COMMAND ) string(REPLACE "\n" ";" out "${out}") +to_relative_paths(out "${out}") list(SORT out) if("${out}" STREQUAL "${expected_out}") @@ -80,6 +95,7 @@ execute_process(COMMAND ) string(REPLACE "\n" ";" out "${out}") +to_relative_paths(out "${out}") list(SORT out) if("${out}" STREQUAL "${expected_out}") @@ -110,6 +126,7 @@ execute_process(COMMAND ) string(REPLACE "\n" ";" out "${out}") +to_relative_paths(out "${out}") list(SORT out) if("${out}" STREQUAL "${expected_out}") @@ -140,6 +157,7 @@ execute_process(COMMAND ) string(REPLACE "\n" ";" out "${out}") +to_relative_paths(out "${out}") list(SORT out) if("${out}" STREQUAL "${expected_out}") @@ -170,6 +188,7 @@ execute_process(COMMAND ) string(REPLACE "\n" ";" out "${out}") +to_relative_paths(out "${out}") list(SORT out) if("${out}" STREQUAL "${expected_out}") diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index 5389bdf..8e0b611 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -17,21 +17,11 @@ message("Using CVS tools:") set(CVS "@CVS_EXECUTABLE@") message(" cvs = ${CVS}") -set(REPO ${TOP}/repo) - -# The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. -# Detect the MSYS cvs and convert the repo path to an MSYS path. -if(WIN32) - if(EXISTS "${CVS}") - file(STRINGS "${CVS}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") - if(cvs_is_msys) - message(" '${CVS}' is from MSYS (contains '${cvs_is_msys}')") - string(REGEX REPLACE "^([A-Za-z]):" "/\\1" REPO "${REPO}") - endif() - endif() -endif() +# Pre-pending :local: prevents cvs from trying to interpret Windows drive +# letters, like "C:", as host names. +set(REPO ":local:${TOP}/repo") -set(CVSCMD ${CVS} -d${REPO}) +set(CVSCMD ${CVS} -d "${REPO}") # CVSNT requires an extra option to 'cvs init'. set(CVS_INIT_OPT) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 0838532..cff98e3 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -4,9 +4,12 @@ cmake_policy(SET CMP0057 NEW) project(CompileFeatures) +set(ext_C c) +set(ext_CXX cpp) + macro(run_test feature lang) if (${feature} IN_LIST CMAKE_${lang}_COMPILE_FEATURES) - add_library(test_${feature} OBJECT ${feature}) + add_library(test_${feature} OBJECT ${feature}.${ext_${lang}}) set_property(TARGET test_${feature} PROPERTY COMPILE_FEATURES "${feature}" ) @@ -15,7 +18,7 @@ macro(run_test feature lang) endif() endmacro() -if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") foreach(feature ${c_features}) @@ -23,7 +26,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") endforeach() endif() -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") foreach(feature ${cxx_features}) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 132abf4..59e3bcc 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -161,7 +161,7 @@ if(do_cvs_tests) # set(proj TutorialStep1-CVS-20090626) ExternalProject_Add(${proj} - CVS_REPOSITORY "${local_cvs_repo}" + CVS_REPOSITORY ":local:${local_cvs_repo}" CVS_MODULE "TutorialStep1" CVS_TAG "-D2009-06-26 16:50:00 UTC" UPDATE_COMMAND "" @@ -176,7 +176,7 @@ if(do_cvs_tests) # set(proj TutorialStep1-CVS-testtag1) ExternalProject_Add(${proj} - CVS_REPOSITORY "${local_cvs_repo}" + CVS_REPOSITORY ":local:${local_cvs_repo}" CVS_MODULE "TutorialStep1" CVS_TAG -rtesttag1 UPDATE_COMMAND "" @@ -191,7 +191,7 @@ if(do_cvs_tests) # set(proj TutorialStep1-CVS-HEAD) ExternalProject_Add(${proj} - CVS_REPOSITORY "${local_cvs_repo}" + CVS_REPOSITORY ":local:${local_cvs_repo}" CVS_MODULE "TutorialStep1" CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt index b31a38b..6f8a7b1 100644 --- a/Tests/ExternalProjectUpdate/CMakeLists.txt +++ b/Tests/ExternalProjectUpdate/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 2.8.12) project(ExternalProjectUpdateTest NONE) if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) cmake_policy(SET CMP0114 NEW) +else() + # This test is very noisy with warnings about this policy if we don't + # explicitly set it. Projects shouldn't do this, but for test code this + # is reasonable. + cmake_policy(SET CMP0114 OLD) endif() cmake_policy(GET CMP0114 cmp0114) diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake index aaa05d7..394df87 100644 --- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -185,7 +185,6 @@ if(do_git_tests) # 'git fetch' check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 0 REBASE) check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1 REBASE) - check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 1 REBASE) check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 0 REBASE) check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 REBASE) # This is a remote symbolic ref, so it will always trigger a 'git fetch' diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 929fa4d..1868892 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -120,7 +120,7 @@ endfunction() # if the id's match or the compilers are compatible, then # call the test_fortran_c_interface_module function if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES - "(Intel:MSVC|Absoft:GNU)" + "(Intel(LLVM)?:MSVC|Absoft:GNU)" OR ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" )) test_fortran_c_interface_module() else() diff --git a/Tests/Fortran/myc.c b/Tests/Fortran/myc.c index efd9b68..1a4d5a4 100644 --- a/Tests/Fortran/myc.c +++ b/Tests/Fortran/myc.c @@ -1,6 +1,6 @@ #include "foo.h" -extern F_test_mod_sub(void); -extern F_mysub(void); +extern void F_test_mod_sub(void); +extern void F_mysub(void); int myc(void) { F_mysub(); diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 637f581..b5b5e56 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -111,7 +111,7 @@ endif() # Test that with Intel Fortran we always compile with preprocessor # defines even if splitting the preprocessing and compilation steps. -if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") add_executable(IntelIfDef IntelIfDef.f) set_property(TARGET IntelIfDef PROPERTY Fortran_FORMAT FIXED) target_compile_definitions(IntelIfDef PRIVATE SOME_DEF) @@ -146,13 +146,13 @@ set_property(SOURCE no_preprocess_source_lower.f PROPERTY Fortran_PREPROCESS OFF # Test that we can explicitly not preprocess a target or source. # This will not work on certain compilers due to either missing a # "don't preprocess" flag, or due to choice of file extension. -if(test_pp_flags AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|SunPro|XL)") +if(test_pp_flags AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|NVHPC|SunPro|XL)") add_library(no_preprocess_target STATIC no_preprocess_target_upper.F) target_compile_options(no_preprocess_target PRIVATE -DINTEGER=nonsense) add_library(no_preprocess_source STATIC no_preprocess_source_upper.F) target_compile_options(no_preprocess_source PRIVATE -DINTEGER=nonsense) if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL "Cray" - AND NOT "${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "Intel;MSVC") + AND NOT "${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "Intel(LLVM)?;MSVC") target_sources(no_preprocess_target PRIVATE no_preprocess_target_fpp.fpp) target_sources(no_preprocess_source PRIVATE no_preprocess_source_fpp.fpp) endif() diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt index 27838a4..41bd6f5 100644 --- a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt +++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt @@ -6,8 +6,9 @@ foreach(t MultiThreaded SingleThreaded) foreach(dbg "" Debug) foreach(dll "" DLL) set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_${t}${dbg}${dll}") - if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") - # ifort does not actually define these, so inject them + if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" + OR CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + # ifort and ifx do not actually define these, so inject them string(REPLACE "-threads" "-threads;-D_MT" "${var}" "${${var}}") string(REPLACE "-dbglibs" "-dbglibs;-D_DEBUG" "${var}" "${${var}}") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index cffef5a..0cf74bf 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -52,7 +52,7 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") endif() @@ -95,7 +95,7 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") endif() diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 95aa351..5aa2459 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -9,8 +9,9 @@ endif() # Intel 11.1 does not support /Fd but Intel 14.0 does. # TODO: Did a version in between these add it? -if(CMAKE_C_COMPILER_ID STREQUAL Intel AND - CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0) +if((CMAKE_C_COMPILER_ID STREQUAL Intel AND + CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0) OR + CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") set(NO_COMPILE_PDB 1) endif() diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index bce1b3f..bf2af64 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -147,8 +147,13 @@ endif() # - NMake is okay with just \\\" # - The XL compiler does not re-escape \\\" when launching an # internal tool to do preprocessing . +# - The IntelLLVM C and C++ compiler drivers do not re-escape the \\\" when +# launching the underlying compiler. FIXME: this bug is expected to be fixed +# in a future release. if((PP_NMAKE OR PP_UMAKE) AND - NOT CMAKE_C_COMPILER_ID STREQUAL "XL") + NOT CMAKE_C_COMPILER_ID STREQUAL "XL" AND + NOT CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM" AND + NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") string(APPEND STRING_EXTRA "\\\"") endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index bd08dd9..323306a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -268,7 +268,7 @@ add_RunCMake_test(Graphviz) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) -if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$") add_RunCMake_test(MetaCompileFeatures) endif() if(MSVC) diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 345b37f..0ab545a 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -79,6 +79,11 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) "which does not match:${msg_expected}\n" "${output_error_message}") endif() + elseif(foundFilescount_ EQUAL 0) + message(FATAL_ERROR + "Found no files for file No. '${file_no_}'!" + " Globbing expression: '${EXPECTED_FILE_${file_no_}}'" + "${output_error_message}") else() message(FATAL_ERROR "Found more than one file for file No. '${file_no_}'!" diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index d270005..9ff1f8a 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -1,7 +1,7 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) -# PGI compiler doesn't add build id to binaries by default -if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") +# Some compilers do not add build id to binaries by default. +if(CMAKE_CXX_COMPILER_ID MATCHES "^(IntelLLVM|PGI|NVHPC)$") string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id") string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id") endif() diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake index cb0d541..891e138 100644 --- a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -10,7 +10,8 @@ function(check_files dir) set(actual) foreach(i IN LISTS glob) if(NOT i MATCHES "(\\.manifest$)|(\\.exp$)|(\\.tds$)") - list(APPEND actual ${i}) + get_filename_component(real_path ${i} REALPATH) + list(APPEND actual ${real_path}) endif() endforeach() list(REMOVE_DUPLICATES actual) diff --git a/Tests/RunCMake/ExternalProject/FetchGitTags.cmake b/Tests/RunCMake/ExternalProject/FetchGitTags.cmake new file mode 100644 index 0000000..37d1b40 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/FetchGitTags.cmake @@ -0,0 +1,67 @@ +find_package(Git QUIET REQUIRED) + +include(ExternalProject) + +set(srcRepo ${CMAKE_CURRENT_BINARY_DIR}/srcRepo) +set(srcDir ${CMAKE_CURRENT_BINARY_DIR}/src) +set(binDir ${CMAKE_CURRENT_BINARY_DIR}/build) +file(MAKE_DIRECTORY ${srcRepo}) +file(MAKE_DIRECTORY ${srcDir}) + +file(GLOB entries ${srcRepo}/*) +file(REMOVE_RECURSE ${entries} ${binDir}) +file(TOUCH ${srcRepo}/firstFile.txt) +configure_file(${CMAKE_CURRENT_LIST_DIR}/FetchGitTags/CMakeLists.txt + ${srcDir}/CMakeLists.txt COPYONLY) + +function(execGitCommand) + execute_process( + WORKING_DIRECTORY ${srcRepo} + COMMAND ${GIT_EXECUTABLE} ${ARGN} + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY + ) +endfunction() + +function(configureAndBuild tag) + execute_process(COMMAND ${CMAKE_COMMAND} + -G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}" + -A "${CMAKE_GENERATOR_PLATFORM}" + -D repoDir:PATH=${srcRepo} + -D gitTag:STRING=${tag} + -B ${binDir} + -S ${srcDir} + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY + ) + + execute_process(COMMAND ${CMAKE_COMMAND} --build ${binDir} --target fetcher + WORKING_DIRECTORY ${binDir} + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY + ) +endfunction() + +# Setup a fresh source repo with a predictable default branch across all +# git versions +execGitCommand(-c init.defaultBranch=master init) +execGitCommand(config --add user.email "testauthor@cmake.org") +execGitCommand(config --add user.name testauthor) + +# Create the initial repo structure +execGitCommand(add firstFile.txt) +execGitCommand(commit -m "First file") + +message(STATUS "First configure-and-build") +configureAndBuild(master) + +# Create a tagged commit that is not on any branch. With git 2.20 or later, +# this commit won't be fetched without the --tags option. +file(TOUCH ${srcRepo}/secondFile.txt) +execGitCommand(add secondFile.txt) +execGitCommand(commit -m "Second file") +execGitCommand(tag -a -m "Adding tag" tag_of_interest) +execGitCommand(reset --hard HEAD~1) + +message(STATUS "Second configure-and-build") +configureAndBuild(tag_of_interest) diff --git a/Tests/RunCMake/ExternalProject/FetchGitTags/CMakeLists.txt b/Tests/RunCMake/ExternalProject/FetchGitTags/CMakeLists.txt new file mode 100644 index 0000000..d9a380c --- /dev/null +++ b/Tests/RunCMake/ExternalProject/FetchGitTags/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.19) +project(FetchTags LANGUAGES NONE) + +include(ExternalProject) + +# repoDir and gitTag are expected to be set as cache variables + +ExternalProject_Add(fetcher + GIT_REPOSITORY ${repoDir} + GIT_TAG ${gitTag} + GIT_REMOTE_UPDATE_STRATEGY CHECKOUT + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 22b8d24..976655a 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -181,3 +181,12 @@ endfunction() if(NOT RunCMake_GENERATOR MATCHES "Visual Studio 9 ") __ep_test_CONFIGURE_HANDLED_BY_BUILD() endif() + +find_package(Git QUIET) +if(GIT_EXECUTABLE) + # Note that there appear to be differences in where git writes its output to + # on some platforms. It may go to stdout or stderr, so force it to be merged. + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + run_cmake(FetchGitTags) + set(RunCMake_TEST_OUTPUT_MERGE FALSE) +endif() diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index c66757f..df2410a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -608,7 +608,7 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/generated_exe.json"), ] - if cxx_compiler_id in ['Clang', 'AppleClang', 'GNU', 'Intel', 'MSVC', 'Embarcadero'] and g["name"] != "Xcode": + if cxx_compiler_id in ['Clang', 'AppleClang', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero'] and g["name"] != "Xcode": for e in expected: if e["name"] == "cxx_exe": if matches(g["name"], "^(Visual Studio |Ninja Multi-Config)"): diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index ae9a84c..431d1ce 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -103,7 +103,7 @@ add_executable(GenerateExportHeader exportheader_test.cpp) target_link_libraries(GenerateExportHeader ${link_libraries}) if (WIN32 OR CYGWIN) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND + if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") set(_platform Win32-Clang) elseif(MSVC AND COMPILER_HAS_DEPRECATED) |