-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (120 loc) · 5.51 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
##---------------------------------------------------------------------------------------------------------------------
## BEAR
##---------------------------------------------------------------------------------------------------------------------
## Copyright 2020 ViGUS University of Seville
##---------------------------------------------------------------------------------------------------------------------
## Permission is hereby granted, free of charge, to any person obtaining a copy of this software
## and associated documentation files (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge, publish, distribute,
## sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in all copies or substantial
## portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
## BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
## OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##---------------------------------------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
PROJECT(bear VERSION 0.1 LANGUAGES C CXX)
#########################################
###### General config ######
#########################################
option(BUILD_EXAMPLES "Compile examples" ON)
#########################################
###### Loading 3rd party libraries ######
#########################################
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE )
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH})
#########################################
###### Library ######
#########################################
file(GLOB_RECURSE BEAR_HEADERS "include/*.h" "include/*.inl")
file(GLOB_RECURSE BEAR_SOURCES "src/*.cpp" "src/*.c")
add_library(${PROJECT_NAME} SHARED ${BEAR_SOURCES} ${BEAR_HEADERS})
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C)
## Load OpenCV
find_package(OpenCV)
if(${OpenCV_FOUND})
MESSAGE( STATUS "OpenCV FOUND")
target_compile_definitions(${PROJECT_NAME} PUBLIC "BEAR_USE_OpenCV")
target_include_directories(${PROJECT_NAME} PUBLIC ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${OpenCV_LIBRARIES})
endif(${OpenCV_FOUND})
## Load Eigen
find_package(Eigen3 REQUIRED)
if(${Eigen3_FOUND})
MESSAGE( STATUS "Eigen FOUND")
target_compile_definitions(${PROJECT_NAME} PUBLIC "BEAR_USE_EIGEN3")
target_include_directories(${PROJECT_NAME} PUBLIC "/usr/include/eigen3")
endif(${Eigen3_FOUND})
#########################################
###### Documentation ######
#########################################
# find_package(Doxygen)
# if(DOXYGEN_FOUND)
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
# add_custom_target( doc_bear
# ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
# COMMENT "Generating API documentation with Doxygen" VERBATIM )
# endif(DOXYGEN_FOUND)
#########################################
###### Examples ######
#########################################
if(${BUILD_EXAMPLES})
add_subdirectory(examples)
endif()
#########################################
###### INSTALL ######
#########################################
include(CMakePackageConfigHelpers)
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
install(TARGETS bear
EXPORT bearTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX}
)
write_basic_package_version_file(
bearConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
# This installs the include folder
install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.inl")
export(TARGETS bear NAMESPACE bear:: FILE bear.cmake)
# This generates bearTargets.cmake
install(EXPORT bearTargets
FILE bearTargets.cmake
NAMESPACE bear::
DESTINATION lib/cmake/${PROJECT_NAME}
)
configure_file("${CMAKE_MODULE_PATH}/bearConfig.cmake.in" bearConfig.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bearConfig.cmake"
DESTINATION lib/cmake/bear
)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()