CMakeLists.txt 6.3 KB
Newer Older
WINTZ Julien's avatar
WINTZ Julien committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:

15
cmake_minimum_required(VERSION 3.6.0)
WINTZ Julien's avatar
WINTZ Julien committed
16 17 18 19 20 21 22 23 24

######################################################################

project(dtkVisualization)

## ###################################################################
## Version setup
## ###################################################################

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
25
set(${PROJECT_NAME}_VERSION_MAJOR 2)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
26
set(${PROJECT_NAME}_VERSION_MINOR 8)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
27
set(${PROJECT_NAME}_VERSION_PATCH 3)
WINTZ Julien's avatar
WINTZ Julien committed
28 29 30 31 32 33 34 35 36 37 38 39 40
set(${PROJECT_NAME}_VERSION
  ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})

## ###################################################################
## Output directory setup
## ###################################################################

include(GNUInstallDirs)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

41 42 43
set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)

WINTZ Julien's avatar
WINTZ Julien committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
## #################################################################
## Install prefix
## #################################################################

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "${PROJECT_NAME} install prefix" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

## #################################################################
## Generate compilation database
## #################################################################

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")

## #################################################################
## Build setup
## #################################################################

62
set(CMAKE_CXX_STANDARD 14)
WINTZ Julien's avatar
WINTZ Julien committed
63 64
set(CMAKE_CXX_STANDARD_REQUIRED ON)

65 66 67
if(UNIX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()
WINTZ Julien's avatar
WINTZ Julien committed
68

WINTZ Julien's avatar
WINTZ Julien committed
69 70 71 72 73 74 75 76 77 78
## ###################################################################
## Dependencies - cmake
## ###################################################################

include(GenerateExportHeader)

## #################################################################
## Dependencies - external
## #################################################################

79
find_package(VTK REQUIRED)
WINTZ Julien's avatar
WINTZ Julien committed
80

81
find_package(Qt5 COMPONENTS Core Widgets OpenGL Xml Multimedia MultimediaWidgets WebSockets REQUIRED)
82
include_directories(${Qt5Multimedia_PRIVATE_INCLUDE_DIRS})
WINTZ Julien's avatar
WINTZ Julien committed
83

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
84
find_package(dtkCore    2.3.0 REQUIRED)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
85
find_package(dtkFonts   2.0.0 REQUIRED)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
86
find_package(dtkWidgets 2.7.0 REQUIRED)
87
find_package(dtkLog     2.1.0 REQUIRED)
WINTZ Julien's avatar
WINTZ Julien committed
88

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
89 90 91 92 93
if(WIN32)
  set(OpenGL_GL_PREFERENCE "GLVND")
  find_package(OpenGL REQUIRED)
endif(WIN32)

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
94 95 96 97
if(MSVC)
  add_definitions("/wd4068")
endif(MSVC)

WINTZ Julien's avatar
WINTZ Julien committed
98 99 100 101 102
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

include(${VTK_USE_FILE})

103
include_directories(${dtkCore_INCLUDE_DIRS})
104
include_directories(${dtkLog_INCLUDE_DIRS})
WINTZ Julien's avatar
WINTZ Julien committed
105 106 107
include_directories(${dtkFonts_INCLUDE_DIRS})
include_directories(${dtkWidgets_INCLUDE_DIRS})

WINTZ Julien's avatar
WINTZ Julien committed
108 109 110 111 112 113 114
## #################################################################
## Dependencies - internal
## #################################################################

include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/dtkVisualization)
115
include_directories(${CMAKE_SOURCE_DIR}/src/dtkVisualizationFactory)
116
include_directories(${CMAKE_SOURCE_DIR}/src/dtkVisualizationWidgets)
WINTZ Julien's avatar
WINTZ Julien committed
117 118 119 120 121 122

## ###################################################################
## Input
## ###################################################################

add_subdirectory(src)
WINTZ Julien's avatar
WINTZ Julien committed
123
add_subdirectory(app)
124
add_subdirectory(exp)
WINTZ Julien's avatar
WINTZ Julien committed
125 126 127 128 129 130 131 132 133 134

## ###################################################################
## Exporting
## ###################################################################

export(PACKAGE ${PROJECT_NAME})

configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
  "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
135
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.install.cmake.in
WINTZ Julien's avatar
WINTZ Julien committed
136 137 138 139 140 141 142
  "${CMAKE_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake" @ONLY)

configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake.in
  "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" @ONLY)

install(FILES
  "${CMAKE_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
143 144
  "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  DESTINATION  ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
WINTZ Julien's avatar
WINTZ Julien committed
145

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
146
install(EXPORT ${PROJECT_NAME}Depends DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
WINTZ Julien's avatar
WINTZ Julien committed
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

## ###################################################################
## Beautifying
## ###################################################################

mark_as_advanced(${PROJECT_NAME}_VERSION_MAJOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_MINOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_BUILD)

mark_as_advanced(Qt5OpenGL_DIR)
mark_as_advanced(Qt5Concurrent_DIR)
mark_as_advanced(Qt5Core_DIR)
mark_as_advanced(Qt5Declarative_DIR)
mark_as_advanced(Qt5Gui_DIR)
mark_as_advanced(Qt5Network_DIR)
mark_as_advanced(Qt5Qml_DIR)
mark_as_advanced(Qt5Quick_DIR)
mark_as_advanced(Qt5QuickTest_DIR)
mark_as_advanced(Qt5Script_DIR)
mark_as_advanced(Qt5Test_DIR)
mark_as_advanced(Qt5Widgets_DIR)
mark_as_advanced(Qt5Xml_DIR)
mark_as_advanced(Qt5Sql_DIR)

mark_as_advanced(CMAKE_AR)
mark_as_advanced(CMAKE_BUILD_TYPE)
mark_as_advanced(CMAKE_INSTALL_PREFIX)
mark_as_advanced(CMAKE_OSX_ARCHITECTURES)
mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET)
mark_as_advanced(CMAKE_OSX_SYSROOT)

## ###################################################################
## Packaging
## ###################################################################

include(InstallRequiredSystemLibraries)

set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}")

include(CPack)

######################################################################
### CMakeLists.txt ends here