-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
145 lines (94 loc) · 4.22 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
# PROJECT CONFIGURATION
cmake_minimum_required(VERSION 3.1)
project(OptTwoPlanarTriangulation LANGUAGES C CXX VERSION 1.0.0)
set(LIBRARY_TARGET_NAME "OptTwoPlanarTriangulation")
set(LIBRARY_TARGET_NAME_EXPORT "${LIBRARY_TARGET_NAME}Export")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # We require C++ 14
# set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.")
set(CMAKE_BUILD_TYPE Release)
# set(CMAKE_CXX_FLAGS_DEBUG "-g -O3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# build the examples
set(BUILD_${LIBRARY_TARGET_NAME}_EXAMPLE ON)
# build the tests
set(BUILD_${LIBRARY_TARGET_NAME}_TESTS ON)
# Build type
# Directory for built libraries
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib CACHE PATH "The directory in which to place libraries built by this project")
# Directory for built executables
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "The directory in which to place executables built by this project")
# BUILD CONFIGURATIONS
option(CMAKE_VERBOSE_MAKEFILE "Generate verbose makefiles?" OFF)
set(CODE_PROFILING OFF CACHE BOOL "Turn on code profiling?")
# Add the .cmake files that ship with Eigen3 to the CMake module path (useful for finding other stuff)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" CACHE STRING "The CMake module path used for this project")
# FIND EIGEN3
set( ENV{EIGEN3_ROOT_DIR} ${CMAKE_SOURCE_DIR}/eigen)
find_package(Eigen3 3.3 REQUIRED)
if(EIGEN3_FOUND)
message(STATUS "Found Eigen3 library (version ${EIGEN3_VERSION_STRING})")
message(STATUS "Eigen3 include directory: ${EIGEN3_INCLUDE_DIR}\n")
else()
message(STATUS "Eigen library not found!")
endif()
# FIND ADDITIONAL LIBRARIES
ADD_DEFINITIONS ( -DPQXX_HIDE_EXP_OPTIONAL )
set(${LIBRARY_TARGET_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(${LIBRARY_TARGET_NAME}_SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(${LIBRARY_TARGET_NAME}_EXAMPLES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/examples)
set(${LIBRARY_TARGET_NAME}_TESTS_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/test)
# Expose the include directories for this project
set(${LIBRARY_TARGET_NAME}_ADD_INCLUDES ${EIGEN3_INCLUDE_DIR} )
set(${LIBRARY_TARGET_NAME}_CERT_INCLUDES ${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS} ${${LIBRARY_TARGET_NAME}_ADD_INCLUDES})
# Get the set of header and source files
set(${LIBRARY_TARGET_NAME}_HDRS
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/TwoViewPlanarTypes.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/TwoViewPlanarUtils.h
# fast solver
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/TwoViewPlanarDual.h
# Certifier
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/TwoViewPlanarCert.h
)
set(${LIBRARY_TARGET_NAME}_SRCS
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/TwoViewPlanarUtils.cpp
# fast solver
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/TwoViewPlanarDual.cpp
# Certifier
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/TwoViewPlanarCert.cpp
)
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode\n")
# Build the Essential library
add_library(${LIBRARY_TARGET_NAME} ${${LIBRARY_TARGET_NAME}_HDRS} ${${LIBRARY_TARGET_NAME}_SRCS} )
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC
# only when building from the source tree
$<BUILD_INTERFACE:${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}>
$<INSTALL_INTERFACE:include>
${${LIBRARY_TARGET_NAME}_ADD_INCLUDES}
)
target_link_libraries(${LIBRARY_TARGET_NAME})
if(${CODE_PROFILING})
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES COMPILE_FLAGS "-pg -g" LINK_FLAGS "-pg -g")
endif()
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${LIBRARY_TARGET_NAME_EXPORT}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
INCLUDES DESTINATION "include"
PUBLIC_HEADER DESTINATION "include/${LIBRARY_TARGET_NAME}"
)
# Build the example executable
IF(BUILD_${LIBRARY_TARGET_NAME}_EXAMPLE)
message(STATUS "Adding examples to build")
add_subdirectory(examples)
endif()
# building the tests
if(BUILD_${LIBRARY_TARGET_NAME}_TESTS)
message(STATUS "Adding tests to build")
add_subdirectory(test)
endif()
# Install
include(cmake/setup_installation.cmake)