Test if variable is defined before executing GCC test

This commit is contained in:
Magne Sjaastad 2014-04-15 09:48:32 +02:00
parent 922d76cd91
commit 74d7ba276e

View File

@ -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()