-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
118 lines (98 loc) · 3.67 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
cmake_minimum_required(VERSION 2.8)
project (NPDivs)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
option(EXE_LINK_SHARED
"Link the executable to the shared library, rather than the static." ON)
# version info
set(NPDIVS_MAJOR_VERSION 0)
set(NPDIVS_MINOR_VERSION 1)
set(NPDIVS_PATCH_VERSION 0)
set(NPDIVS_VERSION
${NPDIVS_MAJOR_VERSION}.${NPDIVS_MINOR_VERSION}.${NPDIVS_PATCH_VERSION})
# offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDE_DIR include CACHE PATH
"Installation directory for header files")
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR CMake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/CMake/NPDivs)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")
# make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
# find packages
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
find_package(Threads REQUIRED)
# let user override boost paths
set(BOOST_HEADERS CACHE PATH "Header directory for libraries")
set(BOOST_SYSTEM CACHE PATH "Path to Boost System library")
set(BOOST_THREAD CACHE PATH "Path to Boost Thread library")
set(BOOST_PROGRAM_OPTIONS CACHE PATH "Path to Boost Program Options library")
if(BOOST_HEADERS AND BOOST_SYSTEM AND BOOST_THREAD AND BOOST_PROGRAM_OPTIONS)
else()
find_package(Boost 1.35 COMPONENTS system thread program_options REQUIRED)
if(NOT BOOST_HEADERS)
set(BOOST_HEADERS ${Boost_INCLUDE_DIRS})
endif()
if (NOT BOOST_SYSTEM)
set(BOOST_SYSTEM ${Boost_SYSTEM_LIBRARY})
endif()
if (NOT BOOST_THREAD)
set(BOOST_THREAD ${Boost_THREAD_LIBRARY})
endif()
if (NOT BOOST_PROGRAM_OPTIONS)
set(BOOST_PROGRAM_OPTIONS ${Boost_PROGRAM_OPTIONS_LIBRARY})
endif()
endif()
include_directories(${BOOST_HEADERS})
find_package(PkgConfig REQUIRED)
pkg_check_modules(FLANN REQUIRED flann)
include_directories(${FLANN_INCLUDE_DIRS})
link_directories(${FLANN_LIBRARY_DIRS})
if(FLANN_CFLAGS)
add_definitions(${FLANN_CFLAGS})
endif(FLANN_CFLAGS)
# add subdirectories with actual content
add_subdirectory(np-divs)
add_subdirectory(test)
add_subdirectory(matlab)
add_subdirectory(wrappers)
################################################################################
## stuff for making NPDivsConfig.cmake
# add targets to build-tree export set
export(TARGETS np-divs np-divs_s npdivs
FILE "${PROJECT_BINARY_DIR}/NPDivsLibraryDepends.cmake")
# register package with cmake registry
export(PACKAGE NPDivs)
# create NPDivs{BuildTreeSettings,Config,ConfigVersion}.cmake
configure_file(NPDivsBuildTreeSettings.cmake.in
"${PROJECT_BINARY_DIR}/NPDivsBuildTreeSettings.cmake" @ONLY)
file(RELATIVE_PATH CONF_REL_INCLUDE_DIR
"${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
file(RELATIVE_PATH CONF_REL_LIB_DIR
"${INSTALL_CMAKE_DIR}" "${INSTALL_LIB_DIR}")
configure_file(NPDivsConfig.cmake.in
"${PROJECT_BINARY_DIR}/NPDivsConfig.cmake" @ONLY)
configure_file(NPDivsConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/NPDivsConfigVersion.cmake" @ONLY)
# install export set for use with the install-tree
install(EXPORT NPDivsLibraryDepends
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
install(
FILES "${CMAKE_BINARY_DIR}/NPDivsConfig.cmake"
"${CMAKE_BINARY_DIR}/NPDivsConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)