-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
100 lines (84 loc) · 2.82 KB
/
CMakeLists.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required(VERSION 3.16)
project(CMakeSFMLProject LANGUAGES CXX)
set(CMAKE_EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/..)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..)
set(EXECUTABLE_NAME Tetroid)
set(UNIT_TEST_EXE Emulator_tests)
# string(APPEND CMAKE_CXX_FLAGS "-Wall")
string(APPEND CMAKE_CXX_FLAGS " -g")
# set(CMAKE_BUILD_TYPE Debug)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
FetchContent_MakeAvailable(SFML)
if(DEFINED UNITTESTS AND UNITTESTS STREQUAL "ON")
enable_testing()
add_executable(
${UNIT_TEST_EXE}
src/unitTests/RunUnitTests.cc
src/unitTests/emulator_test.cc
src/SetupSFML.cpp
src/emulator/APU.cpp
src/emulator/AddressMode.cpp
src/emulator/BitOperations.cpp
src/emulator/Bus.cpp
src/emulator/Computer.cpp
src/emulator/Instructions.cpp
src/emulator/LoadRom.cpp
src/emulator/PPU.cpp
src/emulator/StatusRegister.cpp
src/emulator/NESError.cpp
src/emulator/InstructionMap.cpp
)
target_link_libraries(
${UNIT_TEST_EXE}
GTest::gtest_main
)
target_include_directories(${UNIT_TEST_EXE} PRIVATE ${CMAKE_SOURCE_DIR}/src/include)
target_link_libraries(
${UNIT_TEST_EXE}
sfml-graphics
)
include(GoogleTest)
gtest_discover_tests( ${UNIT_TEST_EXE})
target_compile_features( ${UNIT_TEST_EXE} PRIVATE cxx_std_20)
install(TARGETS ${UNIT_TEST_EXE}
)
else()
add_executable(${EXECUTABLE_NAME} src/main.cpp
src/SetupSFML.cpp
src/emulator/APU.cpp
src/emulator/AddressMode.cpp
src/emulator/BitOperations.cpp
src/emulator/Bus.cpp
src/emulator/Computer.cpp
src/emulator/Instructions.cpp
src/emulator/LoadRom.cpp
src/emulator/PPU.cpp
src/emulator/StatusRegister.cpp
src/emulator/NESError.cpp
src/emulator/InstructionMap.cpp
)
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/include)
target_link_libraries(${EXECUTABLE_NAME} PRIVATE sfml-graphics)
target_compile_features(${EXECUTABLE_NAME} PRIVATE cxx_std_20)
install(TARGETS ${EXECUTABLE_NAME})
endif()
# if(WIN32)
# add_custom_command(
# TARGET ${EXECUTABLE_NAME}
# COMMENT "Copy OpenAL DLL"
# PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:${EXECUTABLE_NAME}>
# VERBATIM)
# endif()
# uncomment if you are running this in Visual Studio or if you get an error on windows with the current setup