diff --git a/CMakeLists.txt b/CMakeLists.txt index 7792172b2f..77b9e46768 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,9 +334,12 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E false ) -# Target to generate only soh.o2r -add_custom_target( - GenerateSohOtr +# soh.o2r is rebuilt only when its inputs change, and is part of ALL so `install` never ships a stale one. +file(GLOB_RECURSE SOH_O2R_ASSETS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/*) +list(FILTER SOH_O2R_ASSETS EXCLUDE REGEX "/soh/assets/custom/shaders/") +file(GLOB_RECURSE SOH_O2R_SHADERS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/fast/shaders/*) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/soh/soh.o2r # copy LUS default shaders into assets/custom COMMAND ${CMAKE_COMMAND} -E rm -r -f ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/fast/shaders/ ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ @@ -347,9 +350,11 @@ add_custom_target( ${CMAKE_PROJECT_VERSION} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/soh/soh.o2r ${CMAKE_CURRENT_SOURCE_DIR}/soh.o2r COMMENT "Generating soh.o2r..." - DEPENDS soh-o2r-packer - BYPRODUCTS ${CMAKE_SOURCE_DIR}/soh.o2r ${CMAKE_BINARY_DIR}/soh/soh.o2r + DEPENDS soh-o2r-packer ${SOH_O2R_ASSETS} ${SOH_O2R_SHADERS} + BYPRODUCTS ${CMAKE_SOURCE_DIR}/soh.o2r + VERBATIM ) +add_custom_target(GenerateSohOtr ALL DEPENDS ${CMAKE_BINARY_DIR}/soh/soh.o2r) # ExtractAssets produced soh.o2r as well as the rom archives, so keep doing that. add_dependencies(ExtractAssets GenerateSohOtr)