Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/cmake/AddPlatformExecutable.cmake
Joshua Goins ca2c2c9d3d Move all engine-specific models, materials etc. to a new base directory
This is a huge change, and basically breaks everything (as per usual!)

First of, this includes stuff like shaders so anything involving those
are broken and then fixed. A new BuildAssets cmake file is added to
aid in running AssetCompiler, and it seems to work fine on the engine
base assets.

The File API will eventually be revamped to handle this new way of
organizing the files and domains will eventually be gotten rid of all
together since I probably will replace it with game directory
priorities. As it stands right now, there isn't a way to easily
replace say - render_options.cfg with your own game-specific version.

Apple builds are probably broken by this commit (since I'm moving
around content and shader directories) to be fixed later.
2022-05-21 18:28:48 -04:00

80 lines
3.1 KiB
CMake
Executable file

function(set_output_dir target)
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
XCODE_GENERATE_SCHEME ON)
endfunction()
function(add_platform_executable)
cmake_parse_arguments(add_platform_executable
""
"TARGET;APP_CLASS;APP_INCLUDE;APP_NAME;SKIP_DATA"
"SRC"
${ARGN})
set(APP_CLASS ${add_platform_executable_APP_CLASS} CACHE INTERNAL "")
set(GAME_SRC ${add_platform_executable_SRC} CACHE INTERNAL "")
set(APP_INCLUDE ${add_platform_executable_APP_INCLUDE} CACHE INTERNAL "")
set(APP_NAME ${add_platform_executable_APP_NAME} CACHE INTERNAL "")
string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${PLATFORM_MAIN_FILE_NAME})
set(MYFILE_WITHOUT_EXT ${CMAKE_MATCH_1})
configure_file(${PLATFORM_MAIN_FILE_PATH} ${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}${MYFILE_WITHOUT_EXT})
if(COMMAND setup_target)
setup_target(${add_platform_executable_TARGET})
endif()
add_executable(${add_platform_executable_TARGET}
${PLATFORM_SOURCES}
${add_platform_executable_SRC}
${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}${MYFILE_WITHOUT_EXT})
set_engine_properties(${add_platform_executable_TARGET})
if("${PLATFORM_EXECUTABLE_PROPERTIES}" STREQUAL "")
else()
set_target_properties(${add_platform_executable_TARGET}
PROPERTIES
${PLATFORM_EXECUTABLE_PROPERTIES}
)
endif()
target_link_libraries(${add_platform_executable_TARGET}
PRIVATE
ExtraLibrariesPlatform
)
# there's no point in including the base assets if it doesn't need data at all,
# and this prevents a cyclic dependency with assetpipeline, modelcompiler, etc.
if(NOT ${add_platform_executable_SKIP_DATA})
add_dependencies(${add_platform_executable_TARGET} EngineBase)
endif()
if("${add_platform_executable_APP_NAME}")
set_target_properties(${add_platform_executable_TARGET} PROPERTIES XCODE_ATTRIBUTE_EXECUTABLE_NAME ${add_platform_executable_APP_NAME})
set_target_properties(${add_platform_executable_TARGET} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME ${add_platform_executable_APP_NAME})
endif()
if(COMMAND add_platform_commands)
add_platform_commands(${add_platform_executable_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/game ${add_platform_executable_SKIP_DATA})
endif()
set_output_dir(${add_platform_executable_TARGET})
endfunction()
function(add_platform)
cmake_parse_arguments(add_platform
"$"
"MAIN_FILE;DISPLAY_NAME"
"EXECUTABLE_PROPERTIES;LINK_LIBRARIES;COMPILE_OPTIONS;SRC"
${ARGN})
set(PLATFORM_MAIN_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${add_platform_MAIN_FILE} CACHE INTERNAL "")
set(PLATFORM_MAIN_FILE_NAME ${add_platform_MAIN_FILE} CACHE INTERNAL "")
set(PLATFORM_EXECUTABLE_PROPERTIES ${add_platform_EXECUTABLE_PROPERTIES} CACHE INTERNAL "")
set(PLATFORM_SOURCES ${add_platform_SRC} CACHE INTERNAL "")
add_library(ExtraLibrariesPlatform INTERFACE)
target_link_libraries(ExtraLibrariesPlatform INTERFACE ${add_platform_LINK_LIBRARIES})
endfunction()