Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

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

Commit a916097f authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Cleaned up CMake scripts and added correct export definitions so that now...

Cleaned up CMake scripts and added correct export definitions so that now CAMPVis can easily imported into other CMake projects through FIND_PACKAGE(CAMPVis).
parent a26fa8dc
#
# CAMPVis - Yet another visualization framework
# CMake file inspired by Voreen
#
# = CAMPVis - Yet another medical visualization framework =====================
PROJECT(CAMPVis)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
#
# Global Build Options
#
SET(CAMPVIS_VERSION 1.0.0)
# = Global Build Options ======================================================
OPTION(BUILD_SHARED_LIBS "Build shared libraries (strongly recommended!)" ON)
#OPTION(CAMPVIS_PRECOMPILED_HEADER "Use pre-compiled headers?" ON)
OPTION(CAMPVIS_DEBUG "Activate debug code?" ON)
OPTION(CAMPVIS_BUILD_APPLICATION "Build CAMPVis Application" ON)
OPTION(CAMPVIS_BUILD_CORE "Build CAMPVis Core" ON)
OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON)
OPTION(CAMPVIS_ENABLE_SCRIPTING "Add support for scripting CAMPVis using Lua" OFF)
OPTION(CAMPVIS_BUILD_LIB_CGT "Build CGT Library" ON)
OPTION(CAMPVIS_BUILD_LIB_LUA "Build Lua Library" OFF)
OPTION(CAMPVIS_BUILD_DOXYGEN "Build Doxygen Documentation" OFF)
OPTION(CAMPVIS_DEPLOY_SHADERS "Deploy Shader files to binary directory" OFF)
OPTION(CAMPVIS_GROUP_SOURCE_FILES "Group source files by directory" ON)
OPTION(CAMPVIS_BUILD_GOOGLETEST "Build googletest library" OFF)
OPTION(CAMPVIS_BUILD_TEST_SOURCES "Build Unit Tests of gooogletest" OFF)
OPTION(CAMPVIS_ENABLE_TESTING "Build CAMPVis Unit Tests using gooogletest" OFF)
IF(WIN32)
OPTION(CAMPVIS_COPY_EXTERNAL_DLLS "Copy external DLLs to bin directory?" ON)
......@@ -32,46 +22,46 @@ IF(WIN32)
OPTION(CAMPVIS_GENERATE_MANIFEST "Generate manifest in Visual Studio debug builds (switch on when encountering errors using incremental linking)?" OFF)
ENDIF()
# = Further Build Options =====================================================
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")
#
# Further Build Configurations
#
# propagate CAMPVIS_ENABLE_SCRIPTING to CAMPVIS_BUILD_LIB_LUA to support deprecated code
IF (CAMPVIS_ENABLE_SCRIPTING)
SET(CAMPVIS_BUILD_LIB_LUA ON)
ENDIF()
include(cmake/commonconf.cmake)
include(cmake/parseModulesDir.cmake)
# = Start the definition of all CAMPVis targets ===============================
MESSAGE(STATUS "--------------------------------------------------------------------------------")
IF(CAMPVIS_BUILD_LIB_CGT)
ADD_SUBDIRECTORY(ext/cgt)
ADD_SUBDIRECTORY(ext/sigslot)
# 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)
ENDIF()
IF(CAMPVIS_BUILD_LIB_LUA)
# build scripting targets when enabled
IF(CAMPVIS_ENABLE_SCRIPTING)
# build Lua from source
IF(WIN32)
# Keep LUA_BUILD_AS_DLL in sync with BUILD_SHARED_LIBS
SET(LUA_BUILD_AS_DLL ${BUILD_SHARED_LIBS} CACHE BOOL "Build Lua library as DLL" FORCE)
ENDIF(WIN32)
ADD_SUBDIRECTORY(ext/lua EXCLUDE_FROM_ALL)
# If the above command failed, provide a hint how to fix the problem
IF(NOT TARGET liblua)
MESSAGE(SEND_ERROR "Did you forget to run `git submodule update --init`?")
ENDIF(NOT TARGET liblua)
ENDIF()
IF(CAMPVIS_BUILD_CORE)
ADD_SUBDIRECTORY(core)
ENDIF()
IF(CAMPVIS_BUILD_MODULES)
ADD_SUBDIRECTORY(modules)
ENDIF()
IF(CAMPVIS_ENABLE_SCRIPTING)
# First, find Lua to setup paths for all projects correctly
FIND_PACKAGE(Lua REQUIRED)
IF(LUA_FOUND)
......@@ -91,22 +81,44 @@ IF(CAMPVIS_BUILD_APPLICATION)
ADD_SUBDIRECTORY(application)
ENDIF()
IF(CAMPVIS_BUILD_GOOGLETEST)
# build campvis-test when enabled
IF(CAMPVIS_ENABLE_TESTING)
ADD_SUBDIRECTORY(ext/gtest-1.7.0)
ENDIF()
IF(CAMPVIS_BUILD_TEST_SOURCES)
ADD_SUBDIRECTORY(test)
ENDIF()
# build doxygen when enabled
IF(CAMPVIS_BUILD_DOXYGEN)
ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
ENDIF()
#
# Copy External DLLs
#
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 =======
IF(WIN32)
# gather Qt4 DLLs - TODO: remove redundant naming of required components
FIND_PACKAGE(Qt4DLLs COMPONENTS QtCore QtGui QtOpenGL QtNetwork QtXmlPatterns)
......@@ -120,3 +132,5 @@ IF(WIN32)
COPY_EXTERNAL_DLLS(CampvisExternalDllsDebug CampvisExternalDllsRelease false)
ENDIF()
ENDIF()
MESSAGE(STATUS "--------------------------------------------------------------------------------")
......@@ -2,7 +2,7 @@ PROJECT(campvis-application)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
INCLUDE(../cmake/commonconf.cmake)
MESSAGE(STATUS "Configuring CAMPVis Application")
MESSAGE(STATUS "Configuring CAMPVis-Application")
FILE(GLOB CampvisApplicationSources
*.cpp
......
# - Config file for the CAMPVis package
# It defines the following variables
# CAMPVIS_INCLUDE_DIRS - include directories for FooBar
# CAMPVIS_LIBRARIES - libraries to link against
# CAMPVIS_EXECUTABLE - the bar executable
# Compute paths
get_filename_component(CAMPVIS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CAMPVIS_INCLUDE_DIRS "@CampvisGlobalIncludeDirs@;@CampvisModulesIncludeDirs@")
SET(CAMPVIS_DEFINITIONS @CampvisGlobalDefinitions@)
FIND_PACKAGE(Qt4 ${CampvisRequiredQtVersion} REQUIRED QtCore QtGui QtOpenGL)
INCLUDE(${QT_USE_FILE})
SET(CGT_WITH_QT true)
# Our library dependencies (contains definitions for IMPORTED targets)
include("${CAMPVIS_CMAKE_DIR}/CAMPVisTargets.cmake")
# These are IMPORTED targets created by FooBarTargets.cmake
SET(CAMPVIS_CORE_LIBRARIES campvis-core)
SET(CAMPVIS_MODULES_LIBRARIES campvis-modules)
......@@ -8,6 +8,20 @@ MESSAGE(STATUS "TUMVis Binary Directory: ${CampvisBinaryDir}")
# include macros
INCLUDE(${CampvisHome}/cmake/macros.cmake)
# include packaging helper scripts
INCLUDE(GenerateExportHeader)
INCLUDE(CMakePackageConfigHelpers)
# guard against in-source builds
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
MESSAGE(FATAL_ERROR "In-source builds are strongly discouraged and therefore not allowed.")
ENDIF()
# guard against static builds
IF(NOT BUILD_SHARED_LIBS)
MESSAGE(WARNING "Building static CAMPVis libraries is not officially supported and therefore strongly discouraged. Consider setting BUILD_SHARED_LIBS to ON unless you know what you're doing")
ENDIF()
# detect compiler and architecture
IF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 9 2008")
SET(CAMPVIS_MSVC2008 TRUE)
......@@ -79,6 +93,11 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# set install directories
SET(CampvisIncludeInstallDir "include")
SET(CampvisLibInstallDir "lib")
# common include directories
LIST(APPEND CampvisGlobalIncludeDirs "${CampvisHome}/ext")
LIST(APPEND CampvisGlobalIncludeDirs ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
......
......@@ -265,7 +265,7 @@ ENDMACRO(LIST_SUBDIRECTORIES)
# copies the passed debug and release DLLs to bin/Debug and bin/Release, resp.
MACRO(COPY_EXTERNAL_DLLS DebugDLLs ReleaseDLLs failOnError)
MESSAGE(STATUS "Copying external DLLs")
MESSAGE(STATUS "* Copying external DLLs")
SET(debug_dir "${CMAKE_BINARY_DIR}/bin/Debug")
IF(NOT EXISTS ${debug_dir})
......
......@@ -2,7 +2,7 @@ IF(NOT ModulesDirsParsed)
# detect modules
MESSAGE(STATUS "--------------------------------------------------------------------------------")
MESSAGE(STATUS "Detecting installed modules:")
MESSAGE(STATUS "Detecting installed CAMPVis modules:")
# collect list of directories in modules directories
SET(ModulesDir ${CampvisHome}/modules)
......
......@@ -59,3 +59,6 @@ IF(CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisCoreSources ${CampvisHome} "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisCoreHeaders ${CampvisHome} "")
ENDIF()
INSTALL(TARGETS campvis-core DESTINATION exports EXPORT campvis-targets)
......@@ -95,3 +95,5 @@ IF(CAMPVIS_ADD_INSTALL_TARGET)
)
ENDIF()
INSTALL(TARGETS cgt DESTINATION exports EXPORT campvis-targets)
......@@ -34,3 +34,5 @@ IF(CAMPVIS_ADD_INSTALL_TARGET)
)
ENDIF()
INSTALL(TARGETS sigslot DESTINATION exports EXPORT campvis-targets)
......@@ -2,7 +2,7 @@ PROJECT(campvis-modules)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
#INCLUDE(../cmake/commonconf.cmake)
MESSAGE(STATUS "Configuring Campvis Modules")
MESSAGE(STATUS "Configuring CAMPVis-Modules")
WRITE_PIPELINE_REGISTRATION("gen_pipelineregistration.h")
LIST(APPEND CampvisModulesHeaders
......@@ -35,3 +35,6 @@ IF(CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisModulesSources ${CampvisHome} "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisModulesHeaders ${CampvisHome} "")
ENDIF()
INSTALL(TARGETS campvis-modules DESTINATION exports EXPORT campvis-targets)
......@@ -61,7 +61,9 @@ IF(ModuleEnabled)
FILE(GLOB cuda_SOURCES modules/cudaconfidencemaps/core/*.cu)
CUDA_ADD_LIBRARY(cudaconfidencemaps-cuda STATIC
${cuda_SOURCES}
)
)
INSTALL(TARGETS cudaconfidencemaps-cuda DESTINATION exports EXPORT campvis-targets)
# Link CUDA code to module
LIST(APPEND ThisModExternalLibs cudaconfidencemaps-cuda)
......
......@@ -51,6 +51,7 @@
cmake_minimum_required(VERSION 2.6)
MESSAGE(STATUS " Configuring external library: freetype")
# CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
# configures the base build environment and references the toolchain file
......@@ -111,12 +112,12 @@ add_definitions("-D_CRT_SECURE_NO_WARNINGS")
include_directories("${PROJECT_SOURCE_DIR}/include")
# Create the configuration file
message(STATUS "Creating directory, ${PROJECT_BINARY_DIR}/include/freetype2.")
#message(STATUS "Creating directory, ${PROJECT_BINARY_DIR}/include/freetype2.")
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/freetype2)
# For the auto-generated ftconfig.h file
include_directories(BEFORE "${PROJECT_BINARY_DIR}/include/freetype2")
message(STATUS "Creating ${PROJECT_BINARY_DIR}/include/freetype2/ftconfig.h.")
#message(STATUS "Creating ${PROJECT_BINARY_DIR}/include/freetype2/ftconfig.h.")
execute_process(
COMMAND sed -e "s/FT_CONFIG_OPTIONS_H/<ftoption.h>/" -e "s/FT_CONFIG_STANDARD_LIBRARY_H/<ftstdlib.h>/" -e "s?/undef ?#undef ?"
INPUT_FILE ${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.in
......@@ -252,4 +253,5 @@ include(CPack)
# add make dist target
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# eof
# define export targets
INSTALL(TARGETS freetype DESTINATION exports EXPORT campvis-targets)
......@@ -12,6 +12,8 @@
project(alglib CXX C)
cmake_minimum_required(VERSION 2.6.2)
MESSAGE(STATUS " Configuring external library: Alglib")
# Where .h files can be found.
include_directories(
${alglib_SOURCE_DIR}
......@@ -72,3 +74,5 @@ if ( MSVC )
set_property( TARGET alglib APPEND_STRING PROPERTY COMPILE_FLAGS "/W1 /EHsc" )
endif ( MSVC )
# define export targets
INSTALL(TARGETS alglib DESTINATION exports EXPORT campvis-targets)
......@@ -3,7 +3,7 @@
################################################################################
PROJECT(RandomWalksLib)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
MESSAGE(STATUS " Configuring external RandomWalksLib Library")
MESSAGE(STATUS " Configuring external library: RandomWalksLib")
# all RandomWalksLibHeaders except ViennaCL related stuff
SET(RandomWalksLibHeaders ConfidenceMaps2D.h
......@@ -43,3 +43,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_LIBRARY(RandomWalksLib ${CampvisSharedStaticModulesFix} ${RandomWalksLibSources} ${RandomWalksLibHeaders})
TARGET_LINK_LIBRARIES(RandomWalksLib ${RandomWalksLibExternalLibs})
# define export targets
INSTALL(TARGETS RandomWalksLib DESTINATION exports EXPORT campvis-targets)
PROJECT(NLOPT)
MESSAGE(STATUS " Configuring external library: nlopt")
#==============================================================================
# NLOPT CMake file
......@@ -152,4 +153,5 @@ ELSE(NLOPT_BUILD_SHARED)
ENDIF(NLOPT_BUILD_SHARED)
# define export targets
INSTALL(TARGETS nlopt DESTINATION exports EXPORT campvis-targets)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment