CMakeLists.txt 6.65 KB
Newer Older
Julien Wintz's avatar
Julien Wintz 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)
Julien Wintz's avatar
Julien Wintz committed
16
17
18
19
20
21
22
23
24

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

project(dtkWidgets)

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

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
25
set(${PROJECT_NAME}_VERSION_MAJOR 2)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
26
set(${PROJECT_NAME}_VERSION_MINOR 22)
27
set(${PROJECT_NAME}_VERSION_PATCH 1)
Julien Wintz's avatar
Julien Wintz 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)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
41
42
43
44
45
46
47
48
49
50
## ###################################################################
## 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)

Julien Wintz's avatar
Julien Wintz committed
51
52
53
54
55
## #################################################################
## Install prefix
## #################################################################

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
56
  if (DEFINED ENV{CONDA_PREFIX})
57
    set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "${PROJECT_NAME} libdir" FORCE)
58
59
60
61
    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()
Julien Wintz's avatar
Julien Wintz committed
62
63
64
65
66
67
68
69
70
71
72
73
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

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

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")

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

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
74
set(CMAKE_CXX_STANDARD 14)
Julien Wintz's avatar
Julien Wintz committed
75
set(CMAKE_CXX_STANDARD_REQUIRED ON)
76

77
set(CMAKE_SKIP_BUILD_RPATH FALSE)
78
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
CABEL Tristan's avatar
CABEL Tristan committed
79
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
80
81
82
83
84
85
86
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)

if("${isSystemDir}" STREQUAL "-1")
   set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
Julien Wintz's avatar
Julien Wintz committed
87

88
89
90
91
92
93
94
## ###################################################################
## Test setup
## ###################################################################

include(CTest)
enable_testing()

Julien Wintz's avatar
Julien Wintz committed
95
96
97
98
99
100
101
102
103
104
## ###################################################################
## Dependencies - cmake
## ###################################################################

include(GenerateExportHeader)

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

105
find_package(Qt5 REQUIRED COMPONENTS Core Gui Quick QuickWidgets Widgets Xml Test)
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
106
107
108
109

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Julien Wintz's avatar
Julien Wintz committed
110

111
find_package(dtkCore REQUIRED)
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
112
find_package(dtkFonts REQUIRED)
113
find_package(dtkLog REQUIRED)
Julien Wintz's avatar
Julien Wintz committed
114
find_package(dtkThemes REQUIRED)
Julien Wintz's avatar
Julien Wintz committed
115

Julien Wintz's avatar
Julien Wintz committed
116
117
118
119
120
## ###################################################################
## Input
## ###################################################################

add_subdirectory(src)
121
add_subdirectory(tst)
122
add_subdirectory(exp)
Julien Wintz's avatar
Julien Wintz committed
123
124

## ###################################################################
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
125
## Export configuration
Julien Wintz's avatar
Julien Wintz committed
126
127
## ###################################################################

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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)

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)
Julien Wintz's avatar
Julien Wintz committed
144

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
145
146
147
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
  VERSION ${${PROJECT_NAME}_VERSION}
  COMPATIBILITY AnyNewerVersion)
Julien Wintz's avatar
Julien Wintz committed
148

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
149
150
151
## ###################################################################
## Exporting
## ###################################################################
Julien Wintz's avatar
Julien Wintz committed
152

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
153
154
155
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})
Julien Wintz's avatar
Julien Wintz committed
156

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
157
158
159
install(EXPORT layer-targets
  FILE ${PROJECT_NAME}Targets.cmake
  DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
Julien Wintz's avatar
Julien Wintz committed
160

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
161
export(PACKAGE ${PROJECT_NAME})
Julien Wintz's avatar
Julien Wintz committed
162
163
164
165
166
167
168
169
170

## ###################################################################
## 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
171
172
mark_as_advanced(${PROJECT_NAME}_CMAKE_INSTALL_DIR)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
173
mark_as_advanced(Qt5_DIR)
Julien Wintz's avatar
Julien Wintz committed
174
175
mark_as_advanced(Qt5Core_DIR)
mark_as_advanced(Qt5Gui_DIR)
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
176
mark_as_advanced(Qt5OpenGL_DIR)
Julien Wintz's avatar
Julien Wintz committed
177
mark_as_advanced(Qt5Test_DIR)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
178
mark_as_advanced(Qt5Xml_DIR)
Julien Wintz's avatar
Julien Wintz committed
179
180
181
182
183
184
185
186
187
188
mark_as_advanced(Qt5Widgets_DIR)

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

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