forked from lucasjinreal/thor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·110 lines (84 loc) · 2.78 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
cmake_minimum_required(VERSION 3.5)
project(thor VERSION 1.3.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
option(USE_OPENCV "enable OpenCV in vis modules" ON)
option(USE_EIGEN "enable build with eigen" OFF)
option(USE_CV_EX "enable additional cv draw ability" OFF)
option(USE_PROTOBUF "enable protobuf related components." OFF)
option(USE_CURL "enable curl related components." OFF)
option(DEBUG "Enable debug mode, for develop" ON)
file(GLOB_RECURSE thor_SRCS "src/*.cpp" "src/*.cc")
file(GLOB_RECURSE thor_HEADERS "include/*.h" "include/*.hpp")
if (WIN32)
message(STATUS "Windows platform thor can only build with simple mode, will close EIGEN and CV_EX")
endif ()
include(GNUInstallDirs)
if (USE_CV_EX)
include_directories(/usr/include/freetype2/)
add_definitions(-DUSE_CV_EX)
endif ()
if (USE_EIGEN)
include_directories(/usr/include/eigen3)
add_definitions(-DUSE_EIGEN)
endif ()
if (USE_OPENCV)
find_package(OpenCV REQUIRED)
if (OpenCV_FOUND)
message(STATUS "Build with OpenCV")
add_definitions(-DUSE_OPENCV)
else ()
set(USE_OPENCV OFF)
message(STATUS "Can not found OpenCV, turned it off.")
endif ()
endif ()
if (USE_CURL)
find_package(CURL REQUIRED)
if (NOT CURL_FOUND)
set(USE_CURL OFF)
message(STATUS "Can not found curl, turned it off")
else ()
add_definitions(-DUSE_CURL)
endif ()
endif ()
if (USE_PROTOBUF)
find_package(Protobuf REQUIRED)
if (NOT PROTOBUF_FOUND)
set(USE_PROTOBUF OFF)
message(STATUS "protobuf not found, turned it off.")
else ()
add_definitions(-DUSE_PROTOBUF)
endif ()
endif ()
message(STATUS "OpenCV: " ${USE_OPENCV})
message(STATUS "Eigen: " ${USE_EIGEN})
message(STATUS "Protobuf: " ${USE_PROTOBUF})
message(STATUS "CV_EX: " ${USE_CV_EX})
message(STATUS "CURL: " ${USE_CURL})
add_library(thor SHARED ${thor_SRCS} ${thor_HEADERS})
add_library(thor_static STATIC ${thor_SRCS} ${thor_HEADERS})
if (USE_OPENCV)
target_link_libraries(thor ${OpenCV_LIBS})
endif ()
if (USE_PROTOBUF)
target_link_libraries(thor ${PROTOBUF_LIBRARIES})
endif ()
if (USE_CURL)
target_link_libraries(thor ${CURL_LIBRARIES})
endif ()
set_target_properties(
thor
PROPERTIES
PUBLIC_HEADER "${thor_HEADERS}")
set_target_properties(
thor_static
PROPERTIES
PUBLIC_HEADER "${thor_HEADERS}")
configure_file(thor.pc thor.pc @ONLY)
target_include_directories(thor PRIVATE .)
target_include_directories(thor_static PRIVATE .)
install(TARGETS thor thor_static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/thor)
install(FILES include/thor.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)