-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
168 lines (113 loc) · 4.75 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# PROJECT CONFIGURATION
cmake_minimum_required(VERSION 3.1)
# set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.")
project(SDPRPP LANGUAGES C CXX VERSION 1.0.0)
set(CMAKE_BUILD_TYPE Release)
set(LIBRARY_TARGET_NAME "SDPRPP")
set(LIBRARY_TARGET_NAME_EXPORT "${LIBRARY_TARGET_NAME}Export")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # We require C++ 14
# Build the example
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?")
if(${CODE_PROFILING})
message(STATUS "Turning on code profiling for Essential Matrix Estimation")
endif()
# 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
# These next operations make use of the .cmake files shipped with Eigen3
find_package(BLAS REQUIRED)
# add_definitions(-march=native)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
# for SDP solver
find_package(SDPA REQUIRED)
include_directories(${SDPA_INCLUDE_DIRS})
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}_EXAMPLE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/example)
set(${LIBRARY_TARGET_NAME}_TESTS_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/test)
# Expose the include directories for this project
set(${LIBRARY_TARGET_NAME}_ADD_INCLUDES
${SDPA_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
set(${LIBRARY_TARGET_NAME}_CERT_INCLUDES
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}
${${LIBRARY_TARGET_NAME}_ADD_INCLUDES})
# Get the set of Essential header and source files
set(${LIBRARY_TARGET_NAME}_HDRS
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalTypes.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalUtils.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalLeft.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalRight.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalBoth.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/PrimalAdjugate.h
)
set(${LIBRARY_TARGET_NAME}_SRCS
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/PrimalUtils.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/PrimalLeft.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/PrimalRight.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/PrimalBoth.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/PrimalAdjugate.cpp
)
# 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}>
# only when using the lib from the install path
$<INSTALL_INTERFACE:include>
${${LIBRARY_TARGET_NAME}_ADD_INCLUDES}
)
target_link_libraries(${LIBRARY_TARGET_NAME}
PUBLIC
${BLAS_LIBRARIES}
${M}
${LAPACK}
sdpa
blas
lapack
dmumps_seq)
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}"
)
# building the example
if(BUILD_${LIBRARY_TARGET_NAME}_EXAMPLE)
message(STATUS "Adding tests to build")
add_subdirectory(example)
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)