[cmake] Improve OTRExporter asset extraction script, Lower required CMake to 3.16 (#1196)

* supply ZAPD.out path as an argument to extract_assets.py rather than regenerating the script

Generating an entirely new script file to change a string is excessive.
Instead, extract_assets.py takes in one optional positional argument that
contains the path to ZAPD.out, the original purpose for the string
replacement.

This also removes the need for the file(CHMOD ...) command, which bumps
the minimum cmake version all the way up to 3.19.

Additionally, there was an extra script being generated in
OTRExporter/CMakeLists.txt that used the same CHMOD logic, but did not
accurately declare its minimum version to 3.19, this removes that unused
logic.

* OTRExporter: accept a rom path as an argument to extract_assets.py
This commit is contained in:
Zaxus125 2022-08-16 02:34:30 -05:00 committed by GitHub
commit b7f9960a60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 20 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
@ -138,15 +138,15 @@ find_package(Python3 COMPONENTS Interpreter)
add_custom_target(
ExtractAssets
COMMAND ${CMAKE_COMMAND} -Dprogram=$<TARGET_FILE:ZAPD> -P ${CMAKE_SOURCE_DIR}/CMake/genscript.cmake
COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f oot.otr
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>"
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_BINARY_DIR}/soh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
COMMENT "Running asset extraction..."
DEPENDS ZAPD
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")