Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting the output directory to create_pbp_file macro #244

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/base/CreatePBP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ macro(create_pbp_file)
PREVIEW_PATH # optional, absolute path to .png file, 480x272
MUSIC_PATH # optional, absolute path to .at3 file
VERSION # optional, adds version information to PARAM.SFO
OUTPUT_DIR # optional, set the output directory for the EBOOT.PBP
)
set(options
BUILD_PRX # optional, generates and uses PRX file instead of ELF in EBOOT.PBP
Expand All @@ -30,6 +31,20 @@ macro(create_pbp_file)
set(ARG_VERSION "")
endif()

# set output directory to where the target is build if not set
if (NOT DEFINED ARG_OUTPUT_DIR)
set(ARG_OUTPUT_DIR $<TARGET_FILE_DIR:${ARG_TARGET}>)
else()
# Make sure the output directory exists
if(NOT IS_DIRECTORY ${ARG_OUTPUT_DIR})
add_custom_command(
TARGET ${APP} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
${ARG_OUTPUT_DIR}
)
endif()
endif()

# As pack-pbp takes undefined arguments in form of "NULL" string,
# set each undefined macro variable to such value:
foreach(arg ${oneValueArgs})
Expand Down Expand Up @@ -146,6 +161,13 @@ macro(create_pbp_file)
)
endif()

add_custom_command(
TARGET ${APP} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove
${ARG_OUTPUT_DIR}/PARAM.SFO
COMMENT "Cleaning up PARAM.SFO for target ${ARG_TARGET}"
)

add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD COMMAND
Expand Down