From b1d1573702f21e3104606d6ade5f5d39ec86a33a Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Thu, 23 Jan 2025 22:02:11 +0100 Subject: restructure project --- CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bfbf5d..abd4f29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,49 @@ project( LANGUAGES CXX OBJCXX OBJC VERSION 1.0) -set(CMAKE_CXX_STANDARD 17) +option(NES_ENABLE_SANITIZER_ADDRESS "Enable address sanitizer." OFF) +option(NES_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Enable undefined behavior sanitizer." OFF) +option(NES_ENABLE_DEBUG_OUTPUT "Enable debug output." OFF) +option(NES_ENABLE_PPU "Enable Picture Processing Unit." ON) -add_executable(nes) -add_subdirectory(src) +add_library(nes_options INTERFACE) +add_library(nes::options ALIAS nes_options) +target_compile_features(nes_options INTERFACE cxx_std_17) +target_compile_options(nes_options + INTERFACE + -Wall + -Wextra + -Wnon-virtual-dtor + -Wcast-align + -Wunused + -Woverloaded-virtual + -Wpedantic + -Wconversion + -Wsign-conversion + -Wdouble-promotion + -Wformat=2 + -Wswitch-enum + -Wno-gnu-anonymous-struct) +if(APPLE) + # Use automatic reference counting for Objective-C code. + target_compile_options(nes_options INTERFACE "-fobjc-arc") +endif() +if(NES_ENABLE_SANITIZER_ADDRESS AND NES_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) + message(FATAL_ERROR "Address sanitizer and undefined behavior sanitizer cannot be enabled at the same time.") +elseif(NES_ENABLE_SANITIZER_ADDRESS) + target_compile_options(nes_options INTERFACE -fsanitize=address) +elseif(NES_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) + target_compile_options(nes_options INTERFACE -fsanitize=undefined) +endif() -find_library(FRAMEWORK_COCOA Cocoa REQUIRED) -find_library(FRAMEWORK_SPRITEKIT SpriteKit REQUIRED) -target_link_libraries(nes PRIVATE ${FRAMEWORK_COCOA} ${FRAMEWORK_SPRITEKIT}) \ No newline at end of file +if(NES_ENABLE_DEBUG_OUTPUT) + include(FetchContent) + FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.15.0) + FetchContent_MakeAvailable(spdlog) +endif() + +add_subdirectory(lib) +add_subdirectory(app) \ No newline at end of file -- cgit v1.3.1