-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
80 lines (61 loc) · 2.71 KB
/
CMakeLists.txt
File metadata and controls
80 lines (61 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.20)
project(Chip8 VERSION 0.1.0 LANGUAGES CXX)
#-------------------------------------------------------------------------------
# Compiler Configuration
#-------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(PRODUCTION_BUILD "Make this a production build" OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
add_compile_options(/W4 /permissive-)
else()
add_compile_options(-Wall -Wextra -pedantic -Wconversion)
endif()
#-------------------------------------------------------------------------------
# Dependencies
#-------------------------------------------------------------------------------
include(FetchContent)
# GoogleTest
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.17.0
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
#-------------------------------------------------------------------------------
# Vendor Includes
#-------------------------------------------------------------------------------
# Suppress warnings for olcPixelGameEngine
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/vendor/PGE)
#-------------------------------------------------------------------------------
# Source and Core Library
#-------------------------------------------------------------------------------
# Gather only core source files (excluding main.cpp)
file(GLOB_RECURSE CORE_SRC CONFIGURE_DEPENDS src/*.cpp src/*.h)
# Build core logic as a static library
add_library(Chip8Core STATIC ${CORE_SRC})
target_include_directories(Chip8Core PUBLIC src)
# Optional: define ROMS_PATH for dev builds
if(NOT PRODUCTION_BUILD)
target_compile_definitions(Chip8Core PUBLIC ROMS_PATH="${PROJECT_SOURCE_DIR}/roms/")
endif()
#-------------------------------------------------------------------------------
# Application Executable
#-------------------------------------------------------------------------------
add_executable(${PROJECT_NAME} main/main.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC src)
target_link_libraries(${PROJECT_NAME} PRIVATE Chip8Core)
#-------------------------------------------------------------------------------
# Unit Tests (with GTest + GMock)
#-------------------------------------------------------------------------------
file(GLOB_RECURSE TEST_FILES CONFIGURE_DEPENDS tests/*.cpp)
if(TEST_FILES)
add_executable(${PROJECT_NAME}_tests ${TEST_FILES})
target_link_libraries(${PROJECT_NAME}_tests PRIVATE Chip8Core gmock_main)
include(CTest)
enable_testing()
add_test(NAME AllTests COMMAND ${PROJECT_NAME}_tests)
endif()