-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
74 lines (53 loc) · 2.57 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
cmake_minimum_required(VERSION 3.10)
set(project_name "arabica")
set(dir_app "app")
set(dir_emulator "arabica")
set(dir_test "test")
set(dir_vcpkg "~/vcpkg")
set(CMAKE_TOOLCHAIN_FILE "${dir_vcpkg}/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(${project_name})
find_package(fmt CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
include_directories("${CMAKE_CURRENT_LIST_DIR}")
file(GLOB_RECURSE src_app "${dir_app}/*.cpp")
file(GLOB_RECURSE src_emulator "${dir_emulator}/*.cpp")
file(GLOB_RECURSE src_test "${dir_test}/*.cpp")
OPTION(BUILD_DESKTOP "Build Desktop" OFF)
OPTION(BUILD_TEST "Build Test" OFF)
OPTION(BUILD_WASM "Build Webassembly" OFF)
add_library(${dir_emulator} ${src_emulator})
target_compile_options(${dir_emulator} PUBLIC -g)
target_compile_options(${dir_emulator} PUBLIC -O0)
IF(BUILD_DESKTOP)
target_link_libraries(${dir_emulator} PUBLIC fmt::fmt)
target_link_libraries(${dir_emulator} PUBLIC SDL2::SDL2)
add_executable(${project_name}.out ${src_app})
target_compile_options(${project_name}.out PRIVATE -g)
target_compile_options(${project_name}.out PRIVATE -O0)
target_link_libraries(${project_name}.out PUBLIC ${dir_emulator})
ENDIF(BUILD_DESKTOP)
IF(BUILD_TEST)
target_link_libraries(${dir_emulator} PUBLIC fmt::fmt)
target_link_libraries(${dir_emulator} PUBLIC SDL2::SDL2)
add_executable(test_${project_name}.out ${src_test})
target_compile_options(test_${project_name}.out PRIVATE -g)
target_compile_options(test_${project_name}.out PRIVATE -O0)
target_link_libraries(test_${project_name}.out PUBLIC ${dir_emulator}
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main)
ENDIF(BUILD_TEST)
IF(BUILD_WASM)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_libraries(${dir_emulator} PUBLIC "-s WASM=1 -s USE_SDL=2 -s -O3 --preload-file ../roms@/roms")
add_executable(${project_name}_wasm ${src_app})
target_compile_options(${project_name}_wasm PRIVATE -g)
target_compile_options(${project_name}_wasm PRIVATE -O0)
target_link_libraries(${project_name}_wasm PUBLIC ${dir_emulator})
ENDIF(BUILD_WASM)