@@ -312,6 +312,68 @@ function(add_nro_target target)
312
312
set_target_properties (${target} PROPERTIES LINK_FLAGS "-specs=${LIBNX} /switch.specs" )
313
313
endfunction ()
314
314
315
+ function (add_ovl_target target )
316
+ get_filename_component (target_we ${target} NAME_WE )
317
+
318
+ # Extract metadata from the target.
319
+ get_target_property (icon ${target} "ICON" )
320
+ get_target_property (romfs ${target} "ROMFS" )
321
+
322
+ set_app_icon(${icon} )
323
+
324
+ # Construct the `NROFLAGS` to invoke elf2nro with.
325
+ set (NROFLAGS "" )
326
+
327
+ # Set icon for the NRO, if given.
328
+ if (__HOMEBREW_ICON)
329
+ string (APPEND ${NROFLAGS} "--icon=\" ${__HOMEBREW_ICON} \" " )
330
+ endif ()
331
+
332
+ # Add RomFS to the NRO, if given.
333
+ if (NOT "${romfs} " STREQUAL "romfs-NOTFOUND" )
334
+ if (IS_DIRECTORY ${romfs} )
335
+ # RomFS is a directory, pass --romfsdir to
336
+ # elf2nro and let it build an image for us.
337
+ string (APPEND ${NROFLAGS} " --romfsdir=\" ${romfs} \" " )
338
+ else ()
339
+ # A RomFS image was provided, which can be
340
+ # supplied to the --romfs flag.
341
+ if (EXISTS ${romfs} )
342
+ string (APPEND ${NROFLAGS} " --romfs=\" ${romfs} \" " )
343
+ else ()
344
+ message (WARNING "The provided RomFS image at ${romfs} doesn't exist" )
345
+ endif ()
346
+ endif ()
347
+ endif ()
348
+
349
+ # Build the NRO file.
350
+ if (NOT NO_NACP)
351
+ if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .nacp)
352
+ __generate_nacp(${target} )
353
+ endif ()
354
+
355
+ add_custom_command (
356
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .ovl
357
+ COMMAND ${elf2nro} $<TARGET_FILE:${target} > ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .ovl --nacp=${CMAKE_CURRENT_BINARY_DIR} /${target_we} .nacp ${NROFLAGS}
358
+ DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .nacp
359
+ VERBATIM
360
+ )
361
+ else ()
362
+ message (STATUS "No .nacp file will be generated for ${target_we} .ovl" )
363
+
364
+ add_custom_command (
365
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .ovl
366
+ COMMAND ${elf2nro} $<TARGET_FILE:${target} > ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .ovl ${NROFLAGS}
367
+ DEPENDS ${target}
368
+ VERBATIM
369
+ )
370
+ endif ()
371
+
372
+ # Add the respective NRO target and set the required linker flags for the original target.
373
+ add_custom_target (${target_we} _ovl ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR} /${target_we} .ovl)
374
+ set_target_properties (${target} PROPERTIES LINK_FLAGS "-specs=${LIBNX} /switch.specs" )
375
+ endfunction ()
376
+
315
377
## Builds a .nso file from a given target.
316
378
##
317
379
## NSOs are the main executable format on the Switch, however
0 commit comments