-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
105 lines (87 loc) · 4.41 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
# --------------------------------------------------------------------------- #
# Author: Joey Dumont <joey.dumont@gmail.com> #
# Date: 2015-09-02 #
# Description: CMake compilation instructions. #
# License: CC0 - Public Domain. #
# #
# This file is part of the Zernike library. It is thus freely available and #
# infinitely modifiable and copyable. As it is with such products, it comes #
# with absolutely no warranty. It might even have bugs (!). If so, feel free #
# to drop a line at the email address above, or visit: #
# https://github.com/valandil/zernike #
# ----------------------------------------------------------------------------#
# ----------------------------------------------------------------- #
# -- Name and version of library -- #
# ----------------------------------------------------------------- #
project(Zernike)
set (Zernike_VERSION_MAJOR 1)
set (Zernike_VERSION_MINOR 1)
set (Zernike_VERSION_RELEASE 0)
# ----------------------------------------------------------------- #
# -- Configuration and Dependencies -- #
# ----------------------------------------------------------------- #
# -- CMake version and installation directory.
cmake_minimum_required(VERSION 2.8)
# -- Default installation directory.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX /usr)
endif()
# -- Search path for CMake modules.
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
# -- Required dependency: Boost.
find_package(Boost 1.48.0 REQUIRED)
include_directories(${BOOST_INCLUDE_DIRS})
SET (LIBS ${LIBS} ${BOOST_LIBRARIES})
# -- Compiler config.
# Configuration for the GCC compiler.
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -pg -g -Wall -march=native -std=c++11")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -pg -g -Wall -march=native")
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c++11")
endif()
# ----------------------------------------------------------------- #
# -- Compilation Instructions -- #
# ----------------------------------------------------------------- #
# -- Included files
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include INC_LIST)
# -- Source files
aux_source_directory (${CMAKE_CURRENT_SOURCE_DIR}/src SRC_LIST)
# -- Build a shared library
add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
target_compile_definitions(${PROJECT_NAME} PRIVATE -DZERNIKE_EXPORTS)
# Define the properties of the library to
# be built (version and other stuff).
set_target_properties (
${PROJECT_NAME}
PROPERTIES
VERSION ${Zernike_VERSION_MAJOR}.${Zernike_VERSION_MINOR}.${Zernike_VERSION_RELEASE}
SOVERSION ${Zernike_VERSION_MAJOR}.${Zernike_VERSION_MINOR}.${Zernike_VERSION_RELEASE}
)
# Link dependencies
target_link_libraries (${PROJECT_NAME} ${LIBS})
# Install directories
install (TARGETS ${PROJECT_NAME} DESTINATION lib)
install (DIRECTORY include/ DESTINATION include)
# ----------------------------------------------------------------- #
# -- Packaging Instructions -- #
# ----------------------------------------------------------------- #
# Configure and install the pkg-config file.
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pkg/Zernike.pc.in
${CMAKE_CURRENT_BINARY_DIR}/pkg/Zernike.pc @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/pkg/Zernike.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/)
endif(PKG_CONFIG_FOUND)
# Install the CMake Find Modules.
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/Zernike)
# ----------------------------------------------------------------- #
# -- Unit Testing -- #
# ----------------------------------------------------------------- #
include(CTest)
add_subdirectory(tests)