-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
140 lines (122 loc) · 4.86 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
#
# Copyright 2013 Computer Graphics Group, RWTH Aachen University
# Author: Hans-Christian Ebke <[email protected]>
#
# This file is part of QEx.
#
# QEx 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.
#
# QEx 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 QEx. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required (VERSION 2.6)
# Only set project name if not build from within another project.
if("${PROJECT_NAME}" STREQUAL "")
project (QEx)
endif()
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package (OpenMesh REQUIRED)
set (SOURCES "")
set (INCLUDE_DIRS "")
set (LIBRARIES "")
set (LIBRARY_DIRS "")
list (APPEND SOURCES interfaces/c/qex.cc src/predicates.c src/MeshExtractor.cc)
list (APPEND INCLUDE_DIRS ${OPENMESH_INCLUDE_DIRS})
list (APPEND LIBRARIES ${OPENMESH_LIBRARIES})
include_directories (
${CMAKE_SOURCE_DIR}/interfaces/c
${INCLUDE_DIRS}
)
link_directories (
${CMAKE_BINARY_DIR}
${LIBRARY_DIRS}
)
add_library (QEx SHARED ${SOURCES})
add_library (QExStatic STATIC ${SOURCES})
target_link_libraries (QEx ${LIBRARIES})
target_link_libraries (QExStatic ${LIBRARIES})
#
# In order for the exact predicates to work the compiler
# must not generate x87 FPU code as this leads to the use
# of extended precision registers which prevent lead to
# wrong results.
#
# As SSE does not have extended precision registers,
# forcing the generation of SSE code ensures that the
# exact predicates produce correct results.
#
set (QEX_COMPILE_FLAGS "-Wall")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (QEX_COMPILE_FLAGS "${QEX_COMPILE_FLAGS} -msse -mfpmath=sse -pedantic -Weverything")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set (QEX_COMPILE_FLAGS "${QEX_COMPILE_FLAGS} -msse -mfpmath=sse -pedantic -Wextra")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message (WARNING
"You are using an Intel compiler which might generate x87 FPU code "
"that breaks the exact predicates. If you know which compiler flags "
"ensure that the Intel compiler produces SSE code, please patch "
"the CMakeLists.txt and inform the author <[email protected]>.")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# There is code in exactinit() that should make sure that nor
# x87 extended internal precision is used.
else ()
message (WARNING
"You are using an unknown compiler which might generate x87 FPU code "
"that breaks the exact predicates. If you know how to detect this compiler "
"and which flags "
"ensure that this compiler produces SSE code, please patch "
"the CMakeLists.txt and inform the author <[email protected]>.")
endif ()
set(STL_RANGE_CHECKS false CACHE BOOL "Include STL range checks in debug mode (This option is only used in debug mode.)")
# Add a flag to check stl vectors in debugging mode
if (STL_RANGE_CHECKS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC" )
endif()
set_target_properties (QEx
PROPERTIES
COMPILE_FLAGS "${QEX_COMPILE_FLAGS}"
DEFINE_SYMBOLS "-DQEX_EXPORT_SYMBOLS"
)
set_target_properties (QExStatic
PROPERTIES
COMPILE_FLAGS "${QEX_COMPILE_FLAGS}"
DEFINE_SYMBOLS "-DQEX_EXPORT_SYMBOLS"
)
#
# Fake successful finder run if compiling as a dependent project.
#
if(NOT "${PROJECT_NAME}" MATCHES "QEx")
set (QEX_FOUND true PARENT_SCOPE)
set (QEX_LIBRARIES QEx PARENT_SCOPE)
set (QEX_LIBRARY QEx PARENT_SCOPE)
set (QEX_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/interfaces/c" PARENT_SCOPE)
set (QEX_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "The directory where the OpenMesh libraries can be found.")
endif()
add_subdirectory(demo/minimal_c)
add_subdirectory(demo/cmdline_tool)
set(BUILD_UNIT_TESTS false CACHE BOOL "Whether to build the unit tests.")
if (BUILD_UNIT_TESTS)
enable_testing()
set(GTEST_DIR CACHE PATH "Source path of googletest.")
if (NOT GTEST_DIR)
message(FATAL_ERROR "GTEST_DIR unset")
endif()
add_subdirectory(${GTEST_DIR} gtest)
add_subdirectory(tests)
endif()
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
add_custom_target(qex_doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
COMMENT "Generating Doxygen documentation" VERBATIM)
endif()