From 0fa8498256f0c8dbcc3778fda7d7ef771d5fa6ca Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Wed, 3 May 2017 16:49:06 +0200 Subject: [PATCH] CompileCheck: Fix check_flag for MSVC --- cmake/CompileCheck.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/CompileCheck.cmake b/cmake/CompileCheck.cmake index ac70e4f..b2ca4fc 100644 --- a/cmake/CompileCheck.cmake +++ b/cmake/CompileCheck.cmake @@ -117,7 +117,11 @@ endfunction(check_compile) function(check_flag RESULT FLAG TYPE) set(compile_test_file "${CMAKE_CURRENT_BINARY_DIR}/compile_flag_test.cpp") - file(WRITE ${compile_test_file} "__attribute__((const)) int main(){ return 0; }\n") + if(MSVC) + file(WRITE ${compile_test_file} "int main(){ return 0; }\n") + else() + file(WRITE ${compile_test_file} "__attribute__((const)) int main(){ return 0; }\n") + endif() check_compile(result "${compile_test_file}" "${FLAG}" "${TYPE} flag") set(${RESULT} "${result}" PARENT_SCOPE) endfunction(check_flag)