-
Notifications
You must be signed in to change notification settings - Fork 118
/
CMakeLists.txt
159 lines (122 loc) · 5.41 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# This file is part of OpenREALM.
#
# Copyright (C) 2018 Alexander Kern <laxnpander at gmail dot com> (Braunschweig University of Technology)
# For more information see <https://github.com/laxnpander/OpenREALM>
#
# OpenREALM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenREALM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenREALM. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.15)
project(OpenREALM)
set(OpenREALM_VERSION "1.0.0")
set(OpenREALM_VERSION_NUMBER "1000")
################################################################################
# Paths
################################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_INCLUDE_PATH "/usr/local/include")
if(UNIX)
include(GNUInstallDirs)
set(OpenREALM_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
set(OpenREALM_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(OpenREALM_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(OpenREALM_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(OpenREALM_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(OpenREALM_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/OpenREALM")
set(OpenREALM_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/OpenREALM")
#elseif(WIN32)
# set(OpenREALM_INC_INSTALL_DIR "include/OpenREALM")
# set(OpenREALM_RUNTIME_INSTALL_DIR "bin")
# set(OpenREALM_LIBRARY_INSTALL_DIR "bin")
# set(OpenREALM_ARCHIVE_INSTALL_DIR "lib")
# set(OpenREALM_FRAMEWORK_INSTALL_DIR "bin")
#
# set(OpenREALM_CMAKE_CONFIG_INSTALL_DIR "share/OpenREALM/cmake")
# set(OpenREALM_ADDITIONAL_FILES_INSTALL_DIR "share/OpenREALM")
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
message(FATAL_ERROR "Could not set install folders for this platform!")
endif()
################################################################################
# Include CMake dependencies
################################################################################
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(CheckCXXCompilerFlag)
include(CheckLanguage)
include(CMakePackageConfigHelpers)
################################################################################
# Options
################################################################################
option(TESTS_ENABLED "Whether to build test binaries" OFF)
if(TESTS_ENABLED)
enable_testing()
include(cmake/googletest.cmake)
fetch_googletest(
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_BINARY_DIR}/googletest
)
endif()
################################################################################
# Compiler specific configuration
################################################################################
if(CMAKE_BUILD_TYPE)
message(STATUS "Build type specified as ${CMAKE_BUILD_TYPE}")
else()
message(STATUS "Build type not specified, using Release")
set(CMAKE_BUILD_TYPE Release)
set(IS_DEBUG OFF)
endif()
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
message(STATUS "CUDA Support enabled.")
include(FindCUDA)
set(CUDA_ARCH_LIST Auto CACHE STRING "List of CUDA architectures (e.g. Pascal, Volta, etc) or \
compute capability versions (6.1, 7.0, etc) to generate code for. \
Set to Auto for automatic detection (default).")
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCH_LIST})
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS})
else()
message(STATUS "CUDA Support disabled.")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
################################################################################
# Add modules
################################################################################
add_subdirectory(modules)
################################################################################
# Install
################################################################################
# Create and install version file
set(version_file "${CMAKE_CURRENT_BINARY_DIR}/OpenREALMConfigVersion.cmake")
write_basic_package_version_file(${version_file}
VERSION ${OpenREALM_VERSION}
COMPATIBILITY ExactVersion
)
install(FILES ${version_file}
DESTINATION ${OpenREALM_CMAKE_CONFIG_INSTALL_DIR})
# install readme and license
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_SOURCE_DIR}/README.md"
DESTINATION ${OpenREALM_ADDITIONAL_FILES_INSTALL_DIR}
)
install(
EXPORT OpenREALMTargets
DESTINATION ${OpenREALM_CMAKE_CONFIG_INSTALL_DIR}
FILE OpenREALMConfig.cmake
)
################################################################################
# Done :)
################################################################################