-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
115 lines (100 loc) · 4.33 KB
/
CMakeLists.txt
File metadata and controls
115 lines (100 loc) · 4.33 KB
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
#*************************************************************************
# CMakeLists.txt -- This file is part of edp. *
# *
# Author: Ivo Filot <[email protected]> *
# *
# edp is free software: you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published *
# by the Free Software Foundation, either version 3 of the License, *
# or (at your option) any later version. *
# *
# edp is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty *
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
# See the GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program. If not, see http://www.gnu.org/licenses/. *
# *
#*************************************************************************/
# set minimum cmake requirements
cmake_minimum_required(VERSION 2.8.12)
project (edp)
# add custom directory to look for .cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules )
# prepare configuration file
SET(VERSION_MAJOR "2")
SET(VERSION_MINOR "0")
SET(VERSION_MICRO "3")
configure_file(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/config.h @ONLY)
if(EXISTS "${CMAKE_SOURCE_DIR}/config.h")
MESSAGE("[USER] Creating ${CMAKE_SOURCE_DIR}/config.h from ${CMAKE_SOURCE_DIR}/config.h.in")
else()
MESSAGE("[USER] Could not find configuration file in ${CMAKE_SOURCE_DIR}!")
endif()
# Enable release build
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# add OS specific
if(APPLE)
add_definitions(-D_APPLE)
SET(BOOST_INCLUDEDIR "/usr/local/include")
SET(BOOST_LIBRARYDIR "/usr/local/lib")
else()
SET(BOOST_INCLUDEDIR "/usr/include")
SET(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")
endif()
find_package(OpenMP)
if (OPENMP_FOUND)
option(HAS_OPENMP "OpenMP enabled" ON)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# set Boost
set (Boost_NO_SYSTEM_PATHS ON)
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_RUNTIME OFF)
set (BOOST_ALL_DYN_LINK OFF)
# Include libraries
find_package(PkgConfig REQUIRED)
find_package(Boost COMPONENTS regex iostreams filesystem system REQUIRED)
find_package(CPPUNIT REQUIRED) # for unit tests
pkg_check_modules(TCLAP tclap REQUIRED)
pkg_check_modules(CAIRO cairo REQUIRED)
pkg_check_modules(EIGEN eigen3 REQUIRED)
# Set include folders
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${EIGEN_INCLUDE_DIRS}
${TCLAP_INCLUDE_DIR}
${CAIRO_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${CPPUNIT_INCLUDE_DIR})
# Add sources
file(GLOB SOURCES "*.cpp")
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/edp.cpp)
add_library(edpsources STATIC ${SOURCES})
add_executable(edp ${CMAKE_CURRENT_SOURCE_DIR}/edp.cpp)
# Set c++17 and use march=native
add_definitions(-std=c++17 -march=native)
# Link libraries
target_link_libraries(edp
edpsources
${Boost_LIBRARIES}
${CAIRO_LIBRARIES})
if(NOT DISABLE_TEST)
message("[USER] Performing unit tests")
enable_testing ()
add_subdirectory("test")
else()
message("[USER] Testing routine disabled")
endif()
###
# Installing
##
install (TARGETS edp DESTINATION bin)