summaryrefslogtreecommitdiff
path: root/Tests/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-03 06:42:06 -0500
committerBrad King <brad.king@kitware.com>2022-02-03 06:45:53 -0500
commit9d621ceba115a409ca58e8c59fba365f55fd6d26 (patch)
tree50234a073c5b466d02c1281e804a1829c65435e7 /Tests/CMakeLists.txt
parent92459258108c0036808f29f83a8503fea18ccee9 (diff)
downloadcmake-9d621ceba115a409ca58e8c59fba365f55fd6d26.tar.gz
Tests: Run MFC test only when explicitly enabled
Previously we used a complicated heuristic to decide whether or not to run the MFC test, but it sometimes decided incorrectly to run the test. Since that was first written, we have developed a convention for other tests to enable them via undocumented cache entries that are added only on machines known to meet the tests' requirements. Do that for MFC.
Diffstat (limited to 'Tests/CMakeLists.txt')
-rw-r--r--Tests/CMakeLists.txt104
1 files changed, 1 insertions, 103 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index da6219e763..6946ffbb86 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2107,109 +2107,7 @@ if(BUILD_TESTING)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
endif()
- if(NOT DEFINED CTEST_RUN_MFC)
- set(CTEST_RUN_MFC OFF)
-
- if(MSVC)
- set(CTEST_RUN_MFC ON)
-
- # Look for evidence that this is a VCExpress build. If so, avoid
- # the MFC test by default.
- string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
- if(mkprog MATCHES "vcexpress")
- message(STATUS
- "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
- set(CTEST_RUN_MFC OFF)
- endif()
-
- # Since MSBuild might also be the "makeprogram" for a VCExpress
- # build tree, use one more heuristic, too. The string representing
- # the .vcproj file type contains "VCExpress" on machines where an
- # express edition of VS was installed last:
- if(CTEST_RUN_MFC)
- execute_process(COMMAND cmd /c assoc .vcproj
- OUTPUT_STRIP_TRAILING_WHITESPACE
- OUTPUT_VARIABLE ov)
- if(ov MATCHES "VCExpress")
- message(STATUS
- ".vcproj file association indicates VCExpress, avoiding MFC test")
- set(CTEST_RUN_MFC OFF)
- elseif( NOT ov )
- message(STATUS
- ".vcproj has no file association, avoiding MFC test")
- set(CTEST_RUN_MFC OFF)
- endif()
- endif()
-
- 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()
-
- # Last resort, after quick checks are done. Do a try_compile, and avoid
- # the MFC test if the simplest possible MFC app cannot be compiled.
- if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
- ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
- COPYONLY
- )
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
- COPYONLY
- )
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
- ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
- COPYONLY
- )
-
- message(STATUS "Looking for MFC")
-
- try_compile(HAVE_MFC
- ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
- ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
- try_compile_mfc
- OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
-
- if(HAVE_MFC)
- message(STATUS "Looking for MFC - found")
- set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
- file(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if MFC exists passed with the following output:\n"
- "${HAVE_MFC_OUTPUT}\n\n")
- else()
- message(STATUS "Looking for MFC - not found")
- set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
- file(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if MFC exists failed with the following output:\n"
- "${HAVE_MFC_OUTPUT}\n\n")
- endif()
- endif()
-
- if(CTEST_RUN_MFC AND NOT HAVE_MFC)
- message(STATUS
- "cannot compile simplest ever MFC app, avoiding MFC test")
- set(CTEST_RUN_MFC OFF)
- endif()
- endif()
- endif()
-
- if(CTEST_RUN_MFC)
+ if(CMake_TEST_MFC)
add_test(MFC ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/MFC"