CMakeLists.txt 7.27 KB
Newer Older
Martin Heistermann's avatar
Martin Heistermann 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 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
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
    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
    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"
)


Martin Heistermann's avatar
acg fix  
Martin Heistermann committed
82 83
# 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".
84 85
include(ACGCommon OPTIONAL RESULT_VARIABLE IN_ACG_BUILD)
if(IN_ACG_BUILD)
Martin Heistermann's avatar
acg fix  
Martin Heistermann committed
86
    message("OVM is being built as part of an ACG project, using acg_add_library!")
87
    if (WIN32)
Martin Heistermann's avatar
acg fix  
Martin Heistermann committed
88
        acg_add_library(OpenVolumeMesh STATIC ${SOURCE_FILES})
89
    else()
Martin Heistermann's avatar
acg fix  
Martin Heistermann committed
90
        acg_add_library(OpenVolumeMesh SHARED ${SOURCE_FILES})
91 92 93 94 95 96 97 98 99
    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)
100

Martin Heistermann's avatar
Martin Heistermann committed
101 102
add_library(OpenVolumeMesh::OpenVolumeMesh ALIAS OpenVolumeMesh)

103 104 105 106 107 108 109 110
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"
)

Martin Heistermann's avatar
Martin Heistermann committed
111 112
set_target_properties (OpenVolumeMesh PROPERTIES
    VERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
113
    SOVERSION ${OpenVolumeMesh_VERSION_MAJOR}.${OpenVolumeMesh_VERSION_MINOR}
Martin Heistermann's avatar
Martin Heistermann committed
114 115 116
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED YES
    CXX_EXTENSIONS NO
Martin Heistermann's avatar
Martin Heistermann committed
117
    CXX_VISIBILITY_PRESET hidden
118
    )
Martin Heistermann's avatar
Martin Heistermann committed
119 120


121 122 123 124 125 126
target_compile_options(OpenVolumeMesh PUBLIC
    "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>"
    # 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>"
    )
127

Martin Heistermann's avatar
Martin Heistermann committed
128 129
target_compile_definitions(OpenVolumeMesh
    PUBLIC
Martin Heistermann's avatar
Martin Heistermann committed
130
        "INCLUDE_TEMPLATES"
Martin Heistermann's avatar
Martin Heistermann committed
131 132 133
        "$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>"
        "$<$<CXX_COMPILER_ID:MSVC>:_USE_MATH_DEFINES>"
    )
Martin Heistermann's avatar
Martin Heistermann committed
134

Martin Heistermann's avatar
Martin Heistermann committed
135
target_compile_options(OpenVolumeMesh PRIVATE
Martin Heistermann's avatar
Martin Heistermann committed
136
    "$<$<CXX_COMPILER_ID:MSVC>:/W1>"
Martin Heistermann's avatar
Martin Heistermann committed
137 138 139 140 141 142 143
    "$<$<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>"
    )

target_include_directories(OpenVolumeMesh
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Martin Heistermann's avatar
Martin Heistermann committed
144
        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/OpenVolumeMesh/Config>
Martin Heistermann's avatar
Martin Heistermann committed
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
        $<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)

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

Martin Heistermann's avatar
Martin Heistermann committed
202 203 204 205 206
#add_subdirectory(FileConverter)

if (OVM_ENABLE_UNITTESTS)
    add_subdirectory(Unittests)
else()
Martin Heistermann's avatar
Martin Heistermann committed
207 208
    # currently this clashes for an in-tree OF build
    #add_subdirectory(Unittests EXCLUDE_FROM_ALL)
Martin Heistermann's avatar
Martin Heistermann committed
209 210
endif()