Skip to content
Snippets Groups Projects
Commit 7d4fb1cb authored by adrien-matta's avatar adrien-matta
Browse files

* Fixing compilation of NPS with new Root.cmake file

parent 87971338
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib") ...@@ -5,7 +5,7 @@ set(NPLIB "${NPTOOL}/NPLib")
set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") set(NPTOOL_INCLUDE_DIR "${NPLIB}/include")
set(NPTOOL_LIB_DIR "${NPLIB}/lib") set(NPTOOL_LIB_DIR "${NPLIB}/lib")
include("${NPLIB}/FindROOT.cmake") include("${NPLIB}/Root.cmake")
project (NPAnalysis) project (NPAnalysis)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
......
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
project(NPLib CXX) project(NPLib CXX)
set(CMAKE_BUILD_TYPE Release)
# Major change in the Core/Physics (affecting the detector/analysis/simulation) # Major change in the Core/Physics (affecting the detector/analysis/simulation)
set(NPLIB_VERSION_MAJOR 2) set(NPLIB_VERSION_MAJOR 2)
# Minor change in the Core/Physics (not affecting any other part) # Minor change in the Core/Physics (not affecting any other part)
...@@ -9,9 +11,6 @@ set(NPLIB_VERSION_MINOR 1) ...@@ -9,9 +11,6 @@ set(NPLIB_VERSION_MINOR 1)
set(NPLIB_VERSION_DETA 35) set(NPLIB_VERSION_DETA 35)
configure_file(Core/NPLibVersion.h.in Core/NPLibVersion.h @ONLY) configure_file(Core/NPLibVersion.h.in Core/NPLibVersion.h @ONLY)
set(CMAKE_BUILD_TYPE Release)
set(DETLIST ${ETLIST}) set(DETLIST ${ETLIST})
string(COMPARE EQUAL "${DETLIST}" "" rdet) string(COMPARE EQUAL "${DETLIST}" "" rdet)
...@@ -26,7 +25,6 @@ cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) ...@@ -26,7 +25,6 @@ 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 # This suppress the Up-to-Date message of file installed for cmake 3.1 and above
set(CMAKE_INSTALL_MESSAGE LAZY) set(CMAKE_INSTALL_MESSAGE LAZY)
message("${CMAKE_CXX_FLAGS}")
# look for Root # look for Root
include("Root.cmake") include("Root.cmake")
......
# - Find ROOT instalation
# This module tries to find the ROOT installation on your system.
# It tries to find the root-config script which gives you all the needed information.
# If the system variable LOCAL_ROOTSYS is set this is straight forward.
# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
# If you need an other path you should add this path to this varaible.
# The root-config script is then used to detect basically everything else.
# This module defines a number of key variables and macros.
# F.Uhlig@gsi.de (fairroot.gsi.de)
MESSAGE(STATUS "Looking for Root...")
SET(ROOT_CONFIG_SEARCHPATH
$ENV{ROOTSYS}/bin
/usr/bin
)
SET(ROOT_DEFINITIONS "")
SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS
${ROOT_CONFIG_SEARCHPATH}
NO_DEFAULT_PATH)
IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and LOCAL_ROOTSYS is not set. Please
set LOCAL_ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
subdirectory cmake/modules.")
ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE})
SET( ENV{LOCAL_ROOTSYS} ${test})
set( LOCAL_ROOTSYS ${test})
ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
IF (ROOT_CONFIG_EXECUTABLE)
SET(ROOT_FOUND FALSE)
EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
MESSAGE(STATUS "Looking for Root... - found $ENV{LOCAL_ROOTSYS}/bin/root")
MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ")
# we need at least version 5.00/00
IF (NOT ROOT_MIN_VERSION)
SET(ROOT_MIN_VERSION "5.00/00")
ENDIF (NOT ROOT_MIN_VERSION)
# now parse the parts of the user given version string into variables
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
# and now the version string given by qmake
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
IF (found_root_major_vers LESS 5)
MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
ENDIF (found_root_major_vers LESS 5)
# compute an overall version number which can be compared at once
MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
IF (found_vers LESS req_vers)
SET(ROOT_FOUND FALSE)
SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
ELSE (found_vers LESS req_vers)
SET(ROOT_FOUND TRUE)
ENDIF (found_vers LESS req_vers)
ENDIF (ROOT_CONFIG_EXECUTABLE)
IF (ROOT_FOUND)
# ask root-config for the library dir
# Set ROOT_LIBRARY_DIR
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
ARGS "--libdir"
OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
# ask root-config for the binary dir
EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
ARGS "--bindir"
OUTPUT_VARIABLE root_bins )
SET(ROOT_BINARY_DIR ${root_bins})
# ask root-config for the include dir
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
ARGS "--incdir"
OUTPUT_VARIABLE root_headers )
SET(ROOT_INCLUDE_DIR ${root_headers})
# CACHE INTERNAL "")
# ask root-config for the library varaibles
EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
# ARGS "--noldflags --noauxlibs --libs"
ARGS "--glibs"
OUTPUT_VARIABLE root_flags )
# STRING(REGEX MATCHALL "([^ ])+" root_libs_all ${root_flags})
# STRING(REGEX MATCHALL "-L([^ ])+" root_library ${root_flags})
# REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
SET(ROOT_LIBRARIES ${root_flags})
# Make variables changeble to the advanced user
MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
# Set ROOT_INCLUDES
SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
#######################################
#
# Check the executables of ROOT
# ( rootcint )
#
#######################################
FIND_PROGRAM(ROOT_CINT_EXECUTABLE
NAMES rootcint
PATHS ${ROOT_BINARY_DIR}
NO_DEFAULT_PATH
)
ENDIF (ROOT_FOUND)
...@@ -65,5 +65,8 @@ include_directories( ${ROOT_INCLUDE_DIR}) ...@@ -65,5 +65,8 @@ include_directories( ${ROOT_INCLUDE_DIR})
# Get the compilator flag from root to assure consistancy # Get the compilator flag from root to assure consistancy
exec_program(${NPTOOL_ROOT_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE NPTOOL_ROOT_CFLAGS ) exec_program(${NPTOOL_ROOT_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE NPTOOL_ROOT_CFLAGS )
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS_RELEASE} ${NPTOOL_ROOT_CFLAGS}") if(CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NPTOOL_ROOT_CFLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS_RELEASE} ${NPTOOL_ROOT_CFLAGS}")
endif()
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8)
#include("../NPLib/FindROOT.cmake") include(CheckCXXCompilerFlag)
include("../NPLib/Root.cmake")
project (NPSimulation) project (NPSimulation)
set (NPSIM_VERSION_MAJOR 2) set (NPSIM_VERSION_MAJOR 2)
set (NPSIM_VERSION_MINOR 0) set (NPSIM_VERSION_MINOR 0)
...@@ -8,6 +8,12 @@ set (NPSIM_VERSION_DETS 18) ...@@ -8,6 +8,12 @@ set (NPSIM_VERSION_DETS 18)
set(CMAKE_BUILD_TYPE Release) 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)
# Finding Geant 4 # Finding Geant 4
find_package(Geant4 REQUIRED ui_all vis_all) find_package(Geant4 REQUIRED ui_all vis_all)
message(${Geant4_USE_FILE}) message(${Geant4_USE_FILE})
...@@ -19,6 +25,40 @@ include(${NPLib_USE_FILE}) ...@@ -19,6 +25,40 @@ include(${NPLib_USE_FILE})
configure_file(Core/NPSimulationVersion.hh.in Core/NPSimulationVersion.hh @ONLY) configure_file(Core/NPSimulationVersion.hh.in Core/NPSimulationVersion.hh @ONLY)
# look for Root
include("../NPLib/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=libc++")
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}) set(DETLIST ${NPLib_DETECTOR_LIST})
string(COMPARE EQUAL "${DETLIST}" "" rdet) string(COMPARE EQUAL "${DETLIST}" "" rdet)
...@@ -28,15 +68,12 @@ if(rdet) ...@@ -28,15 +68,12 @@ if(rdet)
message("Building the following detectors ${DETLIST}") message("Building the following detectors ${DETLIST}")
endif() endif()
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# Add root to the link and include directories # Add root to the link and include directories
include_directories( ${ROOT_INCLUDE_DIR}) #include_directories( ${ROOT_INCLUDE_DIR})
link_directories( ${ROOT_LIBRARY_DIR}) #link_directories( ${ROOT_LIBRARY_DIR})
# Get the compilator flag from root to assure consistancy # Get the compilator flag from root to assure consistancy
EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} EXEC_PROGRAM(${NPTOOL_ROOT_CONFIG}
ARGS "--cflags" ARGS "--cflags"
OUTPUT_VARIABLE root_cflags ) OUTPUT_VARIABLE root_cflags )
......
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