56 lines
1.7 KiB
CMake
56 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
|
|
project(epec-mcu-emulator LANGUAGES C)
|
|
|
|
option(WERROR "Treat warnings as errors" OFF)
|
|
option(UBSAN "Enable undefined behaviour sanitizer" OFF)
|
|
option(PERFMON "Monitor performance of game code" ON)
|
|
option(HOTRELOAD "Enable hot reloading of game code" OFF)
|
|
|
|
set(ASSET_DIR "${CMAKE_SOURCE_DIR}/assets"
|
|
CACHE STRING "Directory containing asset pack")
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
macro(set_default_target_options target)
|
|
set_property(TARGET ${target} PROPERTY C_STANDARD 11)
|
|
set_property(TARGET ${target} PROPERTY C_EXTENSIONS OFF)
|
|
target_compile_options(${target} PRIVATE -Wall -Wextra -pedantic)
|
|
if(${WERROR})
|
|
target_compile_options(${target} PRIVATE -Werror)
|
|
endif()
|
|
if(${UBSAN})
|
|
target_compile_options(${target} PRIVATE -fsanitize=undefined)
|
|
target_link_options(${target} PRIVATE -fsanitize=undefined)
|
|
endif()
|
|
if(${HOTRELOAD})
|
|
target_compile_definitions(engine PRIVATE HOTRELOAD)
|
|
endif()
|
|
endmacro()
|
|
|
|
add_custom_target(format
|
|
COMMAND sh ${CMAKE_SOURCE_DIR}/scripts/format.sh
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|
|
add_custom_target(check-format
|
|
COMMAND sh ${CMAKE_SOURCE_DIR}/scripts/check-format.sh
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|
|
add_custom_target(lint
|
|
COMMAND sh ${CMAKE_SOURCE_DIR}/scripts/lint.sh
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|
|
|
|
find_package(LibXml2 REQUIRED)
|
|
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2 SDL2main)
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
add_subdirectory(engine)
|
|
add_subdirectory(game)
|
|
|
|
# Really this should be in engine/CMakeLists.txt, but it has to go
|
|
# after the declaration of the game target.
|
|
if(${HOTRELOAD})
|
|
target_compile_definitions(engine PRIVATE GAMELIB=\"$<TARGET_FILE:game>\")
|
|
endif()
|