42 lines
1.2 KiB
CMake
42 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
|
|
project(epec-mcu-emulator LANGUAGES C)
|
|
|
|
option(WERROR "Treat warnings as errors" OFF)
|
|
option(SANITIZERS "Enable memory and undefined behaviour sanitizers" OFF)
|
|
|
|
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 (${SANITIZERS})
|
|
target_compile_options(${target} PRIVATE -fsanitize=memory,undefined)
|
|
target_link_options(${target} PRIVATE -fsanitize=memory,undefined)
|
|
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)
|