diff options
author | Brad King <brad.king@kitware.com> | 2022-10-31 16:48:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-10-31 17:01:51 (GMT) |
commit | 1abcb094a7172bfadd5fde90b4c6c19f5527a818 (patch) | |
tree | 8b390f9a1ddbd4943a41b10f2177dbf5987fe9e0 /Tests/RunCMake/try_compile | |
parent | b641a80d55ccde59d8e5c25c63b44df5ee0d999c (diff) | |
download | CMake-1abcb094a7172bfadd5fde90b4c6c19f5527a818.zip CMake-1abcb094a7172bfadd5fde90b4c6c19f5527a818.tar.gz CMake-1abcb094a7172bfadd5fde90b4c6c19f5527a818.tar.bz2 |
Tests: Fix logic to enable RunCMake.try_compile OBJC/OBJCXX cases
CMake itself does not enable the OBJC/OBJCXX languages, so the
`CMAKE_OBJ{C,CXX}_STANDARD_DEFAULT` variables are never defined.
Detect them inside the test instead.
Diffstat (limited to 'Tests/RunCMake/try_compile')
-rw-r--r-- | Tests/RunCMake/try_compile/Inspect.cmake | 20 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/RunCMakeTest.cmake | 15 |
2 files changed, 26 insertions, 9 deletions
diff --git a/Tests/RunCMake/try_compile/Inspect.cmake b/Tests/RunCMake/try_compile/Inspect.cmake index added41..bfca882 100644 --- a/Tests/RunCMake/try_compile/Inspect.cmake +++ b/Tests/RunCMake/try_compile/Inspect.cmake @@ -1,4 +1,18 @@ enable_language(CXX) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " -set(CMAKE_CXX_EXTENSIONS_DEFAULT \"${CMAKE_CXX_EXTENSIONS_DEFAULT}\") -") +if(CMake_TEST_OBJC) + enable_language(OBJC) + enable_language(OBJCXX) +endif() + +set(info "") +foreach(var + CMAKE_CXX_EXTENSIONS_DEFAULT + CMAKE_OBJC_STANDARD_DEFAULT + CMAKE_OBJCXX_STANDARD_DEFAULT + ) + if(DEFINED ${var}) + string(APPEND info "set(${var} \"${${var}}\")\n") + endif() +endforeach() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 7245471..d02a391 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -1,5 +1,14 @@ include(RunCMake) +# Detect information from the toolchain: +# - CMAKE_CXX_EXTENSIONS_DEFAULT +# - CMAKE_OBJC_STANDARD_DEFAULT +# - CMAKE_OBJCXX_STANDARD_DEFAULT +run_cmake_with_options(Inspect + -DCMake_TEST_OBJC=${CMake_TEST_OBJC} + ) +include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + run_cmake(NoArgs) run_cmake(OneArg) run_cmake(TwoArgs) @@ -88,12 +97,6 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() -# Lookup CMAKE_CXX_EXTENSIONS_DEFAULT. -# FIXME: Someday we could move this to the top of the file and use it in -# place of some of the values passed by 'Tests/RunCMake/CMakeLists.txt'. -run_cmake(Inspect) -include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") - # FIXME: Support more compilers and default standard levels. if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT AND ( |