Fix that no OpenMP flags are used with GMX_OPENMP=no
authorRoland Schulz <roland@utk.edu>
Mon, 8 Oct 2012 21:14:47 +0000 (17:14 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 30 Oct 2012 03:32:46 +0000 (04:32 +0100)
If OpenMP flags were set because find_package(OpenMP) could
find something but GMX_OPENMP was false (either set by user
or because find_package(OpenMP) was only partial succesful)
then compiler or linker flags was set which were not needed.
This could cause undefined OpenMP linker errors with
GMX_OPENMP=no.

Fixes part of #1021

Change-Id: I9b66a8c89a84374081886cd2eeb46c87664c1e39

CMakeLists.txt

index 95313476492728199df2f6f69db4d1e857c69f8c..3c4f212b23444e866047c095e71e592b4bd038da 100644 (file)
@@ -1055,6 +1055,14 @@ if (NOT DEFINED GROMACS_C_FLAGS_SET)
         CACHE STRING "Linker flags for creating shared libraries" FORCE) 
 endif (NOT DEFINED GROMACS_C_FLAGS_SET)
 
+if(NOT GMX_OPENMP)
+    #Unset all OpenMP flags in case OpenMP was disabled either by the user
+    #or because it was only partially detected (e.g. only for C but not C++ compiler)
+    unset(OpenMP_C_FLAGS CACHE) 
+    unset(OpenMP_CXX_FLAGS CACHE)
+    unset(OpenMP_LINKER_FLAGS CACHE)
+    unset(OpenMP_SHARED_LINKER_FLAGS)
+endif()
 ######################################
 # Output compiler and CFLAGS used
 ######################################