Repository navigation
Expand file tree
/
Copy pathFindTOPS.cmake
More file actions
253 lines (216 loc) · 9 KB
/
Copy pathFindTOPS.cmake
File metadata and controls
253 lines (216 loc) · 9 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# ========================================================================
# FindTOPS.cmake - Documentation for TOPS-related variables
# ========================================================================
# This file documents variables related to the TOPS toolkit and their usage.
#
# ========================================================================
# Variables
# ========================================================================
# CMAKE_TOPS_COMPILER_TOOLKIT_ROOT
# Path to the folder containing the TOPS toolkit.
# Usage:
# set(CMAKE_TOPS_COMPILER_TOOLKIT_ROOT "${CMAKE_BINARY_DIR}/opt/tops")
# TOPSToolkit_TOPSCC_EXECUTABLE
# Path to the `topscc` executable.
# Usage:
# Evaluated internally; no need for the user to set.
# TOPSToolkit_BIN_DIR
# Path to the folder containing the `topscc` executable.
# Usage:
# Evaluated internally; no need for the user to set.
# TOPSToolkit_ROOT_DIR
# Path to the folder containing the TOPS toolkit.
# Usage:
# Evaluated internally; no need for the user to set.
# CMAKE_TOPS_COMPILER
# Exact path to the `topscc` executable.
# Usage:
# Evaluated internally; no need for the user to set.
# TOPS_PATH
# Path to the folder containing the TOPS toolkit.
# Usage:
# Evaluated internally; no need for the user to set.
# TOPS_TOPSRT
# Path to the `libtopsrt.so` shared library.
# Usage:
# Evaluated internally; no need for the user to set.
# CMAKE_TOPS_COMPILER_INIT
# Return value of a check determining whether `CMAKE_TOPS_COMPILER` has been
# initialized. Uses the compiler from the environment if not found.
# Usage:
# Evaluated internally; no need for the user to set.
# CMAKE_TOPS_COMPILER_ARG1
# Used to include additional flags from the environment variable
# for the compiler during compilation.
# Usage:
# Evaluated internally; no need for the user to set.
# TOPSToolkit_VERSION
# Version of the TOPS toolkit as reported by `topscc --version`.
# Usage:
# Use for logging purposes:
# message(TOPSToolkit_VERSION: ${TOPSToolkit_VERSION})
# CMAKE_TOPS_HOST_COMPILER
# Path to the compiler for host code in `.tops` files.
# Usage:
# Evaluated internally; no need for the user to set.
# CMAKE_TOPS_LIBRARY_ARCHITECTURE
# Architecture-specific library directory names (e.g., `x86_64-linux-gnu`).
# Usage:
# Use for logging purposes:
# message(CMAKE_TOPS_LIBRARY_ARCHITECTURE: ${CMAKE_TOPS_LIBRARY_ARCHITECTURE})
# CMAKE_TOPS_COMPILER_ENV_VAR
# Name of the environment variable used to locate the `topscc` executable.
# Usage:
# Evaluated internally; no need for the user to set.
# CMAKE_TOPS_IMPLICIT_LINK_DIRECTORIES
# Directories containing libraries to link targets created using `topscc`.
# Usage:
# Developers may modify paths if required in `CMakeTOPSDetermineCompiler.cmake`.
# CMAKE_TOPS_IMPLICIT_LINK_LIBRARIES
# Libraries to link targets created using `topscc`.
# Usage:
# Developers may add common libraries in `CMakeTOPSDetermineCompiler.cmake`.
# CMAKE_TOPS_IMPLICIT_INCLUDE_DIRECTORIES
# Include directories for headers required to compile `.tops` files.
# Usage:
# Developers may add directories in `CMakeTOPSDetermineCompiler.cmake`.
# CMAKE_TOPS_PLATFORM_ID
# ID of the platform on which `.tops` code is being compiled (e.g., Linux).
# Usage:
# Use for logging purposes:
# message(CMAKE_TOPS_PLATFORM_ID: ${CMAKE_TOPS_PLATFORM_ID})
# CMAKE_TOPS_TOOLKIT_INCLUDE_DIRECTORIES
# Include directories for `topsrt`-related headers.
# Usage:
# Use for both TOPS and non-TOPS targets:
# target_include_directories(target_name PRIVATE ${CMAKE_TOPS_TOOLKIT_INCLUDE_DIRECTORIES})
# CMAKE_TOPS_STANDARD
# Compilation standard for `.tops` files (C++11, C++14, C++17).
# Usage:
# To change the standard:
# set(CMAKE_TOPS_STANDARD <version>)
# update_tops_flags()
# CMAKE_TOPS_STANDARD_REQUIRED
# Boolean to enforce the `CMAKE_TOPS_STANDARD`.
# Usage:
# To enforce the standard:
# set(CMAKE_TOPS_STANDARD_REQUIRED ON)
# CMAKE_TOPS_FLAGS
# Common compilation flags for `.tops` files.
# Usage:
# Add flags in the repository:
# add_tops_compile_flags(--flag1 --flag2)
# CMAKE_TOPS_OUTPUT_EXTENSION
# Extensions for output files after compiling `.tops` files.
# Usage:
# To set additional extensions:
# set(CMAKE_TOPS_OUTPUT_EXTENSION .<extension>)
# CMAKE_TOPS_SOURCE_FILE_EXTENSIONS
# Extensions for TOPS language source files.
# Usage:
# To set additional extensions:
# set(CMAKE_TOPS_SOURCE_FILE_EXTENSIONS <extension>)
# TOPSToolkit_TOPSPTI_INCLUDE_DIR
# Include directory for `topspti`-related headers.
# Usage:
# Use for non-TOPS targets requiring `topspti` headers.
# TOPSToolkit_TARGET_DIR
# Root directory set according to the compiler. Handles cross-compilation.
# Usage:
# Evaluated internally.
# TOPSToolkit_FOUND
# Boolean indicating whether the TOPS toolkit is found.
# Usage:
# Use for logging purposes:
# message(TOPSToolkit_FOUND: ${TOPSToolkit_FOUND})
# TOPSToolkit_VERSION_MAJOR
# Major version of the TOPS toolkit.
# Usage:
# Use for logging purposes:
# message(TOPSToolkit_VERSION_MAJOR: ${TOPSToolkit_VERSION_MAJOR})
# TOPSToolkit_VERSION_MINOR
# Minor version of the TOPS toolkit.
# Usage:
# Use for logging purposes:
# message(TOPSToolkit_VERSION_MINOR: ${TOPSToolkit_VERSION_MINOR})
# TOPSToolkit_VERSION_PATCH
# Patch version of the TOPS toolkit.
# Usage:
# Use for logging purposes:
# message(TOPSToolkit_VERSION_PATCH: ${TOPSToolkit_VERSION_PATCH})
# TOPSToolkit_TARGET_NAMES
# Target directory names based on the system processor.
# Usage:
# Evaluated internally.
# CMAKE_TOPS_ARCHITECTURE
# Architectures supported globally in the repository.
# Usage:
# To set a single architecture:
# set(CMAKE_TOPS_ARCHITECTURES "gcu400")
# update_tops_flags()
#===========================================================================
# FindTops.cmake
# Function to update TOPS flags based on the standard
function(update_tops_flags)
if (CMAKE_TOPS_STANDARD)
string(FIND "${CMAKE_TOPS_FLAGS}" "-std=c++${CMAKE_TOPS_STANDARD}" PRESENT)
if(PRESENT EQUAL -1)
list(FIND SUPPORTED_TOPS_STANDARDS ${CMAKE_TOPS_STANDARD} INDEX)
if(INDEX EQUAL -1)
if (NOT CMAKE_TOPS_STANDARD_REQUIRED)
message(WARNING "C++${CMAKE_TOPS_STANDARD} is not supported. Falling back to a lower version from supported versions ${SUPPORTED_TOPS_STANDARDS}.")
set(FALLBACK_VERSION "")
foreach(v IN LISTS SUPPORTED_TOPS_STANDARDS)
if(v LESS_EQUAL ${CMAKE_TOPS_STANDARD})
set(FALLBACK_VERSION ${v})
endif()
endforeach()
if(FALLBACK_VERSION)
message(WARNING " Falling back to version ${FALLBACK_VERSION}.")
set(CMAKE_TOPS_STANDARD_COMPILE_FLAG " -std=c++${FALLBACK_VERSION}")
else()
message(FATAL_ERROR "No supported version found to fall back to.")
endif()
else()
message(FATAL_ERROR "CMAKE_TOPS_STANDARD_REQUIRED is ON. The standard C++${CMAKE_TOPS_STANDARD} is not supported by TOPS. Please pass a supported TOPS standards are ${SUPPORTED_CPP_STANDARDS} or keep the CMAKE_TOPS_STANDARD_REQUIRED as OFF.")
endif()
else()
set(CMAKE_TOPS_STANDARD_COMPILE_FLAG " -std=c++${CMAKE_TOPS_STANDARD}")
endif()
set(CMAKE_TOPS_FLAGS "${CMAKE_TOPS_FLAGS} ${CMAKE_TOPS_STANDARD_COMPILE_FLAG}")
set(CMAKE_TOPS_FLAGS "${CMAKE_TOPS_FLAGS}" PARENT_SCOPE)
endif()
endif()
if (CMAKE_TOPS_ARCHITECTURES)
string(FIND "${CMAKE_TOPS_FLAGS}" "-arch ${CMAKE_TOPS_ARCHITECTURES}" PRESENT)
if(PRESENT EQUAL -1)
set(CMAKE_TOPS_FLAGS "${CMAKE_TOPS_FLAGS} -arch ${CMAKE_TOPS_ARCHITECTURES}")
set(CMAKE_TOPS_FLAGS ${CMAKE_TOPS_FLAGS} PARENT_SCOPE)
endif()
endif()
endfunction()
# Initial call to set flags based on the initial CMAKE_TOPS_STANDARD value
update_tops_flags()
function(target_tops_compile_features target scope feature)
if(feature MATCHES "tops_std_([0-9]+)")
set(version ${CMAKE_MATCH_1})
list(FIND SUPPORTED_TOPS_STANDARDS ${version} INDEX)
if (INDEX EQUAL -1)
message(FATAL_ERROR "${feature} not in tops supported versions: ${SUPPORTED_TOPS_STANDARDS}. Please Pass a valid tops c++ version")
else()
target_compile_options(${target} ${scope} $<$<COMPILE_LANGUAGE:TOPS>:-std=c++${CMAKE_MATCH_1}>)
endif()
else()
message(FATAL_ERROR "Unknown TOPS Standard compile feature")
endif()
endfunction()
# ###########################################################################
# #### help functions for add flags to CMAKE_TOPS_FLAGS #####################
# ###########################################################################
# Add a list of flags to 'LIBTOPS_COMPILE_FLAGS'.
macro(add_tops_compile_flags)
foreach(f ${ARGN})
set(CMAKE_TOPS_FLAGS "${CMAKE_TOPS_FLAGS} ${f}")
list(APPEND LIBTOPS_COMPILE_FLAGS ${f})
endforeach()
endmacro()