forked from PlutoUser/pluto6
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
103 lines (76 loc) · 3.62 KB
/
CMakeLists.txt
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
# CMakeLists.txt for event package. It creates a library with dictionary and a main program
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(pluto)
include(CTest)
include_directories(include ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
###########################################################
SET(PLUGIN_CLASSES "")
SET(PLUGIN_CLASSES_NAMES "")
SET(PLUGIN_COLLECTION "")
FUNCTION(addprefix var prefix)
##MESSAGE( STATUS "prefix: " ${prefix} )
SET(listVar "")
FOREACH(f ${ARGN})
LIST(APPEND listVar "${prefix}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION(addprefix)
FUNCTION(addsuffix var suffix)
SET(listVar "")
FOREACH(f ${ARGN})
LIST(APPEND listVar "${f}${suffix}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION(addsuffix)
add_subdirectory(plugins)
##MESSAGE( STATUS "PLUGIN_CLASSES: " ${PLUGIN_CLASSES} )
addsuffix(PHDRS ".h" ${PLUGIN_CLASSES})
addsuffix(PSRC ".cc" ${PLUGIN_CLASSES})
##MESSAGE( STATUS "PHDRS: " ${PHDRS} )
##MESSAGE( STATUS "PLUGIN_CLASSES_NAMES: " ${PLUGIN_CLASSES_NAMES} )
##MESSAGE( STATUS "PLUGIN_COLLECTION: " ${PLUGIN_COLLECTION} )
###########################################################
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Plugins.h)
FOREACH(f ${PHDRS})
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Plugins.h "\#include \"${f}\"\n")
ENDFOREACH(f)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Plugins.cc)
FOREACH(f ${PLUGIN_COLLECTION})
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Plugins.cc "\#include \"${f}\"\n")
ENDFOREACH(f)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/PluginLinkDef.h)
FOREACH(f ${PLUGIN_CLASSES_NAMES})
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/PluginLinkDef.h "\#pragma link C++ class ${f};\n")
ENDFOREACH(f)
###########################################################
file(GLOB SOURCES "src/*.cc")
SET(SOURCES ${SOURCES} ${PLUGIN_CLASSES})
#file(GLOB INCL_FILES RELATIVE "${CMAKE_SOURCE_DIR}" "include/*.h" )
file(GLOB INCL_FILES RELATIVE "${CMAKE_CURRENT_BINARY_DIR}" "include/*.h" )
SET(INCL_FILES ${INCL_FILES} ${PHDRS})
#MESSAGE( STATUS "INCL_FILES: " ${INCL_FILES} )
# You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
# - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
# - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
#list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{ROOTSYS}/etc/cmake)
#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
find_package(ROOT "6.00" REQUIRED COMPONENTS RIO Net EG)
if(ROOT_VERSION LESS 6.00)
message(FATAL_ERROR "The required ROOT version has to be at least 6.00, found " ${ROOT_VERSION})
endif()
message(STATUS "Found ROOT version: " ${ROOT_VERSION})
#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
include(${ROOT_USE_FILE})
##LIST(APPEND INCL_FILES ${PHDRS})
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
ROOT_GENERATE_DICTIONARY(G__Pluto ${INCL_FILES} LINKDEF PlutoLinkDef.h)
#---Create a shared library with geneated dictionary
add_library(Pluto SHARED ${SOURCES} G__Pluto.cxx ${CMAKE_CURRENT_BINARY_DIR}/Compiled.h)
target_link_libraries(Pluto ${ROOT_LIBRARIES})
#---Create a main program using the library
#add_executable(Main MainEvent.cxx)
#target_link_libraries(Main Event)
add_custom_target(Compiled.h)
add_custom_command(OUTPUT Compiled.h COMMAND echo char *date_string = \\\(char*\\\) \\\"\$\$\(date +\"%e %B %Y\"\)\\\" > ${CMAKE_CURRENT_BINARY_DIR}/Compiled.h DEPENDS G__Pluto.cxx ${SOURCES})
#add_custom_target(PluginLinkdef.h)