11option (BUILD_TESTS "Build tests" ON )
22option (WITH_COVERAGE "Build with coverage info" OFF )
33
4+ ########################################################################################################################
5+ ### CMake Policy ###
6+ ########################################################################################################################
7+ cmake_policy (SET CMP0054 OLD)
8+
49
510########################################################################################################################
611### GameboyCore ###
@@ -54,32 +59,32 @@ set(GAMEBOYCORE_HEADERS
5459 include /gameboycore/cartinfo.h
5560 include /gameboycore/opcodeinfo.h
5661 include /gameboycore/opcode_cycles.h
57- src/core/ bitutil.h
58- src/core/ shiftrotate.h
62+ src/bitutil.h
63+ src/shiftrotate.h
5964)
6065
6166set (GAMEBOYCORE
62- src/core/ gameboycore.cpp
63- src/core/ cpu.cpp
64- src/core/ mmu.cpp
65- src/core/ gpu.cpp
66- src/core/ apu.cpp
67- src/core/ joypad.cpp
68- src/core/ link.cpp
69- src/core/ link_cable.cpp
70- src/core/ mbc.cpp
71- src/core/ mbc1.cpp
72- src/core/ mbc2.cpp
73- src/core/ mbc3.cpp
74- src/core/ mbc5.cpp
75- src/core/ alu.cpp
76- src/core/ cartinfo.cpp
77- src/core/ shiftrotate.cpp
78- src/core/ opcodeinfo.cpp
79- src/core/ tileram.cpp
80- src/core/ tilemap.cpp
81- src/core/ oam.cpp
82- src/core/ timer.cpp
67+ src/gameboycore.cpp
68+ src/cpu.cpp
69+ src/mmu.cpp
70+ src/gpu.cpp
71+ src/apu.cpp
72+ src/joypad.cpp
73+ src/link.cpp
74+ src/link_cable.cpp
75+ src/mbc.cpp
76+ src/mbc1.cpp
77+ src/mbc2.cpp
78+ src/mbc3.cpp
79+ src/mbc5.cpp
80+ src/alu.cpp
81+ src/cartinfo.cpp
82+ src/shiftrotate.cpp
83+ src/opcodeinfo.cpp
84+ src/tileram.cpp
85+ src/tilemap.cpp
86+ src/oam.cpp
87+ src/timer.cpp
8388)
8489
8590# Gameboy Core Library
@@ -91,15 +96,18 @@ add_library(gameboycore::gameboycore ALIAS gameboycore)
9196
9297target_compile_features (gameboycore PUBLIC cxx_std_11)
9398
94- # TODO: Move detail headers elsewhere?
95- target_include_directories (gameboycore PUBLIC
96- include /
99+ target_include_directories (gameboycore
100+ PUBLIC
101+ $<INSTALL_INTERFACE:include >
102+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
97103)
98104
99- if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
100- target_compile_options (gameboycore PRIVATE -Wall -Wno-format-security)
101- elseif (MSVC )
102- target_compile_options (gameboycore PRIVATE /W3)
105+ if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
106+ target_compile_options (gameboycore PRIVATE -Wall -Wextra)
107+ elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "MSVC" )
108+ target_compile_options (gameboycore PRIVATE /W4)
109+ elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang" )
110+ target_compile_options (gameboycore PRIVATE -Wall -Wextra)
103111endif ()
104112
105113target_compile_definitions (gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN} =1 _CRT_SECURE_NO_WARNINGS=1)
@@ -111,8 +119,12 @@ target_compile_definitions(gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN}=1
111119if (BUILD_TESTS)
112120 # Setup coverage reporting
113121 if (WITH_COVERAGE)
114- target_link_libraries (gameboycore gcov)
115- target_compile_options (gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
122+ if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
123+ target_compile_options (gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
124+ target_link_libraries (gameboycore gcov)
125+ else ()
126+ message (WARNING "Code coverage is not supported for ${CMAKE_CXX_COMPILER_ID} " )
127+ endif ()
116128 endif ()
117129
118130 add_subdirectory (tests)
0 commit comments