@@ -4,6 +4,16 @@ project(restG4)
4
4
message ("=============== ${PROJECT_NAME} ==============" )
5
5
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /../../cmake ${CMAKE_MODULE_PATH} )
6
6
7
+ if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} )
8
+ # this will only be accessed when build restG4 as a standalone package, not when building the framework
9
+ CMAKE_MINIMUM_REQUIRED (VERSION 3.5 )
10
+ find_package (REST REQUIRED )
11
+ string (FIND ${REST_LIBRARIES} "RestGeant4" REST_GEANT4_FOUND )
12
+ If (${REST_GEANT4_FOUND} EQUAL -1 )
13
+ message (SEND_ERROR "REST found but 'RestGeant4' library is not present. Please install REST with Geant4Lib" )
14
+ endif ()
15
+ endif ()
16
+
7
17
# Find ROOT
8
18
find_package (ROOT REQUIRED COMPONENTS RIO Geom )
9
19
execute_process (COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CFLAGS )
@@ -24,35 +34,24 @@ if (NOT EXISTS "${Geant4_INCLUDE_DIRS}/G4RunManagerFactory.hh")
24
34
add_definitions (-DWITHOUT_G4RunManagerFactory )
25
35
endif ()
26
36
27
- # Find REST
28
- if (NOT DEFINED REST_PATH )
29
- if (DEFINED ENV{REST_PATH} )
30
- set (REST_PATH $ENV{REST_PATH} )
31
- else ()
32
- message (FATAL_ERROR "ERROR ::: REST_PATH must be defined as an environment variable and point to REST install directory" )
33
- return ()
34
- endif ()
35
- endif ()
36
-
37
- if (NOT DEFINED rest_include_dirs )
38
- set (rest_include_dirs ${REST_PATH} /include )
39
- endif ()
40
-
41
37
if (NOT DEFINED CMAKE_INSTALL_PREFIX )
42
38
set (CMAKE_INSTALL_PREFIX ${REST_PATH} )
43
39
endif ()
44
- message (STATUS "Using REST_PATH: ${REST_PATH} " )
45
- message (STATUS "Using rest_include_dirs: ${rest_include_dirs} " )
40
+
46
41
message (STATUS "Package ${PROJECT_NAME} will be installed in ${CMAKE_INSTALL_PREFIX} " )
47
42
48
43
if (NOT CMAKE_CXX_FLAGS )
49
44
set (CMAKE_CXX_FLAGS " -std=c++1y" )
50
45
endif ()
51
46
52
47
# Set include and lib
53
- set (INCLUDE_DIRS ${PROJECT_SOURCE_DIR} /include ${ROOT_INCLUDE_DIRS} ${rest_include_dirs } ${Geant4_INCLUDE_DIR } )
48
+ set (INCLUDE_DIRS ${PROJECT_SOURCE_DIR} /include ${ROOT_INCLUDE_DIRS} ${Geant4_INCLUDE_DIR } ${REST_INCLUDE_DIRS } )
54
49
55
- set (LINK_LIBRARIES ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} RestGeant4 )
50
+ if (NOT ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} )
51
+ set (INCLUDE_DIRS ${INCLUDE_DIRS} ${rest_include_dirs} )
52
+ endif ()
53
+
54
+ set (LINK_LIBRARIES ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} RestFramework RestGeant4 )
56
55
string (STRIP "${LINK_LIBRARIES} " LINK_LIBRARIES )
57
56
58
57
file (GLOB sources ${PROJECT_SOURCE_DIR} /src/*.cxx )
@@ -77,5 +76,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac
77
76
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
78
77
install (TARGETS ${PROJECT_NAME} DESTINATION bin )
79
78
80
- set (package_added "${PROJECT_NAME} " )
81
- set (package_added ${package_added} PARENT_SCOPE )
79
+ if (NOT ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} )
80
+ set (package_added "${PROJECT_NAME} " )
81
+ set (package_added ${package_added} PARENT_SCOPE )
82
+ endif ()
0 commit comments