diff options
author | Brad King <brad.king@kitware.com> | 2022-04-11 12:50:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-04-11 12:50:58 (GMT) |
commit | c362d02e74723007c6b9f87f0ee5736e8f5df1c7 (patch) | |
tree | 1cabe38de51695df6926d3ef28da1175a22f7830 /Tests | |
parent | fd957139c29ba098ad873b8e0f2d85878e62c073 (diff) | |
parent | a10fc754a6a12c681f3acc7efa84798f6c2ea799 (diff) | |
download | CMake-c362d02e74723007c6b9f87f0ee5736e8f5df1c7.zip CMake-c362d02e74723007c6b9f87f0ee5736e8f5df1c7.tar.gz CMake-c362d02e74723007c6b9f87f0ee5736e8f5df1c7.tar.bz2 |
Merge topic 'check-flag-fembed-bitcode-conflict'
a10fc754a6 CheckSourceCompiles: Avoid linker warning with -fembed-bitcode
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7156
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake | 18 | ||||
-rw-r--r-- | Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake new file mode 100644 index 0000000..128f9db --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +include(CheckCompilerFlag) + +# Confirm we can check the conflicting flag directly. This should pass with +# or without the workaround. +check_compiler_flag(C "-fembed-bitcode" result1) +if(NOT result1) + message(FATAL_ERROR "False negative when -fembed-bitcode tested directly") +endif() + +# Check conflicting flag set by user or project won't cause a false negative +# when testing a valid flag. This only passes with the workaround. +set(CMAKE_C_FLAGS -fembed-bitcode) +check_compiler_flag(C "-O" result2) +if(NOT result2) + message(FATAL_ERROR "False negative when -fembed-bitcode set in CMAKE_C_FLAGS") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake index 7ef1860..df2b667 100644 --- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -26,3 +26,7 @@ endif() if(CMake_TEST_HIP) run_cmake(CheckHIPCompilerFlag) endif() + +if(APPLE) + run_cmake_with_options(HeaderpadWorkaround --debug-trycompile) +endif() |