Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Copy the values of {C,CXX,F}FLAGS into smpi{cc,cxx,ff,f90}.
[simgrid.git] / CMakeLists.txt
index 9c1da7a..50075e0 100644 (file)
@@ -4,6 +4,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/tools/cmake/M
 
 project(SimGrid C CXX)
 
+## Save compiler flags preset with environment variables CFLAGS or CXXFLAGS;
+## they will used within smpicc, smpicxx.
+## Do it early so that we get their genuine values. The same will be done later for Fortran.
+set(SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
+set(SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 #     Check for the compiler        #
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
@@ -22,7 +28,6 @@ CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
 ## Request full debugging flags
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
 
 if (CMAKE_COMPILER_IS_GNUCC)    
   if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
@@ -80,6 +85,10 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi)
       set(SMPI_Fortran_LIBS "")
       set(SMPI_FLANG 1)
     endif()
+    set(SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
+
+    ## Request debugging flags for Fortran too
+    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
 
     set(SMPI_FORTRAN 1)
   endif(CMAKE_Fortran_COMPILER)