CMakeLists.txt 5.5 KB
Newer Older
Martin Heistermann's avatar
Martin Heistermann committed
1
SET(SOURCE_FILES
2
    OpenVolumeMesh/Attribs/InterfaceAttrib.cc
Martin Heistermann's avatar
Martin Heistermann committed
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
    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)
47
48
49
        # Windows .dll build is not supported yet.
        # TODO: turn this on once we have OVM_EXPORT macros in all required places,
        # cf CXX_VISIBILITY_PRESET:
Martin Heistermann's avatar
Martin Heistermann committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
        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}
70
    CXX_STANDARD ${OVM_CXX_VERSION}
Martin Heistermann's avatar
Martin Heistermann committed
71
72
    CXX_STANDARD_REQUIRED YES
    CXX_EXTENSIONS NO
73
74
    # TODO: turn this on once we have OVM_EXPORT macros in all required places:
    #CXX_VISIBILITY_PRESET hidden
75
    POSITION_INDEPENDENT_CODE ON
Martin Heistermann's avatar
Martin Heistermann committed
76
77
78
79
80
    )


target_compile_options(OpenVolumeMesh PUBLIC
    "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>"
81
82
83
84
85
    "$<$<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
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
147
148
149
150
151
152
153
154
155
    # 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)

156
157
158
159
160
if (OVM_ENABLE_APPLICATIONS)
    add_subdirectory(FileConverter)
else()
    add_subdirectory(FileConverter EXCLUDE_FROM_ALL)
endif()
Martin Heistermann's avatar
Martin Heistermann committed
161
162
163
164
165

if (OVM_ENABLE_UNITTESTS)
    add_subdirectory(Unittests)
else()