From 74d7ba276ec7a82e04faf554cc1c7c39455f6141 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 Apr 2014 09:48:32 +0200 Subject: [PATCH] Test if variable is defined before executing GCC test --- CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 590b6d0b72..c32423b2a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,14 +99,19 @@ find_package( OpenGL ) # Allow use of non-threadsafe reference counter in cvf::Object on systems with no atomics support if (CMAKE_COMPILER_IS_GNUCC) - check_c_source_compiles("int main(int argc, char **argv) { - int a; - __sync_add_and_fetch(&a, 1); - __sync_fetch_and_add(&a, 1); - __sync_sub_and_fetch(&a, 1); - __sync_fetch_and_sub(&a, 1); }" HAVE_GCC_ATOMICS) + if (NOT DEFINED HAVE_GCC_ATOMICS) + check_c_source_compiles("int main(int argc, char **argv) { + int a; + __sync_add_and_fetch(&a, 1); + __sync_fetch_and_add(&a, 1); + __sync_sub_and_fetch(&a, 1); + __sync_fetch_and_sub(&a, 1); }" HAVE_GCC_ATOMICS) + endif() - if (NOT HAVE_GCC_ATOMITCS) + if (HAVE_GCC_ATOMICS) + message("Atomics supported") + else() + message("Atomics not supported") add_definitions(-DCVF_WORKAROUND_TO_COMPILE_ON_SYSTEMS_WITHOUT_ATOMICS) endif()