-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
151 lines (114 loc) · 4.12 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
#
# libieeep1788
#
# An implementation of the preliminary IEEE P1788 standard for
# interval arithmetic
#
#
# Copyright 2013 - 2015
#
# Marco Nehmeier (nehmeier@informatik.uni-wuerzburg.de)
# Department of Computer Science,
# University of Wuerzburg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# setting user defined build type
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE string "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
else()
set(CMAKE_BUILD_TYPE Release CACHE string "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
# minimum cmake version required to carry out the build
cmake_minimum_required(VERSION 2.8)
# gives the project a name.
project(libieeep1788)
set (P1788_VERSION_MAJOR 0)
set (P1788_VERSION_MINOR 1)
set (P1788_VERSION_PATCH 5)
configure_file (
"${PROJECT_SOURCE_DIR}/p1788/version.hpp.in"
"${PROJECT_BINARY_DIR}/p1788/version.hpp"
)
install(FILES "${PROJECT_BINARY_DIR}/p1788/version.hpp" DESTINATION "include/p1788/")
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_BINARY_DIR}")
## build with code coverage
#option(CODE_COVERAGE OFF)
#
#if(NOT CMAKE_COMPILER_IS_GNUCC OR NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(CODE_COVERAGE OFF)
#endif()
# activates c++11 extensions for g++ compiler.
add_definitions(-std=c++11)
# flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic")
# debug flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -DNDEBUG")
# release flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
# library flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# use custom modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
# find Boost
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.54 COMPONENTS unit_test_framework)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
# find MPFR
find_package(MPFR 3.1.2)
if(MPFR_FOUND)
include_directories(${MPFR_INCLUDE_DIRS})
endif()
#find GMP
find_package(GMP 6.0.0)
if(GMP_FOUND)
include_directories(${GMP_INCLUDE_DIRS})
endif()
# collect and install all header files
add_subdirectory(p1788)
# examples
add_subdirectory(examples)
# documentation
add_subdirectory(doc)
# tests
enable_testing()
#if(CODE_COVERAGE)
# # debug flags
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")
#
# # library flags
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
#endif(CODE_COVERAGE)
add_subdirectory(test)
#if(CODE_COVERAGE)
#
#ADD_CUSTOM_TARGET(coverage)
#ADD_CUSTOM_COMMAND(TARGET coverage
# COMMAND rm -rf coverage
# COMMAND mkdir -p coverage
# COMMAND lcov --directory . --zerocounters
# COMMAND lcov --capture --initial --directory . --output-file coverage/p1788_base.info
# COMMAND make --keep-going test
# COMMAND lcov --capture --directory . --output-file coverage/p1788_test.info
# COMMAND lcov -a coverage/p1788_base.info -a coverage/p1788_test.info -o coverage/p1788_coverage.info
# COMMAND lcov --remove coverage/p1788_coverage.info 'opt/*' '/usr/*' --output-file coverage/p1788_coverage.info
# COMMAND genhtml coverage/p1788_coverage.info --output-directory coverage
# COMMAND
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# )
#
#endif(CODE_COVERAGE)