-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
136 lines (104 loc) · 4.06 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.10)
project(ublarcvapp VERSION 1.1.0)
#---Install location by default is in the build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "${CMAKE_BUILD_DIR}" FORCE )
endif()
# CFLAGS
SET(CMAKE_C_FLAGS "-std=gnu99 -pedantic -fPIC -pedantic -fopenmp -mtune=native")
SET(CMAKE_CXX_FLAGS "-std=c++11 -Wall -fPIC -pedantic -fopenmp -mtune=native")
## Dependencies
#---CERN ROOT (required)
find_package(ROOT CONFIG REQUIRED)
#---LArCV (required)
set( larcv_DIR "$ENV{LARCV_LIBDIR}/cmake/larcv")
find_package( larcv REQUIRED )
# -- json header included in larcv
set(LARCV_JSON_INCLUDE_DIR "$ENV{LARCV_BASEDIR}/extern/json/single_include")
#---OPENCV (optional)
if (USE_OPENCV)
set(OpenCV_DIR $ENV{OPENCV_LIBDIR}/../share/OpenCV)
find_package(OpenCV REQUIRED)
if (NOT OpenCV_FOUND)
message("OpenCV NOT FOUND")
set(USE_OPENCV 0)
endif()
#message("OpenCV FOUND")
else()
message("OpenCV not activated")
endif()
#---larbys GEO2D
# use it if env variables defined
if (DEFINED ENV{GEO2D_BASEDIR})
set(LARCV_USE_GEO2D 1)
# unless explicitly told no
if (DEFINED ENV{USE_GEO2D} AND NOT $USE_GEO2D)
set(LARCV_USE_GEO2D 0)
message("DISABLING modules that need Geo2D")
else()
file( GLOB GEO2D_LIBS "$ENV{GEO2D_LIBDIR}/*.so" )
set( GEO2D_INC_DIR "$ENV{GEO2D_INCDIR}" )
set( GEO2D_LIB_DIR "$ENV{GEO2D_LIBDIR}" )
endif()
else()
set(LARCV_USE_GEO2D 0)
message("DISABLING modules needing Geo2D")
endif()
#---Eigen3
find_package(Eigen3 REQUIRED)
#---LArLite
set( LARLITE_INC_DIRS "$ENV{LARLITE_COREDIR}" "$ENV{LARLITE_BASEDIR}" "$ENV{LARLITE_USERDEVDIR}" "$ENV{LARLITE_BASEDIR}/../" )
set( LARLITE_LIB_DIR "$ENV{LARLITE_LIBDIR}" )
set( HAS_LARLITE 1 )
file( GLOB LARLITE_LIBS "$ENV{LARLITE_LIBDIR}/libLArLite*.so" )
#---LArOpenCV
set( LAROPENCV_INC_DIR "$ENV{LAROPENCV_BASEDIR}" )
set( LAROPENCV_LIB_DIR "$ENV{LARLITE_LIBDIR}" )
file( GLOB LAROPENCV_LIBS "$ENV{LARLITE_LIBDIR}/libLArOpenCV_*.so" )
#---Cilantro
set( cilantro_DIR $ENV{CILANTRO_LIB_DIR} )
find_package( cilantro REQUIRED )
#---Boost
find_package( Boost 1.65 COMPONENTS graph program_options )
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
if (Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
message(STATUS "Using boost include dirs: ${Boost_INCLUDE_DIRS}")
message(STATUS "Using boost library dirs: ${Boost_LIBRARY_DIRS}")
message(STATUS "Using boost libraries: ${Boost_LIBRARIES}")
message(STATUS "Using boost thread library: ${Boost_THREAD_LIBRARY}")
link_directories(${Boost_LIBRARY_DIRS})
endif (Boost_FOUND)
#INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
#--- glog
#find_package(glog REQUIRED)
## Setup
#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
include(${ROOT_USE_FILE})
#---Define Variables for subdirectory cmakelists
set(UBLARCVAPP_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
## Add Source
#---Add base of source
add_subdirectory(ublarcvapp)
#---Configuration export
include(CMakePackageConfigHelpers)
set(UBLARCVAPP_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(UBLARCVAPP_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib")
set(TARGETS_EXPORT_NAME "ublarcvappTargets")
configure_package_config_file("cmake/Config.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/ublarcvappConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/ublarcvapp"
PATH_VARS UBLARCVAPP_INCLUDE_DIR UBLARCVAPP_LIBRARY_DIR UBLARCVAPP_BASE_DIR)
write_basic_package_version_file("${CMAKE_BINARY_DIR}/cmake/ublarcvappConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
## Export Targets
#---Create info to include LArCV in other cmake files
install(EXPORT ublarcvapp
FILE ublarcvappTargets.cmake
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/ublarcvapp")
#---Create info to include LArCV in other cmake files
install(FILES "${CMAKE_BINARY_DIR}/cmake/ublarcvappConfig.cmake"
"${CMAKE_BINARY_DIR}/cmake/ublarcvappConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/ublarcvapp")