diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f9e355fece042e7ab924b4f2f2515c5f13cfe45..8ac363db94c92598735fce7da647134c6f899153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,35 @@ -cmake_minimum_required(VERSION 3.31) - +cmake_minimum_required(VERSION 3.28.3) project(gameboy C CXX) +function(add_strict_warnings target) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(${target} PRIVATE + -Wall + -Wextra + -Wpedantic + -Wconversion + -Werror + ) + elseif(MSVC) + target_compile_options(${target} PRIVATE + /W4 + /w14928 # Covers some -Wextra warnings (illegal copy-initialization) + /w14265 # Covers some -Wextra warnings (class with virtual functions but non-virtual destructor) + /permissive- # Standards compliance (-Wpedantic) + /w14242 # Conversion warnings (-Wconversion) + /w14244 # Conversion warnings (-Wconversion) + /w14254 # Conversion warnings (-Wconversion) + /w14267 # Conversion warnings (-Wconversion) + ) + endif() +endfunction() + set(CMAKE_C_STANDARD 23) set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion") set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 587fd6b175865edd964cc25f8e1e476ca73c7567..4511dda03e8a4543a16b21576f2656440be71db3 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,2 +1,4 @@ file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") -add_library(gb_core STATIC ${SOURCES}) +add_library(gb_core STATIC ${SOURCES} + emulator.cpp) +add_strict_warnings(gb_core) diff --git a/src/raylib/CMakeLists.txt b/src/raylib/CMakeLists.txt index eec3604f7c8ce7c3b72946478ff0f3a8b141bb47..6177a231841c39105554e55ee952695833d78249 100644 --- a/src/raylib/CMakeLists.txt +++ b/src/raylib/CMakeLists.txt @@ -1,5 +1,6 @@ file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") add_library(gb_raylib STATIC ${SOURCES}) +add_strict_warnings(gb_raylib) # Adding Raylib include(FetchContent) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index c5d77270619c47cd6ed087ab980e666f5af44d35..eb1023806521098ac1e5b9cbbb5eefeb51b593c6 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -8,6 +8,7 @@ add_executable(test_core ${CMAKE_SOURCE_DIR}/test/desktop_logging.cpp ${CORE_TESTS} ) +add_strict_warnings(test_core) target_link_libraries(test_core PRIVATE @@ -15,4 +16,4 @@ target_link_libraries(test_core gb_core ) -catch_discover_tests(test_core) +catch_discover_tests(test_core) \ No newline at end of file diff --git a/test/raylib/CMakeLists.txt b/test/raylib/CMakeLists.txt index 72a46dee37712a105207a1d26fa4d493be5d0f7e..ddfa5be1074b54066966fafea343970f728d682b 100644 --- a/test/raylib/CMakeLists.txt +++ b/test/raylib/CMakeLists.txt @@ -35,6 +35,7 @@ foreach(itest ${RAYLIB_INTERACTIVE_TESTS}) ${itest} ${HELPER_FILE} ) + add_strict_warnings(itest_raylib_${test_name}) target_link_libraries(itest_raylib_${test_name} PRIVATE diff --git a/test/raylib/itest_main.cpp b/test/raylib/itest_main.cpp index 785c6f5e4c36d279ca027efede4288bf18636a9a..69091531dfd6022797eeb7fcb68ce432c9b03a36 100644 --- a/test/raylib/itest_main.cpp +++ b/test/raylib/itest_main.cpp @@ -47,7 +47,7 @@ protected: }; // Define our emulator type using the Emulator template with our implementations -using LittleBoyEmulator = Emulator; +using LittleBoyEmulator = Emulator; int main() { // Initialize emulator