Skip to content

Commit

Permalink
CMake: Pass global -std flag from fairsoft-config into CMAKE_CXX_STAN…
Browse files Browse the repository at this point in the history
…DARD variable
  • Loading branch information
dennisklein committed Mar 30, 2021
1 parent 21053af commit 1a4a3f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ if(CMAKE_CXX_FLAGS)
message(STATUS " ")
message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}")
endif()
if(CMAKE_CXX_STANDARD)
message(STATUS " ")
message(STATUS " ${Cyan}GLOBAL CXX STANDARD${CR} ${BGreen}c++${CMAKE_CXX_STANDARD}${CR}")
endif()
if(CMAKE_CONFIGURATION_TYPES)
message(STATUS " ")
message(STATUS " ${Cyan}BUILD TYPE CXX FLAGS${CR}")
Expand Down
9 changes: 8 additions & 1 deletion cmake/modules/CheckCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ If(FAIRSOFT_CONFIG)

Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxxflags
OUTPUT_VARIABLE FAIRSOFT_CXX_FLAGS)
unset(CMAKE_MATCH_1)
String(REGEX REPLACE "-std=c\\+\\+(..)" "" FAIRSOFT_CXX_FLAGS "${FAIRSOFT_CXX_FLAGS}")
if(CMAKE_MATCH_1 AND (NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD VERSION_LESS CMAKE_MATCH_1))
set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
endif()
String(STRIP ${FAIRSOFT_CXX_FLAGS} FAIRSOFT_CXX_FLAGS)
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FAIRSOFT_CXX_FLAGS}")
if(FAIRSOFT_CXX_FLAGS)
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FAIRSOFT_CXX_FLAGS}")
endif()
Else()
Message(STATUS "fairsoft-config not found. Is SIMPATH or FAIRSOFT_ROOT set correctly?")
EndIf()
Expand Down

0 comments on commit 1a4a3f9

Please sign in to comment.