11.3.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

CMakeLists.txt 5.01 KB
Newer Older
1
# = CAMPVis - Yet another medical visualization framework =====================
2 3
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2 FATAL_ERROR)
cmake_policy(SET CMP0020 NEW)
schultezub's avatar
schultezub committed
4

5 6
PROJECT(CAMPVis)

7
SET(CAMPVIS_VERSION 1.0.0)
schultezub's avatar
schultezub committed
8

9
# = Global Build Options ======================================================
10
OPTION(BUILD_SHARED_LIBS            "Build shared libraries (strongly recommended!)"                ON)
11
OPTION(CAMPVIS_DEBUG                "Activate debug code?"                                          ON)
12
OPTION(CAMPVIS_BUILD_LIB_CGT        "Build CGT Library"                                             ON)
13 14
OPTION(CAMPVIS_BUILD_APPLICATION    "Build CAMPVis Application"                                     ON)
OPTION(CAMPVIS_BUILD_MODULES        "Build CAMPVis Modules"                                         ON)
15
OPTION(CAMPVIS_ENABLE_SCRIPTING     "Add support for scripting CAMPVis using Lua"                   OFF)
16
OPTION(CAMPVIS_BUILD_DOXYGEN        "Build Doxygen Documentation"                                   OFF)
17 18

OPTION(CAMPVIS_DEPLOY_SHADERS       "Deploy Shader files to binary directory"                       OFF)
19
OPTION(CAMPVIS_GROUP_SOURCE_FILES   "Group source files by directory"                               ON)
20
OPTION(CAMPVIS_ENABLE_TESTING       "Build CAMPVis Unit Tests using gooogletest"                    OFF)
schultezub's avatar
schultezub committed
21 22

IF(WIN32)
23 24
    OPTION(CAMPVIS_COPY_EXTERNAL_DLLS   "Copy external DLLs to bin directory?"                      ON)
    OPTION(CAMPVIS_INCREMENTAL_LINKING  "Enable incremental linking in Visual Studio debug builds?" ON)
schultezub's avatar
schultezub committed
25
    OPTION(CAMPVIS_GENERATE_MANIFEST    "Generate manifest in Visual Studio debug builds (switch on when encountering errors using incremental linking)?"          OFF)
schultezub's avatar
schultezub committed
26 27
ENDIF()

28 29

# = Further Build Options =====================================================
30 31 32
SET(CAMPVIS_DEFAULT_ENABLED_MODULES "STABLE_NO_DEPENDENCIES" CACHE STRING "Default CAMPVis modules to activate")
SET_PROPERTY(CACHE CAMPVIS_DEFAULT_ENABLED_MODULES PROPERTY STRINGS "NONE" "STABLE_NO_DEPENDENCIES" "STABLE_WITH_EXTERNAL_DEPENDENCIES" "TESTING" "ALL")

33 34 35 36
IF(NOT BUILD_SHARED_LIBS)
    MESSAGE(WARNING "Building shared libraries is turned off. Thus, CAMPVis will most probably not work as intended!\nPlease turn BUILD_SHARED_LIBS on unless you know what you're doing!")
ENDIF(NOT BUILD_SHARED_LIBS)

37 38 39 40 41
# propagate CAMPVIS_ENABLE_SCRIPTING to CAMPVIS_BUILD_LIB_LUA to support deprecated code
IF (CAMPVIS_ENABLE_SCRIPTING)
    SET(CAMPVIS_BUILD_LIB_LUA ON)
ENDIF()

schultezub's avatar
schultezub committed
42
include(cmake/commonconf.cmake)
43
include(cmake/parseModulesDir.cmake)
schultezub's avatar
schultezub committed
44

45 46

# = Start the definition of all CAMPVis targets ===============================
47 48
MESSAGE(STATUS "--------------------------------------------------------------------------------")

49 50 51 52 53 54 55
# cgt, sigslot and campvis-core are enabled by default.
ADD_SUBDIRECTORY(ext/cgt)
ADD_SUBDIRECTORY(ext/sigslot)
ADD_SUBDIRECTORY(core)

IF(CAMPVIS_BUILD_MODULES)
    ADD_SUBDIRECTORY(modules)
schultezub's avatar
schultezub committed
56 57
ENDIF()

58 59 60
# build scripting targets when enabled
IF(CAMPVIS_ENABLE_SCRIPTING)
    # build Lua from source
61 62
    ADD_SUBDIRECTORY(ext/lua)
    SET(LUA_DIR "${CampvisHome}/ext/lua")
63

64
    # First, find Lua to setup paths for all projects correctly
65 66 67
    LIST(APPEND CampvisGlobalIncludeDirs "${LUA_DIR}/src" "${CMAKE_BINARY_DIR}/ext/lua")
    LIST(APPEND CampvisGlobalExternalLibs "liblua")
    LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_HAS_SCRIPTING")
68
    
69 70 71
    ADD_SUBDIRECTORY(scripting)
ENDIF()

schultezub's avatar
schultezub committed
72
IF(CAMPVIS_BUILD_APPLICATION)
schultezub's avatar
 
schultezub committed
73 74 75
    ADD_SUBDIRECTORY(application)
ENDIF()

76 77
# build campvis-test when enabled
IF(CAMPVIS_ENABLE_TESTING)
78
    ADD_SUBDIRECTORY(ext/googletest-release-1.8.0)
79 80 81
    ADD_SUBDIRECTORY(test)
ENDIF()

82
# build doxygen when enabled
83 84 85 86
IF(CAMPVIS_BUILD_DOXYGEN)
    ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
ENDIF()

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
MESSAGE(STATUS "--------------------------------------------------------------------------------")
MESSAGE(STATUS "Finishing up")


# = Export all CAMPVis Targets so that they can be included easily ============
# write package version file
write_basic_package_version_file(
  "${CMAKE_CURRENT_BINARY_DIR}/CAMPVisConfigVersion.cmake"
  VERSION ${CAMPVIS_VERSION}
  COMPATIBILITY AnyNewerVersion
)
# write campvis targets file
export(EXPORT campvis-targets
  FILE "${CMAKE_CURRENT_BINARY_DIR}/CAMPVisTargets.cmake"
#  NAMESPACE Upstream::
)
# write campvis configuration file
configure_file("${CampvisHome}/cmake/CAMPVisConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/CAMPVisConfig.cmake"
  @ONLY
)

#INSTALL(EXPORT campvis-targets NAMESPACE Upstream:: DESTINATION ${CampvisLibInstallDir})
EXPORT(PACKAGE CAMPVis)

# = Copy Windows DLLs to binary dir for improved development experience =======
schultezub's avatar
schultezub committed
114
IF(WIN32)
schultezub's avatar
schultezub committed
115
    IF(CAMPVIS_COPY_EXTERNAL_DLLS)
116 117
        LIST(REMOVE_DUPLICATES CampvisExternalDllsDebug)
        LIST(REMOVE_DUPLICATES CampvisExternalDllsRelease)
schultezub's avatar
schultezub committed
118
        COPY_EXTERNAL_DLLS(CampvisExternalDllsDebug CampvisExternalDllsRelease false)
schultezub's avatar
schultezub committed
119 120
    ENDIF()
ENDIF()
121 122

MESSAGE(STATUS "--------------------------------------------------------------------------------")