@@ -168,7 +168,9 @@ function(slang_add_target dir type)
168
168
# See: https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html
169
169
set_target_properties (
170
170
${target}
171
- PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
171
+ PROPERTIES
172
+ INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
173
+ INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE
172
174
)
173
175
174
176
#
@@ -200,12 +202,26 @@ function(slang_add_target dir type)
200
202
PDB_OUTPUT_DIRECTORY "${output_dir} /${runtime_subdir} "
201
203
)
202
204
203
- if (NOT MSVC )
204
- set_target_properties (
205
+ set (debug_configs "Debug,RelWithDebInfo" )
206
+ if (SLANG_ENABLE_RELEASE_DEBUG_INFO)
207
+ set (debug_configs "Debug,RelWithDebInfo,Release" )
208
+ endif ()
209
+
210
+ set_target_properties (
211
+ ${target}
212
+ PROPERTIES
213
+ MSVC_DEBUG_INFORMATION_FORMAT
214
+ "$<$<CONFIG:${debug_configs} >:Embedded>"
215
+ )
216
+ if (MSVC )
217
+ target_link_options (
218
+ ${target}
219
+ PRIVATE "$<$<CONFIG:${debug_configs} >:/DEBUG>"
220
+ )
221
+ else ()
222
+ target_compile_options (
205
223
${target}
206
- PROPERTIES
207
- COMPILE_OPTIONS
208
- "$<$<CONFIG:Debug,RelWithDebInfo>:-fdebug-prefix-map=${CMAKE_CURRENT_BINARY_DIR} =${output_dir} >"
224
+ PRIVATE "$<$<CONFIG:${debug_configs} >:-g>"
209
225
)
210
226
endif ()
211
227
@@ -234,70 +250,13 @@ function(slang_add_target dir type)
234
250
235
251
if (generate_split_debug_info)
236
252
if (MSVC )
237
- get_target_property (
238
- c_compiler_launcher
239
- ${target}
240
- C_COMPILER_LAUNCHER
241
- )
242
- get_target_property (
243
- cxx_compiler_launcher
244
- ${target}
245
- CXX_COMPILER_LAUNCHER
246
- )
247
-
248
- if (
249
- c_compiler_launcher MATCHES "ccache"
250
- OR cxx_compiler_launcher MATCHES "ccache"
251
- )
252
- message (
253
- WARNING
254
- "(s)ccache detected for target ${target} . Removing launcher as it's incompatible with split debug info compiled with MSVC."
255
- )
256
- set_target_properties (
257
- ${target}
258
- PROPERTIES C_COMPILER_LAUNCHER "" CXX_COMPILER_LAUNCHER ""
259
- )
260
- endif ()
261
-
262
- get_target_property (
263
- msvc_debug_information_format
264
- ${target}
265
- MSVC_DEBUG_INFORMATION_FORMAT
266
- )
267
- if (
268
- NOT msvc_debug_information_format
269
- MATCHES
270
- "(ProgramDatabase|EditAndContinue)"
271
- )
272
- message (
273
- WARNING
274
- "Debug format must be ProgramDatabase or EditAndContinue to generate split debug info with MSVC"
275
- )
276
- endif ()
277
-
278
253
set_target_properties (
279
254
${target}
280
255
PROPERTIES
281
- # While it would be nice to set this here, we don't know if
282
- # the user wants ProgramDatabase or EditAndContinue, so
283
- # just check above
284
- # MSVC_DEBUG_INFORMATION_FORMAT
285
- # "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>"
286
256
COMPILE_PDB_NAME "${target} "
287
257
COMPILE_PDB_OUTPUT_DIRECTORY "${output_dir} "
288
258
)
289
259
else ()
290
- # Common debug flags for GCC/Clang
291
- target_compile_options (
292
- ${target}
293
- PRIVATE
294
- $<$<CONFIG:Debug,RelWithDebInfo>:
295
- -g
296
- -fdebug-prefix -map=${CMAKE_SOURCE_DIR} =.
297
- -fdebug-prefix -map=${CMAKE_BINARY_DIR} =.
298
- >
299
- )
300
-
301
260
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" )
302
261
# macOS - use dsymutil with --flat to create separate debug file
303
262
add_custom_command (
@@ -582,7 +541,6 @@ function(slang_add_target dir type)
582
541
install (
583
542
FILES ${debug_file}
584
543
DESTINATION ${debug_dest}
585
- CONFIGURATIONS Debug RelWithDebInfo
586
544
COMPONENT ${debug_component}
587
545
EXCLUDE_FROM_ALL
588
546
OPTIONAL
0 commit comments