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