2015-07-15 23:26:11 +00:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
cmake_policy(SET CMP0012 NEW)
|
|
|
|
|
|
|
|
function(add_application name)
|
|
|
|
|
|
|
|
set(options DEBUGBREAK CONSOLE)
|
|
|
|
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})
|
|
|
|
|
|
|
|
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
|
|
|
|
COMMAND ${REZ} ${CMAKE_CURRENT_SOURCE_DIR}/${f} -I ${REZ_INCLUDE_PATH} -o ${f}.rsrc.bin
|
2015-07-16 22:32:27 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f})
|
2015-07-17 00:00:17 +00:00
|
|
|
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$")
|
2015-08-26 20:13:21 +00:00
|
|
|
list(APPEND rsrc_files "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
2015-07-16 22:32:27 +00:00
|
|
|
elseif(${f} MATCHES "\\.rsrc.bin$")
|
2015-08-26 20:13:21 +00:00
|
|
|
list(APPEND rsrc_files "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
2015-07-16 22:32:27 +00:00
|
|
|
else()
|
|
|
|
list(APPEND files "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
|
|
|
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})
|
|
|
|
list(APPEND ARGS_MAKEAPPL_ARGS -b)
|
|
|
|
endif()
|
|
|
|
if(${ARGS_CONSOLE})
|
|
|
|
target_link_libraries(${name} RetroConsole)
|
|
|
|
|
|
|
|
# RetroConsole library uses C++:
|
|
|
|
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
endif()
|
|
|
|
|
2015-07-16 22:32:27 +00:00
|
|
|
foreach(f ${rsrc_files})
|
2015-07-20 18:05:38 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.flt)
|
|
|
|
|
|
|
|
add_custom_command(
|
2015-07-16 00:22:26 +00:00
|
|
|
OUTPUT ${name}.bin ${name}.APPL ${name}.dsk
|
2015-07-20 18:05:38 +00:00
|
|
|
#COMMAND ${MAKE_APPL} ${ARGS_MAKEAPPL_ARGS} -c "${name}.flt" -o "${name}"
|
2015-08-26 20:13:21 +00:00
|
|
|
COMMAND ${REZ} ${REZ_TEMPLATES_PATH}/Retro68APPL.r
|
2015-07-20 18:05:38 +00:00
|
|
|
-I${REZ_INCLUDE_PATH}
|
|
|
|
-DFLT_FILE_NAME="\\"${name}.flt\\""
|
|
|
|
-o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL"
|
|
|
|
-t ${ARGS_TYPE} -c ${ARGS_CREATOR}
|
|
|
|
${ARGS_MAKEAPPL_ARGS}
|
2015-07-16 22:32:27 +00:00
|
|
|
DEPENDS ${name} ${rsrc_files})
|
2015-07-15 23:26:11 +00:00
|
|
|
add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin)
|
|
|
|
endfunction()
|
|
|
|
|
2015-07-16 22:32:27 +00:00
|
|
|
cmake_policy(POP)
|