@@ -268,48 +268,28 @@ elseif(${BUILD_SHARED_LIBS} STREQUAL "OFF")
268
268
list (APPEND switches "-link-defaultlib-shared=false" )
269
269
endif ()
270
270
271
- set (build_libdir "${CMAKE_BINARY_DIR} /lib${LIB_SUFFIX} " )
272
- set (install_libdir "${CMAKE_INSTALL_LIBDIR} " )
273
-
274
- # Default -rpath linker option when linking against shared libraries.
275
- if (SHARED_LIBS_SUPPORTED )
276
- set (build_rpath "${build_libdir} " )
277
- set (install_rpath "${install_libdir} " )
278
- endif ()
279
-
280
- makeConfSection (NAME "30-ldc-runtime-lib${LIB_SUFFIX} "
281
- SECTION "default"
282
-
283
- BUILD
284
- SWITCHES ${switches}
285
- LIB_DIRS OVERRIDE ${build_libdir}
286
- RPATH ${build_rpath}
287
-
288
- INSTALL
289
- SWITCHES ${switches}
290
- LIB_DIRS OVERRIDE ${install_libdir}
291
- RPATH ${install_rpath}
292
- )
271
+ # comp_args are arguments passed to ldc2 to change the triple
272
+ function (makeTripleConfig comp_args suffix build_libdir install_libdir )
273
+ set (name "30-ldc-runtime-lib${suffix} " )
274
+ set (sectionPlaceholder "LDC_CONF_MULTILIB_TRIPLE_REGEX" )
293
275
294
- # macOS has fat libraries; otherwise, append a separate config file section for the
295
- # multilib target and override the lib directory.
296
- if (MULTILIB AND NOT "${TARGET_SYSTEM} " MATCHES "APPLE" )
297
- set (build_libdir "${CMAKE_BINARY_DIR} /lib${MULTILIB_SUFFIX} " )
298
- set (install_libdir "${CMAKE_INSTALL_PREFIX} /lib${MULTILIB_SUFFIX} " )
276
+ # Default -rpath linker option when linking against shared libraries.
299
277
if (SHARED_LIBS_SUPPORTED )
300
278
set (build_rpath "${build_libdir} " )
301
279
set (install_rpath "${install_libdir} " )
302
280
endif ()
303
281
304
- set (name "31-ldc-runtime-lib${MULTILIB_SUFFIX} " )
305
- set (sectionPlaceholder "LDC_CONF_MULTILIB_TRIPLE_REGEX" )
306
282
makeConfSection (NAME "${name} "
307
283
SECTION "${sectionPlaceholder} "
284
+
308
285
BUILD
286
+ SWITCHES ${switches}
309
287
LIB_DIRS OVERRIDE ${build_libdir}
310
288
RPATH ${build_rpath}
289
+
311
290
INSTALL
312
- LIB_DIRS OVERRIDE ${install_libdir}
291
+ SWITCHES ${switches}
292
+ LIB_DIRS ${install_libdir}
313
293
RPATH ${install_rpath}
314
294
)
315
295
@@ -325,13 +305,13 @@ if(MULTILIB AND NOT "${TARGET_SYSTEM}" MATCHES "APPLE")
325
305
"${conf} "
326
306
"${sectionPlaceholder} "
327
307
# Next arguments are a compiler invocation for the desired triple
328
- "${LDC_EXE_FULL} " -m${MULTILIB_SUFFIX }
308
+ "${LDC_EXE_FULL} " ${D_FLAGS} ${comp_args }
329
309
)
330
310
if (LDC_EXE )
331
- # We need to get the -m32 target triple but the compiler
332
- # is not built yet. We can't depend on LDC_EXE since that
333
- # would cause a cycle so pass-through the needed commands
334
- # up to the root project and let it run them as POST_BUILD
311
+ # We need to get the target triple but the compiler is not
312
+ # built yet. We can't depend on LDC_EXE since that would
313
+ # cause a cycle so pass-through the needed commands up to
314
+ # the root project and let it run them as POST_BUILD
335
315
# commands. This avoids adding the config_files as
336
316
# transitive dependencies to all compiled D files.
337
317
#
@@ -345,6 +325,22 @@ if(MULTILIB AND NOT "${TARGET_SYSTEM}" MATCHES "APPLE")
345
325
execute_process (COMMAND ${fill_cmd} )
346
326
endif ()
347
327
endforeach ()
328
+
329
+ set (_ALL_CONF_INSTALL_FILES "${_ALL_CONF_INSTALL_FILES} " PARENT_SCOPE )
330
+ set (_LDC_POST_BUILD_COMMANDS "${_LDC_POST_BUILD_COMMANDS} " PARENT_SCOPE )
331
+ set (_LDC_POST_BUILD_BYPRODUCTS "${_LDC_POST_BUILD_BYPRODUCTS} " PARENT_SCOPE )
332
+ endfunction ()
333
+
334
+ set (build_libdir "${CMAKE_BINARY_DIR} /lib${LIB_SUFFIX} " )
335
+ set (install_libdir "${CMAKE_INSTALL_LIBDIR} " )
336
+ makeTripleConfig ("" "${LIB_SUFFIX} " "${build_libdir} " "${install_libdir} " )
337
+
338
+ # macOS has fat libraries; otherwise, append a separate config file section for the
339
+ # multilib target and override the lib directory.
340
+ if (MULTILIB AND NOT "${TARGET_SYSTEM} " MATCHES "APPLE" )
341
+ set (build_libdir "${CMAKE_BINARY_DIR} /lib${MULTILIB_SUFFIX} " )
342
+ set (install_libdir "${CMAKE_INSTALL_PREFIX} /lib${MULTILIB_SUFFIX} " )
343
+ makeTripleConfig ("-m${MULTILIB_SUFFIX} " "${MULTILIB_SUFFIX} " "${build_libdir} " "${install_libdir} " )
348
344
endif ()
349
345
350
346
if (LDC_EXE )
0 commit comments