CMakeLists.txt 8.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)
CABEL Tristan's avatar
CABEL Tristan committed
26
set(${PROJECT_NAME}_VERSION_MINOR 20)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
27
set(${PROJECT_NAME}_VERSION_PATCH 1)
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)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
44 45 46 47 48 49 50 51 52 53
## ###################################################################
## Default build type (RelWithDebInfo)
## ###################################################################

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)

WINTZ Julien's avatar
WINTZ Julien committed
54 55 56 57 58
## #################################################################
## Install prefix
## #################################################################

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
59
  if (DEFINED ENV{CONDA_PREFIX})
60
    set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "${PROJECT_NAME} libdir" FORCE)
61 62 63 64
    set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}" CACHE PATH "${PROJECT_NAME} install prefix" FORCE)
  else()
    set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "${PROJECT_NAME} install prefix" FORCE)
  endif()
WINTZ Julien's avatar
WINTZ Julien committed
65 66 67 68 69 70 71 72 73 74 75 76
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

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

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")

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

77
set(CMAKE_CXX_STANDARD 14)
WINTZ Julien's avatar
WINTZ Julien committed
78 79
set(CMAKE_CXX_STANDARD_REQUIRED ON)

80 81 82 83 84 85 86
## ###################################################################
## Test setup
## ###################################################################

include(CTest)
enable_testing()

WINTZ Julien's avatar
WINTZ Julien committed
87 88 89 90 91 92
## ###################################################################
## Dependencies - cmake
## ###################################################################

include(GenerateExportHeader)

93 94 95 96 97 98
## ##################################################################
##
## ##################################################################

option(DTKVISUALIZATION_USE_UPCOMING_VTK "" FALSE)

WINTZ Julien's avatar
WINTZ Julien committed
99 100 101 102
## #################################################################
## Dependencies - external
## #################################################################

103 104 105 106 107 108 109 110 111 112 113 114 115 116
if(DTKVISUALIZATION_USE_UPCOMING_VTK)
find_package(VTK COMPONENTS
  ChartsCore
  CommonCore
  CommonDataModel
  FiltersFlowPaths
  FiltersModeling
  FiltersSources
  GUISupportQt
  InteractionImage
  InteractionStyle
  IOCore
  IOImage
  IOXML
117
  IOLegacy
118 119 120 121 122 123 124 125 126 127 128
  RenderingAnnotation
  RenderingContext2D
  RenderingContextOpenGL2
  RenderingCore
  RenderingFreeType
  RenderingGL2PSOpenGL2
  RenderingOpenGL2
  RenderingVolumeOpenGL2
  ViewsContext2D
  REQUIRED)
else(DTKVISUALIZATION_USE_UPCOMING_VTK)
129 130
find_package(VTK COMPONENTS
  vtkChartsCore
CABEL Tristan's avatar
CABEL Tristan committed
131 132
  vtkCommonCore
  vtkCommonDataModel
133 134 135
  vtkFiltersFlowPaths
  vtkGUISupportQtOpenGL
  vtkInteractionImage
CABEL Tristan's avatar
CABEL Tristan committed
136 137 138 139 140 141
  vtkRenderingContext2D
  vtkRenderingContextOpenGL2
  vtkRenderingCore
  vtkRenderingFreeType
  vtkRenderingGL2PSOpenGL2
  vtkRenderingOpenGL2
142
  vtkRenderingVolumeOpenGL2
CABEL Tristan's avatar
CABEL Tristan committed
143
  vtkViewsContext2D
144
  vtkIOLegacy
145
  REQUIRED)
146
endif(DTKVISUALIZATION_USE_UPCOMING_VTK)
147

148 149 150 151
if(NOT DTKVISUALIZATION_USE_UPCOMING_VTK)
  include(${VTK_USE_FILE})
endif(NOT DTKVISUALIZATION_USE_UPCOMING_VTK)

152
find_package(Qt5 COMPONENTS Core Widgets Gui Xml Multimedia MultimediaWidgets OpenGL Test REQUIRED)
153

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
154 155
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
WINTZ Julien's avatar
WINTZ Julien committed
156

157
add_library(QtMultimedia_Private INTERFACE)
WINTZ Julien's avatar
WINTZ Julien committed
158

159 160
target_include_directories(QtMultimedia_Private INTERFACE ${Qt5Multimedia_PRIVATE_INCLUDE_DIRS})

161 162
find_package(dtkCore    REQUIRED)
find_package(dtkFonts   REQUIRED)
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
163
find_package(dtkWidgets REQUIRED)
164 165
find_package(dtkThemes  REQUIRED)
find_package(dtkLog     REQUIRED)
166

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
167 168 169 170 171
if(WIN32)
  set(OpenGL_GL_PREFERENCE "GLVND")
  find_package(OpenGL REQUIRED)
endif(WIN32)

WINTZ Julien's avatar
WINTZ Julien committed
172 173 174 175 176
## ###################################################################
## Input
## ###################################################################

add_subdirectory(src)
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
177 178
add_subdirectory(app)
add_subdirectory(exp)
179
add_subdirectory(tst)
WINTZ Julien's avatar
WINTZ Julien committed
180 181

## ###################################################################
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
182
## Export configuration
WINTZ Julien's avatar
WINTZ Julien committed
183 184
## ###################################################################

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
185 186 187 188 189 190 191 192 193 194
include(CMakePackageConfigHelpers)

set(${PROJECT_NAME}_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE
  STRING "install path for ${PROJECT_NAME}Config.cmake")

set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
  "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
  INSTALL_DESTINATION "${${PROJECT_NAME}_CMAKE_INSTALL_DIR}"
  PATH_VARS ${PROJECT_NAME}_INCLUDE_DIRS)
WINTZ Julien's avatar
WINTZ Julien committed
195

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
196 197 198 199 200
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
  ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
  INSTALL_DESTINATION "${${PROJECT_NAME}_CMAKE_INSTALL_DIR}"
  PATH_VARS ${PROJECT_NAME}_INCLUDE_DIRS)
WINTZ Julien's avatar
WINTZ Julien committed
201

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
202 203 204 205 206 207 208
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
  VERSION ${${PROJECT_NAME}_VERSION}
  COMPATIBILITY AnyNewerVersion)

## ###################################################################
## Exporting
## ###################################################################
WINTZ Julien's avatar
WINTZ Julien committed
209

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
210 211 212
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
              ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
  DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
WINTZ Julien's avatar
WINTZ Julien committed
213

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
214 215 216
install(EXPORT layer-targets
  FILE ${PROJECT_NAME}Targets.cmake
  DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
WINTZ Julien's avatar
WINTZ Julien committed
217

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
218
export(PACKAGE ${PROJECT_NAME})
WINTZ Julien's avatar
WINTZ Julien committed
219 220 221 222 223 224 225 226 227

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

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

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
228 229
mark_as_advanced(${PROJECT_NAME}_CMAKE_INSTALL_DIR)

WINTZ Julien's avatar
WINTZ Julien committed
230 231
mark_as_advanced(Qt5OpenGL_DIR)
mark_as_advanced(Qt5Concurrent_DIR)
232 233
mark_as_advanced(Qt5Multimedia_DIR)
mark_as_advanced(Qt5MultimediaWidgets_DIR)
WINTZ Julien's avatar
WINTZ Julien committed
234 235
mark_as_advanced(Qt5Core_DIR)
mark_as_advanced(Qt5Gui_DIR)
236 237 238
mark_as_advanced(Qt5Gui_DIR)
mark_as_advanced(Qt5Multimedia_DIR)
mark_as_advanced(Qt5MultimediaWidgets_DIR)
WINTZ Julien's avatar
WINTZ Julien committed
239
mark_as_advanced(Qt5Network_DIR)
240 241
mark_as_advanced(Qt5OpenGL_DIR)
mark_as_advanced(Qt5Sql_DIR)
242
mark_as_advanced(Qt5Test_DIR)
WINTZ Julien's avatar
WINTZ Julien committed
243 244 245
mark_as_advanced(Qt5Widgets_DIR)
mark_as_advanced(Qt5Xml_DIR)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
246 247 248 249 250 251
mark_as_advanced(dtkCore_DIR)
mark_as_advanced(dtkFonts_DIR)
mark_as_advanced(dtkLog_DIR)
mark_as_advanced(dtkThemes_DIR)
mark_as_advanced(dtkWidgets_DIR)

252 253
mark_as_advanced(VTK_DIR)

WINTZ Julien's avatar
WINTZ Julien committed
254 255 256 257 258 259 260 261
mark_as_advanced(CMAKE_AR)
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)

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