CMakeLists.txt 6.2 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(dtkWidgets)

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

25
set(${PROJECT_NAME}_VERSION_MAJOR 2)
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
26 27
set(${PROJECT_NAME}_VERSION_MINOR 10)
set(${PROJECT_NAME}_VERSION_PATCH 0)
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)

WINTZ Julien's avatar
WINTZ Julien committed
41 42 43
set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)

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 59 60 61 62 63 64 65 66 67 68 69 70 71
## #################################################################
## 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
## #################################################################

72
set(CMAKE_CXX_STANDARD 14)
WINTZ Julien's avatar
WINTZ Julien committed
73 74
set(CMAKE_CXX_STANDARD_REQUIRED ON)

75 76 77 78 79 80 81
## ###################################################################
## Test setup
## ###################################################################

include(CTest)
enable_testing()

WINTZ Julien's avatar
WINTZ Julien committed
82 83 84 85 86 87 88 89 90 91
## ###################################################################
## Dependencies - cmake
## ###################################################################

include(GenerateExportHeader)

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

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
92 93 94 95 96
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Xml Test)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
WINTZ Julien's avatar
WINTZ Julien committed
97

98
find_package(dtkCore REQUIRED)
99
find_package(dtkFonts REQUIRED)
100
find_package(dtkLog REQUIRED)
WINTZ Julien's avatar
WINTZ Julien committed
101
find_package(dtkThemes REQUIRED)
WINTZ Julien's avatar
WINTZ Julien committed
102

WINTZ Julien's avatar
WINTZ Julien committed
103 104 105 106 107
## ###################################################################
## Input
## ###################################################################

add_subdirectory(src)
108
add_subdirectory(tst)
109
add_subdirectory(exp)
WINTZ Julien's avatar
WINTZ Julien committed
110 111

## ###################################################################
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
112
## Export configuration
WINTZ Julien's avatar
WINTZ Julien committed
113 114
## ###################################################################

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
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)
WINTZ Julien's avatar
WINTZ Julien committed
131

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
132 133 134
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
  VERSION ${${PROJECT_NAME}_VERSION}
  COMPATIBILITY AnyNewerVersion)
WINTZ Julien's avatar
WINTZ Julien committed
135

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
136 137 138
## ###################################################################
## Exporting
## ###################################################################
WINTZ Julien's avatar
WINTZ Julien committed
139

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
140 141 142
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
143

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
144 145 146
install(EXPORT layer-targets
  FILE ${PROJECT_NAME}Targets.cmake
  DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
WINTZ Julien's avatar
WINTZ Julien committed
147

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
148
export(PACKAGE ${PROJECT_NAME})
WINTZ Julien's avatar
WINTZ Julien committed
149 150 151 152 153 154 155 156 157

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

160
mark_as_advanced(Qt5_DIR)
WINTZ Julien's avatar
WINTZ Julien committed
161 162
mark_as_advanced(Qt5Core_DIR)
mark_as_advanced(Qt5Gui_DIR)
163
mark_as_advanced(Qt5OpenGL_DIR)
WINTZ Julien's avatar
WINTZ Julien committed
164 165 166
mark_as_advanced(Qt5Test_DIR)
mark_as_advanced(Qt5Widgets_DIR)

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
167 168 169 170 171
mark_as_advanced(dtkCore_DIR)
mark_as_advanced(dtkFonts_DIR)
mark_as_advanced(dtkLog_DIR)
mark_as_advanced(dtkThemes_DIR)

WINTZ Julien's avatar
WINTZ Julien committed
172 173 174 175 176 177 178 179
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