-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
CMakeLists.txt
176 lines (139 loc) · 4.56 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# CMakeList.txt : CMake project for FastNoise2
cmake_minimum_required(VERSION 3.7.1)
project(FastNoise2 VERSION 0.10.0)
set(CMAKE_CXX_STANDARD 17)
message("FastNoise2 Arch: ${CMAKE_SYSTEM_PROCESSOR}")
if(CMAKE_SYSTEM_PROCESSOR MATCHES armv7)
set(FASTSIMD_COMPILE_ARMV7 true)
set(FASTSIMD_COMPILE_ARM true)
set(FASTSIMD_COMPILE_HAVE_NEON true)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
set(FASTSIMD_COMPILE_AARCH64 true)
set(FASTSIMD_COMPILE_ARM true)
set(FASTSIMD_COMPILE_HAVE_NEON true)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm64)
set(FASTSIMD_COMPILE_ARM true)
set(FASTSIMD_COMPILE_HAVE_NEON true)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm)
set(FASTSIMD_COMPILE_ARM true)
endif()
# determine whether this is a standalone project or included by other projects
if (NOT DEFINED FASTNOISE2_STANDALONE_PROJECT)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FASTNOISE2_STANDALONE_PROJECT ON)
else()
set(FASTNOISE2_STANDALONE_PROJECT OFF)
endif ()
endif()
# Build DLL
#set(BUILD_SHARED_LIBS ON)
option(FASTNOISE2_NOISETOOL "Build NoiseTool application" ${FASTNOISE2_STANDALONE_PROJECT})
option(FASTNOISE2_TESTS "Build tests" OFF)
if(MSVC)
#setup pdb target location
set(pdb_output_dir "${CMAKE_CURRENT_BINARY_DIR}/pdb-files")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${pdb_output_dir}")
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${pdb_output_dir}")
#need to sync pdb files
add_compile_options("/FS")
endif()
# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
include(GNUInstallDirs)
set(install_targets "")
add_subdirectory(src)
if(FASTNOISE2_NOISETOOL)
include(cmake/CPM.cmake)
add_subdirectory(NoiseTool)
endif()
if(FASTNOISE2_TESTS)
include(cmake/CPM.cmake)
add_subdirectory(tests)
endif()
#Install -----------------------------------------------------------
# Layout. This works for all platforms:
# * <prefix>/lib*/cmake/<PROJECT-NAME>
# * <prefix>/lib*/
# * <prefix>/include/
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# Include module with fuction 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
# Use:
# * PROJECT_VERSION
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * TARGETS_EXPORT_NAME
# * PROJECT_NAME
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
# Targets:
# * <prefix>/lib/libname.a
# * header location after install: <prefix>/include/${PROJECT_NAME}/include.hpp
# * headers can be included by C++ code `#include <${PROJECT_NAME}/include.hpp>`
install(
TARGETS ${install_targets}
EXPORT "${targets_export_name}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
# Headers:
install(
FILES ${install_fastsimd_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FastSIMD"
)
install(
FILES ${install_fastnoise_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FastNoise"
)
install(
FILES ${install_fastnoise_generators_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FastNoise/Generators"
)
# Config
# * <prefix>/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake
# * <prefix>/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
# Config
# * <prefix>/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
if(MSVC)
#install pdbs
get_cmake_property(is_multi GENERATOR_IS_MULTI_CONFIG)
if(is_multi)
set(config_suffix "$<CONFIG>")
else()
set(config_suffix "")
endif()
if(BUILD_SHARED_LIBS)
set(pdb_dst ${CMAKE_INSTALL_BINDIR})
else()
set(pdb_dst ${CMAKE_INSTALL_LIBDIR})
endif()
install(
DIRECTORY "${pdb_output_dir}/${config_suffix}/"
DESTINATION ${pdb_dst}
)
endif()