From a2af015223050bea7d06291967d122c54056ac45 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 8 May 2025 20:39:20 +0200 Subject: [PATCH] fix Cmakes for this disgrace called msvc and use dummy cartridge in tests --- CMakeLists.txt | 28 +++++++++++++++++++++++++--- src/core/CMakeLists.txt | 4 +++- src/raylib/CMakeLists.txt | 1 + test/core/CMakeLists.txt | 3 ++- test/raylib/CMakeLists.txt | 1 + test/raylib/itest_main.cpp | 2 +- 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f9e355..8ac363d 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 587fd6b..4511dda 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 eec3604..6177a23 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 c5d7727..eb10238 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 72a46de..ddfa5be 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 785c6f5..6909153 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 -- GitLab