Commit 48fccd2a authored by Lynn Garren's avatar Lynn Garren

fix the logic associated with -DCLHEP_BUILD_CXXSTD=ON

parent defc7459
......@@ -2,6 +2,11 @@
12.08.14 Release CLHEP-2.2.0.2
==============================
2014-08-12 Lynn Garren <garren@fnal.gov>
* cmake/Modules/ClhepVariables.cmake: if the user compiles with -std=c++11
and does not use -DCLHEP_BUILD_CXXSTD=ON, the required flags will be set.
2014-08-08 Lynn Garren <garren@fnal.gov>
* Units/Units/SystemOfUnits.h, Units/Units/PhysicalConstants.h:
......
......@@ -89,6 +89,7 @@ macro( _clhep_check_cxxstd )
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9 )
message( FATAL_ERROR "c++11 extensions are not available for ${CMAKE_CXX_COMPILER_ID}${CMAKE_CXX_COMPILER_VERSION}")
......@@ -99,25 +100,51 @@ macro( _clhep_check_cxxstd )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3 )
message( FATAL_ERROR "c++11 extensions are not available for ${CMAKE_CXX_COMPILER}")
elseif( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -ftls-model=initial-exec -pthread -Wno-deprecated-declarations" )
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -ftls-model=initial-exec -pthread -Wno-deprecated-declarations" )
set( CMAKE_CXX_FLAGS "-std=c++0x -ftls-model=initial-exec -pthread -Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ftls-model=initial-exec -pthread -Wno-deprecated-declarations" )
#set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ftls-model=initial-exec -pthread -Wno-deprecated-declarations" )
set( CMAKE_CXX_FLAGS "-std=c++11 -ftls-model=initial-exec -pthread -Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}" )
endif()
else()
message(STATUS "clhep_set_compiler_flags: Do not know how to set c++11 extensions for ${CMAKE_CXX_COMPILER_ID}")
endif()
endmacro( _clhep_check_cxxstd )
macro( _clhep_check_for_pthread )
#message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE " " ";" flag_list ${CMAKE_CXX_FLAGS})
FOREACH(flag ${flag_list})
#message(STATUS "_clhep_check_for_pthread debug: found flag ${flag}" )
if( ${flag} STREQUAL "-std=c++11" )
set(HAVE_STDCXX true)
elseif( ${flag} STREQUAL "-std=c++1y" )
set(HAVE_STDCXX true)
elseif( ${flag} STREQUAL "-std=c++0x" )
set(HAVE_STDCXX true)
endif()
ENDFOREACH(flag)
if( HAVE_STDCXX )
set( CMAKE_CXX_FLAGS "-ftls-model=initial-exec -pthread ${CMAKE_CXX_FLAGS}" )
endif()
#message(STATUS "_clhep_check_for_pthread debug: HAVE_STDCXX ${HAVE_STDCXX}")
#message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
endmacro( _clhep_check_for_pthread )
macro( clhep_set_compiler_flags )
##message(STATUS "incoming cmake build type is ${CMAKE_BUILD_TYPE}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
endif()
##message(STATUS "clhep_set_compiler_flags debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "cmake build type is ${CMAKE_BUILD_TYPE}")
if( CLHEP_BUILD_CXXSTD )
_clhep_check_cxxstd()
message(STATUS "enable c++11 extensions: ${CMAKE_CXX_FLAGS}")
else()
_clhep_check_for_pthread()
endif()
#message(STATUS "clhep_set_compiler_flags debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
#message(STATUS "cmake compilers ${CMAKE_CXX_COMPILER} ${CMAKE_C_COMPILER}")
get_filename_component(clhep_cxx_compiler ${CMAKE_CXX_COMPILER} NAME)
get_filename_component(clhep_c_compiler ${CMAKE_C_COMPILER} NAME)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment