106 lines
3.3 KiB
CMake
106 lines
3.3 KiB
CMake
# Copyright (c) 2022 Dominic Masters
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
|
|
|
set(DAWN_PROJECT_NAME "Dawn")
|
|
set(DAWN_PROJECT_VERSION "01.00")
|
|
|
|
# Variable Caches
|
|
set(DAWN_CACHE_TARGET "dawn-target")
|
|
|
|
# Build target
|
|
if(DEFINED ENV{DAWN_BUILD_SYSTEM})
|
|
set(DAWN_BUILD_SYSTEM $ENV{DAWN_BUILD_SYSTEM} CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
else()
|
|
set(DAWN_BUILD_SYSTEM "linux" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
endif()
|
|
|
|
# Build tools specifics
|
|
if(DAWN_BUILD_SYSTEM STREQUAL "vita")
|
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
if(DEFINED ENV{VITASDK})
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
|
|
else()
|
|
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
|
|
endif()
|
|
endif()
|
|
|
|
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
|
|
|
|
set(DAWN_VITA_APP_NAME "${DAWN_PROJECT_NAME}" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
set(DAWN_VITA_TITLEID "YWSH00001" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
set(DAWN_VITA_VERSION "${DAWN_PROJECT_VERSION}" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
|
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
if(DEFINED ENV{PSPDEV})
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{PSPDEV}/psp/share/pspdev.cmake" CACHE PATH "toolchain file")
|
|
else()
|
|
message(FATAL_ERROR "Please define PSPDEV to point to your SDK path!")
|
|
endif()
|
|
endif()
|
|
|
|
include("$ENV{PSPDEV}/psp/share/pspdev.cmake" REQUIRED)
|
|
endif()
|
|
|
|
# Set Common Build Variables
|
|
set(DAWN_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
|
set(DAWN_BUILD_DIR "${CMAKE_BINARY_DIR}")
|
|
set(DAWN_SOURCES_DIR "${DAWN_ROOT_DIR}/src")
|
|
set(DAWN_TEMP_DIR "${DAWN_BUILD_DIR}/temp")
|
|
set(DAWN_TOOLS_DIR "${DAWN_ROOT_DIR}/tools")
|
|
set(DAWN_ASSETS_DIR "${DAWN_ROOT_DIR}/assets")
|
|
set(DAWN_ASSETS_BUILD_DIR "${DAWN_BUILD_DIR}/assets")
|
|
|
|
# Variables
|
|
set(DAWN_TARGET_NAME "Dawn" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
set(DAWN_ASSETS "" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
set(DAWN_BUILD_BINARY ${DAWN_BUILD_DIR}/Dawn CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
|
|
|
# Initialize Project First.
|
|
project("${DAWN_PROJECT_NAME}"
|
|
VERSION "${DAWN_PROJECT_VERSION}"
|
|
LANGUAGES C CXX
|
|
)
|
|
|
|
add_executable(${DAWN_TARGET_NAME})
|
|
|
|
# Add tools
|
|
add_subdirectory(tools)
|
|
|
|
# Libraries
|
|
add_subdirectory(lib)
|
|
|
|
# Sources
|
|
add_subdirectory(src)
|
|
|
|
# Append assets
|
|
add_dependencies(${DAWN_TARGET_NAME} dawnassets)
|
|
|
|
if(DAWN_BUILD_SYSTEM STREQUAL "vita")
|
|
vita_create_self(${DAWN_TARGET_NAME}.self ${DAWN_BUILD_BINARY})
|
|
vita_create_vpk(
|
|
${DAWN_TARGET_NAME}.vpk
|
|
${DAWN_VITA_TITLEID}
|
|
${DAWN_TARGET_NAME}.self
|
|
VERSION ${DAWN_VITA_VERSION}
|
|
NAME ${DAWN_VITA_APP_NAME}
|
|
)
|
|
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
|
|
create_pbp_file(
|
|
TARGET ${PROJECT_NAME}
|
|
ICON_PATH NULL
|
|
BACKGROUND_PATH NULL
|
|
PREVIEW_PATH NULL
|
|
TITLE ${PROJECT_NAME}
|
|
VERSION ${DAWN_PROJECT_VERSION}
|
|
)
|
|
endif() |