From: Mika Lindqvist Date: Thu, 28 Apr 2016 18:46:17 +0000 (+0300) Subject: CMakeLists.txt: We can't use check_c_source_runs() when cross-compiling. X-Git-Tag: 1.9.9-b1~660^2~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F88%2Fhead;p=thirdparty%2Fzlib-ng.git CMakeLists.txt: We can't use check_c_source_runs() when cross-compiling. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fb70ba2e..6d1bb52f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,6 +249,16 @@ if(HAVE_BUILTIN_CTZL) add_definitions(-DHAVE_BUILTIN_CTZL) endif() +# Macro to check if source compiles when cross-compiling +# or runs when compiling natively +macro(check_c_source_compile_or_run source flag) + if(CMAKE_CROSSCOMPILING) + check_c_source_compiles("${source}" ${flag}) + else() + check_c_source_runs("${source}" ${flag}) + endif() +endmacro(check_c_source_compile_or_run) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DZLIB_DEBUG") if(MSVC) @@ -264,7 +274,7 @@ else() else() set(CMAKE_REQUIRED_FLAGS "${SSE2FLAG}") endif() - check_c_source_runs( + check_c_source_compile_or_run( "#include int main(void) { @@ -280,7 +290,7 @@ else() # use the generic SSE4 enabler option to check for the SSE4.2 instruction we require: set(CMAKE_REQUIRED_FLAGS "${SSE4FLAG}") endif() - check_c_source_runs( + check_c_source_compile_or_run( "int main(void) { unsigned val = 0, h = 0; @@ -294,7 +304,7 @@ else() else() set(CMAKE_REQUIRED_FLAGS "${PCLMULFLAG}") endif() - check_c_source_runs( + check_c_source_compile_or_run( "#include #include int main(void)