CMakeLists.txt 7.45 KB
Newer Older
Martin Heistermann's avatar
Martin Heistermann committed
1
2
3
4
5
6
7
8
SET(HEADER_FILES
    OpenVolumeMesh/System/FunctionalInclude.hh
    OpenVolumeMesh/System/MemoryInclude.hh
    OpenVolumeMesh/System/Deprecation.hh
    OpenVolumeMesh/Attribs/TexCoordAttrib.hh
    OpenVolumeMesh/Attribs/OpenVolumeMeshStatus.hh
    OpenVolumeMesh/Attribs/ColorAttribT_impl.hh
    OpenVolumeMesh/Attribs/ColorAttrib.hh
9
    OpenVolumeMesh/Attribs/InterfaceAttrib.hh
Martin Heistermann's avatar
Martin Heistermann committed
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
    OpenVolumeMesh/Attribs/NormalAttrib.hh
    OpenVolumeMesh/Attribs/NormalAttribT_impl.hh
    OpenVolumeMesh/Attribs/TexCoordAttribT_impl.hh
    OpenVolumeMesh/Attribs/StatusAttribT_impl.hh
    OpenVolumeMesh/Attribs/StatusAttrib.hh
    OpenVolumeMesh/Geometry/Vector11T.hh
    OpenVolumeMesh/Geometry/VectorT_inc.hh
    OpenVolumeMesh/Geometry/VectorT.hh
    OpenVolumeMesh/FileManager/FileManagerT_impl.hh
    OpenVolumeMesh/FileManager/FileManager.hh
    OpenVolumeMesh/Core/BaseEntities.hh
    OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh
    OpenVolumeMesh/Core/BaseProperty.hh
    OpenVolumeMesh/Core/ResourceManager.hh
    OpenVolumeMesh/Core/PropertyHandles.hh
    OpenVolumeMesh/Core/TypeName.hh
    OpenVolumeMesh/Core/PropertyPtrT_impl.hh
    OpenVolumeMesh/Core/PropertyDefinesT_impl.hh
    OpenVolumeMesh/Core/GeometryKernel.hh
    OpenVolumeMesh/Core/TopologyKernel.hh
    OpenVolumeMesh/Core/ResourceManagerT_impl.hh
    OpenVolumeMesh/Core/PropertyDefines.hh
    OpenVolumeMesh/Core/Serializers.hh
    OpenVolumeMesh/Core/OpenVolumeMeshBaseProperty.hh
    OpenVolumeMesh/Core/ForwardDeclarations.hh
    OpenVolumeMesh/Core/PropertyPtr.hh
    OpenVolumeMesh/Core/Entities.hh
    OpenVolumeMesh/Core/SerializersT_impl.hh
    OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh
    OpenVolumeMesh/Core/Iterators.hh
    OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.hh
    OpenVolumeMesh/Mesh/HexahedralMesh.hh
    OpenVolumeMesh/Mesh/HexahedralMeshIterators.hh
    OpenVolumeMesh/Mesh/TetrahedralMesh.hh
    OpenVolumeMesh/Mesh/HexahedralMeshTopologyKernel.hh
    OpenVolumeMesh/Mesh/TetrahedralMeshIterators.hh
    OpenVolumeMesh/Mesh/PolyhedralMesh.hh
    OpenVolumeMesh/Mesh/TetrahedralGeometryKernel.hh
    Unittests/unittests_common.hh)

SET(SOURCE_FILES
51
    OpenVolumeMesh/Attribs/InterfaceAttrib.cc
Martin Heistermann's avatar
Martin Heistermann committed
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
    OpenVolumeMesh/Attribs/OpenVolumeMeshStatus.cc
    OpenVolumeMesh/Attribs/StatusAttrib.cc
    OpenVolumeMesh/Geometry/Vector.cc
    OpenVolumeMesh/FileManager/FileManager.cc
    OpenVolumeMesh/Core/PropertyDefines.cc
    OpenVolumeMesh/Core/OpenVolumeMeshHandle.cc
    OpenVolumeMesh/Core/ResourceManager.cc
    OpenVolumeMesh/Core/BaseEntities.cc
    OpenVolumeMesh/Core/BaseProperty.cc
    OpenVolumeMesh/Core/TopologyKernel.cc
    OpenVolumeMesh/Core/Serializers.cc
    OpenVolumeMesh/Core/Iterators.cc
    OpenVolumeMesh/Core/OpenVolumeMeshBaseProperty.cc
    OpenVolumeMesh/Mesh/TetrahedralMeshIterators.cc
    OpenVolumeMesh/Mesh/HexahedralMeshIterators.cc
    OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc
    OpenVolumeMesh/Mesh/HexahedralMeshTopologyKernel.cc
)

set(OVM_ENABLE_DEPRECATED_APIS ON CACHE BOOL "Support deprecated OpenVolumeMesh APIs")

configure_file (
    "${CMAKE_CURRENT_SOURCE_DIR}/OpenVolumeMesh/Config/DeprecationConfig.hh.in"
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMesh/Config/DeprecationConfig.hh"
)

configure_file (
    "${CMAKE_CURRENT_SOURCE_DIR}/OpenVolumeMesh/Config/Version.hh.in"
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMesh/Config/Version.hh"
)


# If we are in a subdirectory of another project that has a ACGCommon module
# (e.g. OpenFlipper), we will use acg_add_library; otherwise behave "normally".
include(ACGCommon OPTIONAL RESULT_VARIABLE IN_ACG_BUILD)
if(IN_ACG_BUILD)
    message("OVM is being built as part of an ACG project, using acg_add_library!")
    if (WIN32)
        acg_add_library(OpenVolumeMesh STATIC ${SOURCE_FILES})
    else()
        acg_add_library(OpenVolumeMesh SHARED ${SOURCE_FILES})
    endif()
else(IN_ACG_BUILD)
    if (WIN32)
        add_library(OpenVolumeMesh STATIC ${SOURCE_FILES})
    else()
        option(BUILD_SHARED_LIBS "Build shared library (*.dll, *.so, *.dylib) instead of static library (*.a, *.lib)" ON)
        add_library(OpenVolumeMesh ${SOURCE_FILES})
    endif()
endif(IN_ACG_BUILD)

add_library(OpenVolumeMesh::OpenVolumeMesh ALIAS OpenVolumeMesh)

include(GenerateExportHeader)
generate_export_header(OpenVolumeMesh
    BASE_NAME OVM
    EXPORT_FILE_NAME "OpenVolumeMesh/Config/Export.hh"
    DEPRECATED_MACRO_NAME "CMAKE_OVM_DEPRECATED"
    NO_DEPRECATED_MACRO_NAME "CMAKE_OVM_NO_DEPRECATED"
)

set_target_properties (OpenVolumeMesh PROPERTIES
    VERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
    SOVERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
116
    CXX_STANDARD ${OVM_CXX_VERSION}
Martin Heistermann's avatar
Martin Heistermann committed
117
118
119
    CXX_STANDARD_REQUIRED YES
    CXX_EXTENSIONS NO
    CXX_VISIBILITY_PRESET hidden
120
    POSITION_INDEPENDENT_CODE ON
Martin Heistermann's avatar
Martin Heistermann committed
121
122
123
124
125
    )


target_compile_options(OpenVolumeMesh PUBLIC
    "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>"
126
127
128
129
130
    "$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>" # Enable updated __cplusplus macro
    PRIVATE
    "$<$<CXX_COMPILER_ID:GNU>:-Wall>"
    "$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wno-c++98-compat;-Wno-c++98-compat-pedantic;-Wno-weak-vtables;-Wno-padded;-Wno-sign-conversion;-Wno-missing-prototypes>"
    "$<$<CXX_COMPILER_ID:MSVC>:/W1>"
Martin Heistermann's avatar
Martin Heistermann committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
    # disable MSVC inline warnings that are enabled with /Ob2, which is in the default cmake release cxxflags:
    "$<$<CXX_COMPILER_ID:MSVC>:/wd4710>"
    "$<$<CXX_COMPILER_ID:MSVC>:/wd4711>"
    )

target_compile_definitions(OpenVolumeMesh
    PUBLIC
        "INCLUDE_TEMPLATES"
        "$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>"
        "$<$<CXX_COMPILER_ID:MSVC>:_USE_MATH_DEFINES>"
    )

target_include_directories(OpenVolumeMesh
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMesh/Config>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)


set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenVolumeMesh)

configure_package_config_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/OpenVolumeMeshConfig.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMeshConfig.cmake"
    INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
    )

write_basic_package_version_file(
    OpenVolumeMeshConfigVersion.cmake
    VERSION ${PROJECT_VERSION}
    COMPATIBILITY SameMajorVersion
    )

install(FILES
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMeshConfigVersion.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMeshConfig.cmake"
    DESTINATION ${INSTALL_CONFIGDIR})


install(DIRECTORY
    "${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMesh/Config"
    DESTINATION include/OpenVolumeMesh)

# Install Header Files
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OpenVolumeMesh
    DESTINATION include
    FILES_MATCHING PATTERN "*.hh"
    )

install(TARGETS OpenVolumeMesh
    EXPORT OpenVolumeMeshTargets
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(EXPORT OpenVolumeMeshTargets
    FILE OpenVolumeMeshTargets.cmake
    NAMESPACE OpenVolumeMesh::
    DESTINATION ${INSTALL_CONFIGDIR}
)

export(EXPORT OpenVolumeMeshTargets
    NAMESPACE OpenVolumeMesh::)
export(PACKAGE OpenVolumeMesh)

# copy library to correct folder for building as subdirectory of other projects,
# such as OpenFlipper

#add_subdirectory(FileConverter)

if (OVM_ENABLE_UNITTESTS)
    add_subdirectory(Unittests)
else()
    # currently this clashes for an in-tree OF build
    #add_subdirectory(Unittests EXCLUDE_FROM_ALL)
endif()