summaryrefslogtreecommitdiffstats
path: root/Modules/Internal/FeatureTesting.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-05-14 21:56:53 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-05-15 17:38:25 (GMT)
commitf6f1095413772e5d52f6699ff7324180e30f5c35 (patch)
treee701e0335ccf905c906163c05a2e02e0d8ca0cbe /Modules/Internal/FeatureTesting.cmake
parent5c04dfe465d85be3d11f37d16d6ebcafbdcb7d53 (diff)
downloadCMake-f6f1095413772e5d52f6699ff7324180e30f5c35.zip
CMake-f6f1095413772e5d52f6699ff7324180e30f5c35.tar.gz
CMake-f6f1095413772e5d52f6699ff7324180e30f5c35.tar.bz2
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.
Diffstat (limited to 'Modules/Internal/FeatureTesting.cmake')
-rw-r--r--Modules/Internal/FeatureTesting.cmake2
1 files changed, 1 insertions, 1 deletions
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}"