CMakeLists.txt 5.89 KB
Newer Older
Max Lyon's avatar
Max Lyon committed
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
 #
# Copyright 2013 Computer Graphics Group, RWTH Aachen University
# Authors: Hans-Christian Ebke <ebke@cs.rwth-aachen.de>
#          Max Lyon <lyon@cs.rwth-aachen.de>
#
# This file is part of HexEx.
# 
# HexEx 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.
# 
# HexEx 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 HexEx.  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 (HexEx)
endif()

list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

add_definitions(-DINCLUDE_TEMPLATES)

set (SOURCES "")
set (INCLUDE_DIRS "")
set (LIBRARIES "")
set (LIBRARY_DIRS "")


file(GLOB SRCS "${CMAKE_CURRENT_LIST_DIR}/src/*.cc" "${CMAKE_CURRENT_LIST_DIR}/src/*.c")

41
42
43
44
45
46
47
48
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/OpenVolumeMesh")
  add_subdirectory(OpenVolumeMesh)
  message("Building with OpenVolumeMesh")
else()
  message("Not Building with OpenVolumeMesh")
endif()

find_package (OpenVolumeMesh REQUIRED)
Max Lyon's avatar
Max Lyon committed
49
50
51
52
53
54
55
56
57
58
59
60
61

list (APPEND SOURCES ${SRCS})
list (APPEND INCLUDE_DIRS ${OPENVOLUMEMESH_INCLUDE_DIR})
list (APPEND LIBRARY_DIRS ${OPENVOLUMEMESH_LIBRARY_DIR})
list (APPEND LIBRARIES ${OPENVOLUMEMESH_LIBRARY})

include_directories (${INCLUDE_DIRS})

link_directories (${CMAKE_BINARY_DIR} ${LIBRARY_DIRS} )

add_library (HexEx SHARED ${SOURCES})
add_library (HexExStatic STATIC ${SOURCES})

Heng Liu's avatar
Heng Liu committed
62
63
target_link_libraries (HexEx ${LIBRARIES} OpenVolumeMesh)
target_link_libraries (HexExStatic ${LIBRARIES} OpenVolumeMesh)
Max Lyon's avatar
Max Lyon committed
64
65
66
67
68
69
70
71
72
73
74
75
76

#
# 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 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 (HEXEX_COMPILE_FLAGS "-Wall")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Max Lyon's avatar
Max Lyon committed
77
    set (HEXEX_COMPILE_FLAGS "${HEXEX_COMPILE_FLAGS} -msse -mfpmath=sse" )
Max Lyon's avatar
Max Lyon committed
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
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    set (HEXEX_COMPILE_FLAGS "${HEXEX_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 <lyon@cs.rwth-aachen.de>.")
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 <lyon@cs.rwth-aachen.de>.")
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 (HexEx
    PROPERTIES
    COMPILE_FLAGS "${HEXEX_COMPILE_FLAGS}"
    DEFINE_SYMBOLS "-DHEXEX_EXPORT_SYMBOLS"
108
    CXX_STANDARD 11
Max Lyon's avatar
Max Lyon committed
109
110
    )

Heng Liu's avatar
Heng Liu committed
111
112
113
114
115
target_include_directories(HexEx
        INTERFACE
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
        )
116
117
118
119
120
target_include_directories(HexExStatic
        INTERFACE
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
        )
Heng Liu's avatar
Heng Liu committed
121

Max Lyon's avatar
Max Lyon committed
122
123
124
125
set_target_properties (HexExStatic
    PROPERTIES
    COMPILE_FLAGS "${HEXEX_COMPILE_FLAGS}"
    DEFINE_SYMBOLS "-DHEXEX_EXPORT_SYMBOLS"
126
    CXX_STANDARD 11
Max Lyon's avatar
Max Lyon committed
127
    )
128
set_property(TARGET HexExStatic PROPERTY POSITION_INDEPENDENT_CODE ON)
Max Lyon's avatar
Max Lyon committed
129

130
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
Max Lyon's avatar
Max Lyon committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

#
# Fake successful finder run if compiling as a dependent project.
#
if(NOT "${PROJECT_NAME}" MATCHES "HexEx")
    set (HEXEX_FOUND true PARENT_SCOPE)
    set (HEXEX_LIBRARIES HexEx PARENT_SCOPE)
    set (HEXEX_LIBRARY HexEx PARENT_SCOPE)
    set (HEXEX_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/" PARENT_SCOPE)
    set (HEXEX_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "The directory where the HexEx libraries can be found.")
endif()

if("${PROJECT_NAME}" MATCHES "HexEx")
   add_subdirectory(demo/cmdline_tool)
   add_subdirectory(demo/minimum_example)
endif()

Max Lyon's avatar
Max Lyon committed
148
149
#if ( NOT DEFINED HEXEX_BUILD_UNIT_TESTS)
#  set( HEXEX_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit test builds in HexEx." )
Max Lyon's avatar
Max Lyon committed
150
#endif()
Max Lyon's avatar
Max Lyon committed
151
152
153
154
155
156
157
158
#add_subdirectory (unittests)

set(HEXEX_BUILD_UNIT_TESTS false CACHE BOOL "Whether to build the unit tests.")
if (HEXEX_BUILD_UNIT_TESTS)
    enable_testing()
    find_package(GoogleTest REQUIRED)
    add_subdirectory(tests)
endif()
Max Lyon's avatar
Max Lyon committed
159
160
161
162
163
164
165
166
167
168


#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()
169
170

list(REMOVE_AT CMAKE_MODULE_PATH -1)