Warning, /geant4/cmake/Modules/G4MakeRules_cxx.cmake is written in an unsupported language. File is not indexed.
0001 # - Geant4MakeRules_cxx
0002 # Sets the default make rules for a CXX build, specifically the
0003 # initialization of the compiler flags on a platform and compiler
0004 # dependent basis
0005 #
0006 #
0007 #-----------------------------------------------------------------------
0008 # function __configure_tls_models()
0009 # Set available thread local storage models. Valid for GNU,
0010 # Clang and Intel compilers. Adds an additional "auto"
0011 # dummy model to indicate that no flag should be added.
0012 #
0013 function(__configure_tls_models)
0014 # available models, default first
0015 set(_TLSMODELS initial-exec local-exec global-dynamic local-dynamic)
0016 foreach(_s ${_TLSMODELS})
0017 set(${_s}_TLSMODEL_FLAGS "-ftls-model=${_s}" PARENT_SCOPE)
0018 endforeach()
0019
0020 list(APPEND _TLSMODELS auto)
0021 set(auto_TLSMODEL_FLAGS "" PARENT_SCOPE)
0022
0023 set(TLSMODEL_IS_AVAILABLE ${_TLSMODELS} PARENT_SCOPE)
0024 endfunction()
0025
0026 #-----------------------------------------------------------------------
0027 # DEFAULT FLAG SETTING
0028 #-----------------------------------------------------------------------
0029 # GNU C++ or Clang/AppleClang Compiler on all(?) platforms
0030 if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
0031 # Warnings
0032 set(CMAKE_CXX_FLAGS_INIT "-W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow")
0033 # Use pipes rather than temp files
0034 set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -pipe")
0035 # Remove superfluous "unused argument" and "GL deprecation" "warnings" from Clang
0036 if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
0037 set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -Qunused-arguments -DGL_SILENCE_DEPRECATION")
0038 endif()
0039
0040 # Additional per-mode flags
0041 # Assist auto-vectorization in Release
0042 set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -fno-trapping-math -ftree-vectorize -fno-math-errno")
0043
0044 # Use Debug-safe optimization
0045 set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} -Og")
0046
0047 # Extra Geant4 modes
0048 # - Debug_FPE: Core Debug mode plus FPE)
0049 set(CMAKE_CXX_FLAGS_DEBUG_FPE_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} -DG4FPE_DEBUG")
0050
0051 # - TestRelease
0052 set(CMAKE_CXX_FLAGS_TESTRELEASE_INIT "-g -DG4DEBUG_VERBOSE -DG4FPE_DEBUG")
0053
0054 # - Full optimization plus debug info (basically -O3 -g)
0055 set(CMAKE_CXX_FLAGS_FULLRELWITHDEBINFO_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -g")
0056
0057 # - Multithreading
0058 __configure_tls_models()
0059 set(GEANT4_MULTITHREADED_CXX_FLAGS "-pthread")
0060 endif()
0061
0062 #-----------------------------------------------------------------------
0063 # MSVC - all (?) versions
0064 if(MSVC)
0065 # Hmm, WIN32-VC.gmk uses dashes, but cmake uses slashes, latter probably
0066 # best for native build.
0067 set(CMAKE_CXX_FLAGS_INIT "-GR -EHsc -Zm200 -nologo -D_CONSOLE -D_WIN32 -DWIN32 -DOS -DXPNET -D_CRT_SECURE_NO_DEPRECATE")
0068 set(CMAKE_CXX_FLAGS_DEBUG_INIT "-MDd -Od -Zi")
0069 set(CMAKE_CXX_FLAGS_RELEASE_INIT "-MD -Ox -DNDEBUG")
0070 set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-MD -Os -DNDEBUG")
0071 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-MD -O2 -Zi -DNDEBUG")
0072
0073 # Extra modes
0074 set(CMAKE_CXX_FLAGS_TESTRELEASE_INIT "-MDd -Zi -G4DEBUG_VERBOSE")
0075 endif()
0076
0077 #-----------------------------------------------------------------------
0078 # Intel C++ Compilers - all (?) platforms
0079 #
0080 # Sufficient id on all platforms?
0081 if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
0082 # Warnings
0083 set(CMAKE_CXX_FLAGS_INIT "-W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -fp-model precise -diag-disable=10441")
0084 # Use pipes rather than temp files
0085 set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -pipe")
0086
0087 set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
0088 set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
0089 set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
0090 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
0091
0092 # Extra modes
0093 set(CMAKE_CXX_FLAGS_TESTRELEASE_INIT "-g -G4DEBUG_VERBOSE")
0094
0095 # - Multithreading
0096 __configure_tls_models()
0097 set(GEANT4_MULTITHREADED_CXX_FLAGS "-pthread")
0098
0099 # Linker flags
0100 set(CMAKE_EXE_LINKER_FLAGS "-limf")
0101 endif()