From 5c04dfe465d85be3d11f37d16d6ebcafbdcb7d53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 14 May 2014 23:55:34 +0200 Subject: Features: Only require AppleClang policy to be NEW on APPLE. --- Modules/Compiler/Clang-CXX.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index a1b3a10..0409c24 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -6,7 +6,7 @@ if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") endif() cmake_policy(GET CMP0025 appleClangPolicy) -if(NOT appleClangPolicy STREQUAL NEW) +if(APPLE AND NOT appleClangPolicy STREQUAL NEW) return() endif() -- cgit v0.12 From f6f1095413772e5d52f6699ff7324180e30f5c35 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 14 May 2014 23:56:53 +0200 Subject: Features: Use the features symbol in the feature-test compile. Clang discards the entire string if it is not used, removing the ability to read the features from the compiled binary. That is prevented by using the symbol. GNU with -O3 also discards the string, so use the string in a way which is determined by a runtime value (argc) to prevent it being discarded. --- Modules/Internal/FeatureTesting.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index 7bf6d91..abd9a26 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -20,7 +20,7 @@ macro(record_compiler_features lang compile_flags feature_list) endif() endforeach() file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" - "\n};\n\nint main() { return 0; }\n") + "\n};\n\nint main(int argc, char** argv) { (void)argv; return features[argc]; }\n") try_compile(CMAKE_${lang}_FEATURE_TEST ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" -- cgit v0.12