-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
113 lines (95 loc) · 3.73 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
cmake_minimum_required(VERSION 3.8)
### Hunter snapshot that will be used ###
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.23.33.tar.gz"
SHA1 "acbf4b9b77b5a0160adc1da1cdda35f64b14196a"
LOCAL
)
#include("cmake/config.cmake")
#set(HUNTER_KEEP_PACKAGE_SOURCES NO)
set(HUNTER_STATUS_DEBUG ON) # Remove in the future
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
project(randomSlither)
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#######################################
# Dependencies for the main library
#######################################
# Required : Boost - Move python interface to pybind11
set(BUILD_SHARED_LIBS ON)
#add_definitions(-DBOOST_ALL_NO_LIB=1)
#set(Boost_USE_STATIC_LIBS OFF)
#set(BUILD_SHARED_LIBS)
hunter_add_package(Boost COMPONENTS program_options serialization)
find_package(Boost CONFIG REQUIRED program_options serialization)
#set_target_properties(Boost::serialization PROPERTIES POSITION_INDEPENDENT_CODE TRUE) # Adding -fPIC to boost
# Required : Opencv
find_package( OpenCV CONFIG REQUIRED)
# Optional OpenMP
find_package(OpenMP)
# For the library
set(SOURCE_FILES
source/Classification.cpp
source/CommandLineParser.cpp
source/CumulativeNormalDistribution.cpp
source/DataPointCollection.cpp
#demo/source/DensityEstimation.cpp
source/dibCodec.cpp
source/FeatureResponseFunctions.cpp
source/FloydWarshall.cpp
source/Graphics.cpp
source/Platform.cpp
source/PlotCanvas.cpp
#demo/source/Regression.cpp
#demo/source/SemiSupervisedClassification.cpp
source/StatisticsAggregators.cpp)
#######################################
# Build the library
#######################################
add_library(Slither STATIC ${SOURCE_FILES})
# Add related includes
target_include_directories(Slither PUBLIC lib)
target_include_directories(Slither PUBLIC source)
target_include_directories(Slither PUBLIC Boost::serialization)
# Link related libs
target_link_libraries(Slither PUBLIC ${OpenCV_LIBS})
target_link_libraries(Slither PUBLIC Boost::serialization)
target_link_libraries(Slither PUBLIC ${Boost_SERIALIZATION_LIBRARIES})
set_target_properties(Slither PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)
# Adding definitions for OPENMP
if(NOT TARGET OpenMP::OpenMP_CXX)
message("Linking OpenMP stuff with old school style")
find_package(Threads REQUIRED)
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
set_property(TARGET OpenMP::OpenMP_CXX
PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS})
# Only works if the same flag is passed to the linker; use CMake 3.9+ otherwise (Intel, AppleClang)
set_property(TARGET OpenMP::OpenMP_CXX
PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads)
else()
message("Linking OpenMP stuff the new way")
endif()
target_link_libraries(Slither PUBLIC OpenMP::OpenMP_CXX)
#######################################
# Build the Standalone executable
#######################################
add_executable(cppSlither source/main.cpp)
# Linking and including
target_link_libraries(cppSlither PUBLIC Slither)
target_link_libraries(cppSlither PUBLIC Boost::program_options)
target_link_libraries(Slither PUBLIC ${Boost_PROGRAM_OPTIONS_LIBRARIES})
set_target_properties(cppSlither PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)
#######################################
# Build the Python Wrapper
#######################################
# First --> Python requirements
hunter_add_package(pybind11)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(pySlither SHARED pyWrapper/wrapper.cpp)
target_link_libraries(pySlither PRIVATE Slither)