Dawn/archive/dawntools/prefabtool/CMakeLists.txt
2023-10-31 21:15:03 -05:00

60 lines
1.3 KiB
CMake

# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Texture Build Tool
project(prefabtool VERSION 1.0)
add_executable(prefabtool)
# Sources
target_sources(prefabtool
PRIVATE
${DAWN_SHARED_SOURCES}
${DAWN_TOOL_SOURCES}
PrefabTool.cpp
PrefabGen.cpp
PrefabParser.cpp
)
# Includes
target_include_directories(prefabtool
PUBLIC
${DAWN_SHARED_INCLUDES}
${DAWN_TOOL_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}
)
# Definitions
target_compile_definitions(prefabtool
PUBLIC
${DAWN_SHARED_DEFINITIONS}
DAWN_TOOL_INSTANCE=PrefabTool
DAWN_TOOL_HEADER="PrefabTool.hpp"
)
# Libraries
target_link_libraries(prefabtool
PUBLIC
${DAWN_BUILD_HOST_LIBS}
)
# Tool Function
function(tool_prefab in)
set(DEPS "")
if(DAWN_BUILD_TOOLS)
set(DEPS prefabtool)
endif()
STRING(REGEX REPLACE "[\.|\\|\/|\:]" "-" prefab_name ${in})
add_custom_target(prefab_${prefab_name}
COMMAND prefabtool --input="${in}" --output="${DAWN_GENERATED_DIR}/generatedprefabs" --sources="${DAWN_SOURCES_DIR}"
COMMENT "Generating prefab from ${in}"
DEPENDS ${DEPS}
)
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${DAWN_GENERATED_DIR}/generatedprefabs
)
add_dependencies(${DAWN_TARGET_NAME} prefab_${prefab_name})
endfunction()