-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from rest-for-physics/lobis-major-update
Partial changes from `restGeant4` parallel project
- Loading branch information
Showing
48 changed files
with
1,393 additions
and
1,324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,81 @@ | ||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
#Setup the project | ||
# Setup the project | ||
project(restG4) | ||
message("=============== restG4 ==============") | ||
|
||
message("=============== ${PROJECT_NAME} ==============") | ||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake ${CMAKE_MODULE_PATH}) | ||
|
||
#find REST | ||
IF(NOT DEFINED REST_PATH) | ||
IF(DEFINED ENV{REST_PATH}) | ||
set(REST_PATH $ENV{REST_PATH}) | ||
ELSE() | ||
message(FATAL_ERROR "ERROR ::: REST_PATH must be defined as an environment variable and point to REST install directory") | ||
return() | ||
ENDIF() | ||
ENDIF() | ||
set(CMAKE_INSTALL_PREFIX ${REST_PATH}) | ||
message(STATUS "Using REST PATH: " ${REST_PATH}) | ||
|
||
|
||
if(NOT CMAKE_CXX_FLAGS) | ||
SET(CMAKE_CXX_FLAGS "-std=c++1y") | ||
endif() | ||
|
||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
#Find Geant4 package, activating all available UI and Vis drivers by default | ||
#You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake / cmake - gui | ||
#to build a batch mode only executable | ||
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) | ||
if(WITH_GEANT4_UIVIS) | ||
find_package(Geant4 REQUIRED ui_all vis_all) | ||
else() | ||
find_package(Geant4 REQUIRED) | ||
endif() | ||
message ("-- Found Geant4 in version : ${Geant4_VERSION}" ) | ||
|
||
if(${Geant4_VERSION} VERSION_GREATER "10.2.9") | ||
add_definitions(-DG4104) | ||
endif() | ||
|
||
include(FindROOT) | ||
|
||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
#Set include and lib | ||
if(DEFINED rest_include_dirs) | ||
set(incdir ${PROJECT_SOURCE_DIR}/include ${ROOT_INCLUDE_DIRS} ${rest_include_dirs} ${Geant4_INCLUDE_DIR}) | ||
else() | ||
set(incdir ${PROJECT_SOURCE_DIR}/include ${ROOT_INCLUDE_DIRS} ${REST_PATH}/include ${Geant4_INCLUDE_DIR}) | ||
endif() | ||
|
||
|
||
set(lnklib ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} -lGui -lGeom -lGdml -lMinuit RestGeant4 ) | ||
string(STRIP "${lnklib}" lnklib) | ||
|
||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
#Locate sources and headers for this project | ||
# | ||
include(${Geant4_USE_FILE}) | ||
include_directories(${incdir}) | ||
# Find ROOT | ||
find_package(ROOT REQUIRED COMPONENTS RIO Geom) | ||
execute_process(COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CFLAGS) | ||
string(STRIP ${ROOT_CFLAGS} ROOT_CFLAGS) | ||
message(STATUS "-- Found ROOT version: ${ROOT_VERSION} with compilation flags: ${ROOT_CFLAGS} and libraries: ${ROOT_LIBRARIES}") | ||
|
||
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) | ||
# Geant4 was depending on detector that was depending on Garfield ... | ||
#file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh ${Garfield_INCLUDE_DIRS}/*.hh ) | ||
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh ) | ||
# Find Geant4 | ||
find_package(Geant4 REQUIRED ui_all vis_all) | ||
include(${Geant4_USE_FILE}) | ||
message("-- Found Geant4 version: ${Geant4_VERSION}") | ||
|
||
if (${Geant4_VERSION} VERSION_GREATER "10.2.9") | ||
add_definitions(-DG4104) | ||
endif () | ||
|
||
# Fix to allow compatibility with older Geant4 versions that don't have G4RunManagerFactory | ||
if (NOT EXISTS "${Geant4_INCLUDE_DIRS}/G4RunManagerFactory.hh") | ||
add_definitions(-DWITHOUT_G4RunManagerFactory) | ||
endif () | ||
|
||
# Find REST | ||
if (NOT DEFINED REST_PATH) | ||
if (DEFINED ENV{REST_PATH}) | ||
set(REST_PATH $ENV{REST_PATH}) | ||
else () | ||
message(FATAL_ERROR "ERROR ::: REST_PATH must be defined as an environment variable and point to REST install directory") | ||
return() | ||
endif () | ||
endif () | ||
|
||
if (NOT DEFINED rest_include_dirs) | ||
set(rest_include_dirs ${REST_PATH}/include) | ||
endif () | ||
|
||
if (NOT DEFINED CMAKE_INSTALL_PREFIX) | ||
set(CMAKE_INSTALL_PREFIX ${REST_PATH}) | ||
endif () | ||
message(STATUS "Using REST_PATH: ${REST_PATH}") | ||
message(STATUS "Using rest_include_dirs: ${rest_include_dirs}") | ||
message(STATUS "Package ${PROJECT_NAME} will be installed in ${CMAKE_INSTALL_PREFIX}") | ||
|
||
if (NOT CMAKE_CXX_FLAGS) | ||
set(CMAKE_CXX_FLAGS " -std=c++1y") | ||
endif () | ||
|
||
# Set include and lib | ||
set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include ${ROOT_INCLUDE_DIRS} ${rest_include_dirs} ${Geant4_INCLUDE_DIR}) | ||
|
||
set(LINK_LIBRARIES ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} -lGui -lGeom -lGdml -lMinuit RestGeant4) | ||
string(STRIP "${LINK_LIBRARIES}" LINK_LIBRARIES) | ||
|
||
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cxx) | ||
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h) | ||
|
||
#---------------------------------------------------------------------------- | ||
# Add the executable, and link it to the Geant4 libraries | ||
## | ||
#message( STATUS "lnklib G4: ${lnklib}" ) | ||
#message( STATUS "sources G4: ${sources}" ) | ||
#message( STATUS "headers G4: ${headers}" ) | ||
add_executable(restG4 restG4.cc ${sources} ${headers}) | ||
target_link_libraries(restG4 ${lnklib}) | ||
|
||
|
||
#---------------------------------------------------------------------------- | ||
# Copy all scripts to the build directory, i.e. the directory in which we | ||
# build sphereSimLab. This is so that we can run the executable directly because it | ||
# relies on these scripts being in the current working directory. | ||
|
||
install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/examples | ||
DESTINATION . | ||
COMPONENT install | ||
) | ||
|
||
install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac | ||
DESTINATION macros | ||
COMPONENT install | ||
) | ||
|
||
#---------------------------------------------------------------------------- | ||
add_executable(${PROJECT_NAME} restG4.cxx ${sources} ${headers}) | ||
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES}) | ||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${INCLUDE_DIRS}) | ||
|
||
# Copy scripts to the build directory | ||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/examples | ||
DESTINATION . | ||
COMPONENT install | ||
) | ||
|
||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac | ||
DESTINATION macros | ||
COMPONENT install | ||
) | ||
|
||
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX | ||
# | ||
install(TARGETS restG4 DESTINATION bin) | ||
install(TARGETS ${PROJECT_NAME} DESTINATION bin) | ||
|
||
set(package_added "restG4") | ||
set(package_added ${package_added} PARENT_SCOPE) | ||
set(package_added "${PROJECT_NAME} ") | ||
set(package_added ${package_added} PARENT_SCOPE) |
Oops, something went wrong.