2015-07-15 23:26:11 +00:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
cmake_policy(SET CMP0012 NEW)
|
|
|
|
|
|
|
|
function(add_application name)
|
|
|
|
|
2019-01-08 23:11:12 +00:00
|
|
|
set(options DEBUGBREAK CONSOLE)
|
2015-07-15 23:26:11 +00:00
|
|
|
set(oneValueArgs TYPE CREATOR)
|
|
|
|
set(multiValueArgs FILES MAKEAPPL_ARGS)
|
2015-07-20 18:05:38 +00:00
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
|
|
|
|
|
|
|
list(APPEND ARGS_FILES ${ARGS_UNPARSED_ARGUMENTS})
|
|
|
|
|
2015-10-08 20:44:18 +00:00
|
|
|
set(REZ_FLAGS)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroPPC OR CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
2019-01-08 23:11:12 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
2015-10-08 20:44:18 +00:00
|
|
|
set(REZ_FLAGS -DTARGET_API_MAC_CARBON=1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
set(files)
|
2015-07-16 22:32:27 +00:00
|
|
|
set(rsrc_files)
|
2015-07-17 00:00:36 +00:00
|
|
|
set(rez_files)
|
2015-07-16 22:32:27 +00:00
|
|
|
foreach(f ${ARGS_FILES})
|
|
|
|
if(${f} MATCHES "\\.r$")
|
|
|
|
add_custom_command(
|
2015-07-17 00:00:17 +00:00
|
|
|
OUTPUT ${f}.rsrc.bin
|
2015-10-08 20:44:18 +00:00
|
|
|
COMMAND ${REZ} ${REZ_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${f} -I ${REZ_INCLUDE_PATH} -o ${f}.rsrc.bin
|
2018-01-06 02:04:51 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f})
|
|
|
|
list(APPEND rsrc_files "${CMAKE_CURRENT_BINARY_DIR}/${f}.rsrc.bin")
|
2015-07-17 00:00:36 +00:00
|
|
|
list(APPEND rez_files "${f}")
|
2015-07-16 22:32:27 +00:00
|
|
|
elseif(${f} MATCHES "\\.rsrc$")
|
2018-01-06 02:04:51 +00:00
|
|
|
get_filename_component(abspath "${f}" ABSOLUTE)
|
|
|
|
list(APPEND rsrc_files "${abspath}")
|
2015-07-16 22:32:27 +00:00
|
|
|
elseif(${f} MATCHES "\\.rsrc.bin$")
|
2018-01-06 02:04:51 +00:00
|
|
|
get_filename_component(abspath "${f}" ABSOLUTE)
|
|
|
|
list(APPEND rsrc_files "${abspath}")
|
|
|
|
else()
|
|
|
|
get_filename_component(abspath "${f}" ABSOLUTE)
|
|
|
|
list(APPEND files "${abspath}")
|
2015-07-16 22:32:27 +00:00
|
|
|
endif()
|
2015-07-15 23:26:11 +00:00
|
|
|
endforeach()
|
|
|
|
|
2015-07-17 00:00:36 +00:00
|
|
|
add_executable(${name} ${files} ${rez_files})
|
2015-07-15 23:26:11 +00:00
|
|
|
|
|
|
|
if(${ARGS_DEBUGBREAK})
|
2019-01-24 17:49:06 +00:00
|
|
|
target_link_options(${name} PRIVATE "LINKER:--defsym=__break_on_entry=1")
|
2015-07-15 23:26:11 +00:00
|
|
|
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()
|
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
# RetroConsole library uses C++:
|
|
|
|
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
endif()
|
|
|
|
|
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...)
|
|
|
|
list(APPEND ARGS_MAKEAPPL_ARGS "${f}")
|
2015-07-16 22:32:27 +00:00
|
|
|
endforeach()
|
|
|
|
|
2015-07-20 18:05:38 +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
|
|
|
|
|
|
|
if(TARGET libretro)
|
|
|
|
set_target_properties(${name} PROPERTIES LINK_DEPENDS libretro)
|
|
|
|
endif(TARGET libretro)
|
|
|
|
|
2015-08-31 22:04:20 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
|
|
|
|
|
2017-09-24 13:40:19 +00:00
|
|
|
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.code.bin)
|
2015-08-31 22:04:20 +00:00
|
|
|
|
|
|
|
add_custom_command(
|
2017-09-23 19:02:22 +00:00
|
|
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk ${name}.ad "%${name}.ad"
|
2015-10-08 20:44:18 +00:00
|
|
|
COMMAND ${REZ} ${REZ_FLAGS}
|
|
|
|
${REZ_TEMPLATES_PATH}/Retro68APPL.r
|
2015-08-31 22:04:20 +00:00
|
|
|
-I${REZ_INCLUDE_PATH}
|
2017-09-24 13:40:19 +00:00
|
|
|
--copy "${name}.code.bin"
|
|
|
|
-o "${name}.bin"
|
2018-05-05 10:30:19 +00:00
|
|
|
-t "${ARGS_TYPE}" -c "${ARGS_CREATOR}"
|
2018-05-13 22:03:14 +00:00
|
|
|
--cc "${name}.dsk" --cc "${name}.APPL" --cc "%${name}.ad"
|
2015-08-31 22:04:20 +00:00
|
|
|
${ARGS_MAKEAPPL_ARGS}
|
|
|
|
DEPENDS ${name} ${rsrc_files})
|
|
|
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
|
|
|
|
2015-10-06 22:03:28 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES RetroPPC OR CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
2019-01-08 23:11:12 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
2015-10-06 22:03:28 +00:00
|
|
|
set(REZ_TEMPLATE "${REZ_TEMPLATES_PATH}/RetroCarbonAPPL.r")
|
|
|
|
else()
|
|
|
|
set(REZ_TEMPLATE "${REZ_TEMPLATES_PATH}/RetroPPCAPPL.r")
|
|
|
|
endif()
|
|
|
|
|
2015-08-31 22:04:20 +00:00
|
|
|
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(
|
2017-09-23 19:02:22 +00:00
|
|
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk ${name}.ad "%${name}.ad"
|
2015-10-08 20:44:18 +00:00
|
|
|
COMMAND ${REZ}
|
|
|
|
${REZ_FLAGS}
|
|
|
|
${REZ_TEMPLATE}
|
2015-08-31 22:04:20 +00:00
|
|
|
-I${REZ_INCLUDE_PATH}
|
2015-09-08 23:25:59 +00:00
|
|
|
-DCFRAG_NAME="\\"${name}\\""
|
2015-08-31 22:04:20 +00:00
|
|
|
-o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL"
|
2017-09-23 19:02:22 +00:00
|
|
|
--cc "%${name}.ad"
|
2018-05-05 10:30:19 +00:00
|
|
|
-t "${ARGS_TYPE}" -c "${ARGS_CREATOR}"
|
2015-08-31 22:04:20 +00:00
|
|
|
--data ${name}.pef
|
|
|
|
${ARGS_MAKEAPPL_ARGS}
|
|
|
|
DEPENDS ${name}.pef ${rsrc_files})
|
|
|
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
|
|
|
endif()
|
|
|
|
|
2015-07-15 23:26:11 +00:00
|
|
|
endfunction()
|
|
|
|
|
2015-07-16 22:32:27 +00:00
|
|
|
cmake_policy(POP)
|