From b19516b0c55b093120c06185c404bfc22ef90f80 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 16 May 2019 22:52:28 +0200 Subject: [PATCH] Copy the values of {C,CXX,F}FLAGS into smpi{cc,cxx,ff,f90}. The goal is to be able to give compiler flags at cmake time, and to have them used later by the smpi script. For example, it can be used to pass "-m64" and build a 64bit simgrid when it's 32it by default (e.g. on Solaris). The goal is, for example, to be able to set the variable --- CMakeLists.txt | 11 ++++++++++- src/smpi/smpicc.in | 2 +- src/smpi/smpicxx.in | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c1da7af87..50075e0b47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/smpi/smpicc.in b/src/smpi/smpicc.in index 3cc7a6a44e..9098f97353 100755 --- a/src/smpi/smpicc.in +++ b/src/smpi/smpicc.in @@ -23,7 +23,7 @@ else LINKER_UNDEFINED_ERROR="1" fi -list_set CFLAGS +list_set CFLAGS @SMPI_C_FLAGS@ list_set LINKARGS "-lm" if [ "x@WIN32@" = "x1" ]; then list_add CFLAGS "-include" "@includedir@/smpi/smpi_main.h" diff --git a/src/smpi/smpicxx.in b/src/smpi/smpicxx.in index 9b45519d2a..9d2a2c8df1 100755 --- a/src/smpi/smpicxx.in +++ b/src/smpi/smpicxx.in @@ -16,7 +16,7 @@ CMAKE_LINKARGS="-L@libdir@" @SMPITOOLS_SH@ -list_set CXXFLAGS "-std=gnu++11" +list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@ list_set LINKARGS if [ "@WIN32@" != "1" ]; then list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h" -- 2.20.1