forked from A2-Collaboration/acqu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt_ROOT6
123 lines (103 loc) · 5.01 KB
/
CMakeLists.txt_ROOT6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required (VERSION 2.6)
project(acqu)
############################ Register module ###################################
function(REGISTER_MODULE modname topdir linkdef)
# set sources
set(SRC ${CMAKE_SOURCE_DIR}/${topdir}/src/T*.cc)
set(SRC ${SRC} ${CMAKE_SOURCE_DIR}/${topdir}/src/*_t.cc)
set(SRC ${SRC} ${CMAKE_SOURCE_DIR}/${topdir}/src/*.cpp)
file(GLOB SRC ${SRC})
# set headers
set(HDR ${CMAKE_SOURCE_DIR}/${topdir}/src/T*.h)
set(HDR ${HDR} ${CMAKE_SOURCE_DIR}/${topdir}/src/*_t.h)
set(HDR ${HDR} ${CMAKE_SOURCE_DIR}/${topdir}/inc/*.h)
file(GLOB HDR ${HDR})
list(REMOVE_ITEM HDR "${CMAKE_SOURCE_DIR}/Tools/a2display/inc/LinkDef.h")
set(ALL_HDR ${ALL_HDR} ${HDR} PARENT_SCOPE)
foreach(head_file ${HDR})
get_filename_component(ph ${head_file} NAME)
set(HDR_PURE ${HDR_PURE} ${ph})
endforeach()
# create dictionary
get_directory_property(incdirs INCLUDE_DIRECTORIES)
set(includedirs)
foreach( d ${incdirs})
set(includedirs ${includedirs} -I${d})
endforeach()
add_custom_command(OUTPUT G__${modname}.cxx
COMMAND rootcling -f G__${modname}.cxx
-rml lib${modname}.so
-rmf lib${modname}.rootmap
-s lib${modname}.so
${includedirs}
${HDR_PURE}
${CMAKE_SOURCE_DIR}/${topdir}/src/${linkdef}
)
# create library
add_library(${modname} SHARED ${SRC} G__${modname}.cxx)
endfunction()
################################################################################
# check for in-source build, forbid it!
if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "\nIn-source build attempt detected!\n"
"Please create a new directory (e.g. build) and run `cmake ..`.\n"
"Also don't forget to delete the created CMakeCache.txt and CMakeFiles dir"
)
endif()
include (cmake/settings.cmake)
message(STATUS "*** Build Type: " ${CMAKE_BUILD_TYPE})
message(STATUS "*** Compiler Flags: " ${DEFAULT_COMPILE_FLAGS})
message(STATUS "*** Install libs to: " ${LIBRARY_OUTPUT_PATH})
message(STATUS "*** Install bin to: " ${EXECUTABLE_OUTPUT_PATH})
if(ACQU_DAQ)
message(STATUS "*** Building DAQ Part only (ACQU_DAQ=On)")
endif()
# configure ROOT
find_package(ROOT REQUIRED Core EG Gui Foam)
include(${ROOT_USE_FILE})
# check for external OSCAR
if(DEFINED ENV{OSCAR})
message(STATUS "Found external OSCAR in " $ENV{OSCAR})
include_directories($ENV{OSCAR}/include)
link_directories($ENV{OSCAR}/lib)
else()
message(FATAL_ERROR "External OSCAR not found!")
endif()
# includes
include_directories(${CMAKE_SOURCE_DIR}/acqu_core/AcquDAQ/src)
include_directories(${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src)
include_directories(${CMAKE_SOURCE_DIR}/acqu_core/AcquMC/src)
include_directories(${CMAKE_SOURCE_DIR}/acqu_user/root/src)
include_directories(${CMAKE_SOURCE_DIR}/Tools/a2display/inc)
# register all modules
REGISTER_MODULE(AcquDAQ acqu_core/AcquDAQ AcquDAQLinkDef.h)
REGISTER_MODULE(AcquRoot acqu_core/AcquRoot AcquRootLinkDef.h)
REGISTER_MODULE(AcquMC acqu_core/AcquMC MCLinkDef.h)
REGISTER_MODULE(UserRoot acqu_user/root UserLinkDef.h)
REGISTER_MODULE(a2display Tools/a2display ../inc/LinkDef.h)
# additional headers for installation
set(ALL_HDR ${ALL_HDR} ${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src/EnumConst.h)
set(ALL_HDR ${ALL_HDR} ${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src/DataFormats.h)
set(ALL_HDR ${ALL_HDR} ${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src/SwapBytes.h)
set(ALL_HDR ${ALL_HDR} ${CMAKE_SOURCE_DIR}/acqu_core/AcquDAQ/src/ModuleIndex.h)
set(ALL_HDR ${ALL_HDR} ${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src/MCBranchID.h)
# the following feature helps us to get rid of
# getenv("acqu"), getenv("acqu_sys"), getenv("ROOTSYS")
# because we define this variables now at "configure" time!
set(ACQU_CONFIG_FILE "${CMAKE_SOURCE_DIR}/acqu_core/AcquRoot/src/CMakeConfig.h")
configure_file("${CMAKE_SOURCE_DIR}/cmake/CMakeConfig.h.in" "${ACQU_CONFIG_FILE}")
# create executables
add_executable(AcquRoot-bin acqu_user/root/src/MainAcquRoot.cc)
set_target_properties(AcquRoot-bin PROPERTIES OUTPUT_NAME AcquRoot)
target_link_libraries(AcquRoot-bin AcquDAQ AcquRoot UserRoot a2display OSCAR ${ROOT_LIBRARIES})
add_executable(AcquMC-bin acqu_core/AcquMC/src/MainAcquMC.cc)
set_target_properties(AcquMC-bin PROPERTIES OUTPUT_NAME AcquMC)
target_link_libraries(AcquMC-bin AcquDAQ AcquRoot AcquMC ${ROOT_LIBRARIES})
# copy rootmaps, pcm, headers and scripts
add_custom_command(TARGET AcquRoot-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/*.rootmap ${PROJECT_BINARY_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/*.pcm ${PROJECT_BINARY_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/include
COMMAND ${CMAKE_COMMAND} -E copy ${ALL_HDR} ${PROJECT_BINARY_DIR}/include
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/acqu_core/scripts/AcquHierarchy ${PROJECT_BINARY_DIR}/bin
)