CMakeLists.txt 2.28 KB
Newer Older
Martin Heistermann's avatar
Martin Heistermann committed
1 2
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
cmake_policy(VERSION 3.12.0)
3

4

Martin Heistermann's avatar
Martin Heistermann committed
5 6 7 8 9
project (OpenVolumeMesh
    VERSION 2.1.0
    LANGUAGES CXX
    HOMEPAGE_URL https://openvolumemesh.org/
    )
10

11
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Mike Kremer's avatar
Mike Kremer committed
12

Martin Heistermann's avatar
Martin Heistermann committed
13 14 15 16
if( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
    set(OVM_STANDALONE_BUILD TRUE)
else()
    set(OVM_STANDALONE_BUILD FALSE)
Jan Möbius's avatar
Jan Möbius committed
17 18
endif()

19
set(OVM_ENABLE_APPLICATIONS ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh applications")
20
set(OVM_ENABLE_UNITTESTS ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh unit tests")
21 22
set(OVM_ENABLE_EXAMPLES ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh examples")
set(OVM_BUILD_DOCUMENTATION ${OVM_STANDALONE_BUILD} CACHE BOOL "Build OpenVolumeMesh documentation")
Mike Kremer's avatar
Mike Kremer committed
23

Martin Heistermann's avatar
Martin Heistermann committed
24 25
set(OVM_CXX_VERSION 11 CACHE STRING "C++ version to use")
set_property(CACHE OVM_CXX_VERSION PROPERTY STRINGS 11 14 17 20)
26

27 28 29 30 31
if (OVM_STANDALONE_BUILD)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Build/bin")
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Build/lib")
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Build/lib")
    set(OVM_TARGET_PREFIX "")
32
    enable_testing()
33 34 35 36 37 38 39 40 41 42 43
    option(STL_DEBUG "Enable STL debug checks. Warning: This must be consistent across the whole build! Not compatible with the libc++ shipped with Apple XCode as of 2019." OFF)
    if (STL_DEBUG)
        # We do not know which STL will be used, defining both is the easist way.

        # https://libcxx.llvm.org/docs/UsingLibcxx.html#libc-configuration-macros
        # https://libcxx.llvm.org/docs/DesignDocs/DebugMode.html#using-debug-mode
        add_definitions(-D_LIBCPP_DEBUG=1)
        # https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/manual/debug_mode_using.html
        add_definitions(-D_GLIBXX_DEBUG=1)
        add_definitions(-D_GLIBXX_DEBUG_PEDANTIC=1)
    endif()
44 45 46 47
else()
    # OVM_TARGET_PREFIX is prepended to targets with generic names,
    # i.e., "doc", "unittests"
    set(OVM_TARGET_PREFIX "OVM_")
Martin Heistermann's avatar
Martin Heistermann committed
48
endif()
Mike Kremer's avatar
Mike Kremer committed
49

Martin Heistermann's avatar
Martin Heistermann committed
50
set (CMAKE_DEBUG_POSTFIX "d")
Mike Kremer's avatar
Mike Kremer committed
51 52

add_subdirectory (src)
53

Martin Heistermann's avatar
Martin Heistermann committed
54
if (OVM_ENABLE_EXAMPLES)
55
    add_subdirectory(examples)
Martin Heistermann's avatar
Martin Heistermann committed
56 57
endif()

58 59 60
if (OVM_BUILD_DOCUMENTATION)
   add_subdirectory(documentation)
endif()
Mike Kremer's avatar
Mike Kremer committed
61

Martin Heistermann's avatar
Martin Heistermann committed
62
#export(PACKAGE OpenVolumeMesh)
Mike Kremer's avatar
Mike Kremer committed
63

64
#list(REMOVE_AT CMAKE_MODULE_PATH -1)