2015-07-15 23:26:11 +00:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
cmake_policy(SET CMP0012 NEW)
|
|
|
|
|
|
|
|
function(add_application name)
|
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
set(options DEBUGBREAK CONSOLE)
|
|
|
|
set(oneValueArgs TYPE CREATOR)
|
|
|
|
set(multiValueArgs FILES MAKEAPPL_ARGS)
|
|
|
|
|
|
|
|
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
|
|
|
|
|
|
|
list(APPEND ARGS_FILES ${ARGS_UNPARSED_ARGUMENTS})
|
|
|
|
|
|
|
|
set(REZ_FLAGS)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroPPC OR CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
|
|
|
set(REZ_FLAGS -DTARGET_API_MAC_CARBON=1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(files)
|
|
|
|
set(rsrc_files)
|
|
|
|
set(rez_files)
|
2021-11-24 23:40:36 +00:00
|
|
|
|
|
|
|
set(rez_include_options ${REZ_INCLUDE_PATH})
|
|
|
|
list(TRANSFORM rez_include_options PREPEND -I)
|
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
foreach(f ${ARGS_FILES})
|
2022-09-21 06:32:09 +00:00
|
|
|
get_filename_component(abspath "${f}" ABSOLUTE)
|
2019-08-18 11:21:00 +00:00
|
|
|
if(${f} MATCHES "\\.r$")
|
2022-09-21 06:32:09 +00:00
|
|
|
get_filename_component(rsrc_file "${f}" NAME)
|
|
|
|
set(rsrc_file "${CMAKE_CURRENT_BINARY_DIR}/${rsrc_file}.rsrc.bin")
|
2019-08-18 11:21:00 +00:00
|
|
|
add_custom_command(
|
2022-09-21 06:32:09 +00:00
|
|
|
OUTPUT ${rsrc_file}
|
|
|
|
COMMAND ${REZ} ${REZ_FLAGS} ${abspath} ${rez_include_options} -o ${rsrc_file}
|
|
|
|
DEPENDS ${abspath})
|
|
|
|
list(APPEND rsrc_files "${rsrc_file}")
|
|
|
|
list(APPEND rez_files "${abspath}")
|
2019-08-18 11:21:00 +00:00
|
|
|
elseif(${f} MATCHES "\\.rsrc$")
|
2018-01-06 02:04:51 +00:00
|
|
|
list(APPEND rsrc_files "${abspath}")
|
2019-08-18 11:21:00 +00:00
|
|
|
elseif(${f} MATCHES "\\.rsrc.bin$")
|
2018-01-06 02:04:51 +00:00
|
|
|
list(APPEND rsrc_files "${abspath}")
|
|
|
|
else()
|
|
|
|
list(APPEND files "${abspath}")
|
2019-08-18 11:21:00 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-07-15 23:26:11 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
add_executable(${name} ${files} ${rez_files})
|
2015-07-15 23:26:11 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
if(${ARGS_DEBUGBREAK})
|
|
|
|
target_link_options(${name} PRIVATE "LINKER:--defsym=__break_on_entry=1")
|
|
|
|
endif()
|
|
|
|
if(${ARGS_CONSOLE})
|
2019-01-13 21:53:26 +00:00
|
|
|
if(TARGET RetroConsole OR NOT (CMAKE_SYSTEM_NAME MATCHES RetroCarbon))
|
|
|
|
target_link_libraries(${name} RetroConsole)
|
|
|
|
else()
|
|
|
|
target_link_libraries(${name} RetroConsoleCarbon)
|
|
|
|
endif()
|
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
# RetroConsole library uses C++:
|
|
|
|
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
endif()
|
2015-07-15 23:26:11 +00:00
|
|
|
|
2018-01-08 23:29:02 +00:00
|
|
|
foreach(f ${rsrc_files})
|
|
|
|
# DO NOT add --copy here.
|
|
|
|
# The files in rsrc_files are guaranteed to be .rsrc or .rsrc.bin, so they
|
|
|
|
# will be recognized by Rez.
|
|
|
|
# Currently, the --copy flag has the side effect that Rez processes all --copy inputs
|
|
|
|
# before other inputs, so this messes up the overriding mechanics, leading to the wrong SIZE resource
|
|
|
|
# being included. (duplicate resources shouldn't be replaced silently, and overriding should be explicit...)
|
2019-08-18 11:21:00 +00:00
|
|
|
list(APPEND ARGS_MAKEAPPL_ARGS "${f}")
|
|
|
|
endforeach()
|
2015-07-16 22:32:27 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
if(NOT ARGS_TYPE)
|
|
|
|
set(ARGS_TYPE "APPL")
|
|
|
|
endif()
|
|
|
|
if(NOT ARGS_CREATOR)
|
|
|
|
set(ARGS_CREATOR "????")
|
|
|
|
endif()
|
2015-07-16 22:32:27 +00:00
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
if(TARGET retrocrt)
|
2019-08-12 20:37:22 +00:00
|
|
|
add_dependencies(${name} retrocrt)
|
2019-08-18 11:21:00 +00:00
|
|
|
endif(TARGET retrocrt)
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
|
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.code.bin)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk ${name}.ad "%${name}.ad"
|
|
|
|
COMMAND ${REZ} ${REZ_FLAGS}
|
|
|
|
${REZ_TEMPLATES_PATH}/Retro68APPL.r
|
2021-12-11 17:08:51 +00:00
|
|
|
${rez_include_options}
|
2019-08-18 11:21:00 +00:00
|
|
|
--copy "${name}.code.bin"
|
|
|
|
-o "${name}.bin"
|
|
|
|
-t "${ARGS_TYPE}" -c "${ARGS_CREATOR}"
|
|
|
|
--cc "${name}.dsk" --cc "${name}.APPL" --cc "%${name}.ad"
|
|
|
|
${ARGS_MAKEAPPL_ARGS}
|
|
|
|
DEPENDS ${name} ${rsrc_files})
|
|
|
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
|
|
|
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES RetroPPC OR CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
|
|
|
set(REZ_TEMPLATE "${REZ_TEMPLATES_PATH}/RetroCarbonAPPL.r")
|
|
|
|
else()
|
|
|
|
set(REZ_TEMPLATE "${REZ_TEMPLATES_PATH}/RetroPPCAPPL.r")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.xcoff)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${name}.pef
|
|
|
|
COMMAND ${MAKE_PEF} "${name}.xcoff" -o "${name}.pef"
|
|
|
|
DEPENDS ${name})
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk ${name}.ad "%${name}.ad"
|
|
|
|
COMMAND ${REZ}
|
|
|
|
${REZ_FLAGS}
|
|
|
|
${REZ_TEMPLATE}
|
2021-12-11 17:08:51 +00:00
|
|
|
${rez_include_options}
|
2019-08-18 11:21:00 +00:00
|
|
|
-DCFRAG_NAME="\\"${name}\\""
|
|
|
|
-o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL"
|
|
|
|
--cc "%${name}.ad"
|
|
|
|
-t "${ARGS_TYPE}" -c "${ARGS_CREATOR}"
|
|
|
|
--data ${name}.pef
|
|
|
|
${ARGS_MAKEAPPL_ARGS}
|
|
|
|
DEPENDS ${name}.pef ${rsrc_files})
|
|
|
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
|
|
|
endif()
|
2015-08-31 22:04:20 +00:00
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
endfunction()
|
|
|
|
|
2015-07-16 22:32:27 +00:00
|
|
|
cmake_policy(POP)
|