Skip to content
Snippets Groups Projects
Commit 67d02a8d authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Introducing NPTool_CMake_Preamble.cmake to mutualize the compiler

* setting
parent 8b5d86ae
No related branches found
No related tags found
No related merge requests found
......@@ -20,21 +20,8 @@ if(rdet)
message("Building the following detectors ${DETLIST}")
endif()
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# This suppress the Up-to-Date message of file installed for cmake 3.1 and above
set(CMAKE_INSTALL_MESSAGE LAZY)
# look for Root
include("ressources/CMake/Root.cmake")
# Check for user disabling of c++11 support
string(COMPARE EQUAL "${CPP11}" "no" nocpp11)
if(nocpp11)
message(" -> C++11 support disable")
endif()
# include the nptool standard CMake preamble
include("ressources/CMake/NPTool_CMake_Preamble.cmake")
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
......@@ -49,6 +36,7 @@ endif()
# If compiler is GCC active the color diagnostic
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*GNU.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
......
cmake_minimum_required (VERSION 2.8)
#Finding NPTool
set(NPTOOL "$ENV{NPTOOL}")
set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/ressources/CMake/Root.cmake")
include(CheckCXXCompilerFlag)
project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release)
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# This suppress the Up-to-Date message of file installed for cmake 3.1 and above
set(CMAKE_INSTALL_MESSAGE LAZY)
# Add root to the link and include directories
include_directories( ${ROOT_INCLUDE_DIR})
link_directories( ${ROOT_LIBRARY_DIR})
include_directories( ${NPTOOL_INCLUDE_DIR})
link_directories( ${NPTOOL_LIB_DIR})
# Check for user disabling of c++11 support
string(COMPARE EQUAL "${CPP11}" "no" nocpp11)
if(nocpp11)
message(" -> C++11 support disable")
endif()
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -undefined dynamic_lookup")
if( UNIX AND NOT APPLE )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
endif()
if( APPLE AND CLANG_VERSION_MAJOR VERSION_LESS 5 AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif()
# If compiler is GCC active the color diagnostic
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*GNU.*")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
# Adjust the compiler language flag
set(NOCPPFLAGS true)
if(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*11")
set(NOCPPFLAGS false)
elseif(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*0x")
set(NOCPPFLAGS false)
endif()
if(NOCPPFLAGS)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11 AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
endif()
if(COMPILER_SUPPORTS_CXX0X AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
endif()
#Finding NPTool
find_package(NPLib)
include(${NPLib_USE_FILE})
#include the nptool standard CMake preamble
include("${NPLIB}/ressources/CMake/NPTool_CMake_Preamble.cmake")
add_library(NPAnalysis SHARED Analysis.cxx)
target_link_libraries(NPAnalysis ${ROOT_LIBRARIES} -L${NPLIB}/lib -lNPCore -lNPPhysics -lNPInteractionCoordinates -lNPInitialConditions)
......@@ -9,6 +9,8 @@ get_filename_component(NPLib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(NPLib_USE_FILE "@CMAKE_BINARY_DIR@/NPLibConfig.cmake")
set(NPLib_INCLUDE_DIRS "@CMAKE_INCLUDE_OUTPUT_DIRECTORY@")
set(NPLib_DETECTOR_LIST "@DETLIST@")
set(NPTOOL "$ENV{NPTOOL}")
set(NPLIB "${NPTOOL}/NPLib")
include_directories("${NPLib_INCLUDE_DIRS}")
set(NPLib_LIBRARIES "-L@CMAKE_BINARY_DIR@/lib -lNPCore -lNPPhysics")
......
# Set usefull variable
set(NPTOOL "$ENV{NPTOOL}")
set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib")
# Look for Root
include("${NPLIB}/ressources/CMake/Root.cmake")
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# This suppress the Up-to-Date message of file installed for cmake 3.1 and above
set(CMAKE_INSTALL_MESSAGE LAZY)
# Check for user disabling of c++11 support
string(COMPARE EQUAL "${CPP11}" "no" nocpp11)
if(nocpp11)
message(" -> C++11 support disable")
endif()
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
if( UNIX AND NOT APPLE )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
endif()
if( APPLE AND CLANG_VERSION_MAJOR VERSION_LESS 5 AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif()
# If compiler is GCC active the color diagnostic
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*GNU.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
# Adjust the compiler language flag
set(NOCPPFLAGS true)
if(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*11")
set(NOCPPFLAGS false)
elseif(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*0x")
set(NOCPPFLAGS false)
endif()
if(NOCPPFLAGS)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11 AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
endif()
if(COMPILER_SUPPORTS_CXX0X AND NOT nocpp11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
endif()
......@@ -8,11 +8,12 @@ set (NPSIM_VERSION_DETS 18)
set(CMAKE_BUILD_TYPE Release)
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# Finding NPLib
find_package(NPLib)
include(${NPLib_USE_FILE})
# This suppress the Up-to-Date message of file installed for cmake 3.1 and above
set(CMAKE_INSTALL_MESSAGE LAZY)
#include the nptool standard CMake preamble
include("../NPLib/ressources/CMake/NPTool_CMake_Preamble.cmake")
# Finding Geant 4
find_package(Geant4 REQUIRED ui_all vis_all)
......@@ -33,54 +34,8 @@ message ("Geant4 found, Version : ${NPS_GEANT4_VERSION_MAJOR}.${NPS_GEANT4_VERSI
include(${Geant4_USE_FILE})
add_definitions(${Geant4_DEFINITIONS})
# Finding NPLib
find_package(NPLib)
include(${NPLib_USE_FILE})
configure_file(Core/NPSimulationVersion.hh.in Core/NPSimulationVersion.hh @ONLY)
# look for Root
include("../NPLib/ressources/CMake/Root.cmake")
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
if( UNIX AND NOT APPLE )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
endif()
endif()
# If compiler is GCC active the color diagnostic
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*GNU.*")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
# Adjust the compiler language flag
set(NOCPPFLAGS true)
if(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*11")
set(NOCPPFLAGS false)
elseif(${CMAKE_CXX_FLAGS} MATCHES ".*std=.*0x")
set(NOCPPFLAGS false)
endif()
if(NOCPPFLAGS)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
endif()
if(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
endif()
# Detector List
set(DETLIST ${NPLib_DETECTOR_LIST})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment