-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (124 loc) · 3.48 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
cmake_minimum_required(VERSION 3.21)
project(
Pixelly2
VERSION 0.1.0
LANGUAGES CXX C
)
###############################################################################
#
# SETUP VARIABLES
#
###############################################################################
if(NOT DEFINED VCPKG_ROOT)
if(DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT $ENV{VCPKG_ROOT} CACHE PATH "Path to vcpkg directory")
endif()
endif()
if(DEFINED VCPKG_ROOT)
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
message(FATAL_ERROR "Invalid VCPKG_ROOT specified (${VCPKG_ROOT}); please specify an absolute path")
endif()
endif()
if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(SOL2_DO_TESTS OFF)
set(SOL2_DO_EXAMPLES OFF)
set(SOL2_DOCS OFF)
set(SOL2_LUA_VERSION "5.4")
set(SOL2_BUILD_LUA OFF)
add_compile_definitions(
SOL_ALL_SAFETIES_ON
SOL_USING_CXX_LUA
)
###############################################################################
#
# FIND PACKAGES
#
###############################################################################
find_package(effolkronium_random CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(Lua REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_path(BOOST_INCLUDE_DIR "boost/predef.h")
set(SFML_BUILD_WINDOW ON)
set(SFML_BUILD_GRAPHICS ON)
set(SFML_BUILD_AUDIO ON)
set(SFML_BUILD_NETWORK OFF)
set(SFML_BUILD_DOC OFF)
set(SFML_BUILD_TEST_SUITE OFF)
set(SFML_ENABLE_COVERAGE OFF)
add_subdirectory(deps/SFML)
#add_compile_definitions(_SQ64)
#add_subdirectory(deps/quirrel)
###############################################################################
#
# SET UP TARGETS
#
###############################################################################
add_executable(Pixelly
src/Pixelly2.cpp
src/base.cpp
src/gpu.cpp
src/input.cpp
src/machine.cpp
src/apis/lua.cpp
src/apis/lua/gpu.cpp
src/apis/lua/input.cpp
src/apis/lua/intern.cpp
)
target_include_directories(Pixelly
PRIVATE
${CMAKE_SOURCE_DIR}/include
${LUA_INCLUDE_DIR}
${BOOST_INCLUDE_DIRS}
)
target_compile_features(Pixelly PUBLIC cxx_std_20)
target_compile_features(Pixelly PUBLIC c_std_17)
if(UNIX AND NOT APPLE)
set(PXLY_SFML_LIBRARIES
sfml-system
sfml-window
sfml-graphics
sfml-audio
)
else()
set(PXLY_SFML_LIBRARIES
sfml-main
sfml-system
sfml-window
sfml-graphics
sfml-audio
)
endif()
target_link_libraries(Pixelly
PRIVATE
${PXLY_SFML_LIBRARIES}
effolkronium_random
fmt::fmt
${LUA_LIBRARIES}
sol2::sol2
)
if(CMAKE_BUILD_TYPE EQUAL "Debug")
target_compile_definitions(Pixelly PUBLIC PXLY_DEBUG)
endif()
set(PXLY_DATA_FILES
data/fonts/unscii-8-alt-mod.otf
data/fonts/unscii-8-fantasy-mod.otf
data/fonts/unscii-8-mcr-mod.otf
data/fonts/unscii-8-mod.otf
data/fonts/unscii-8-thin-mod.otf
data/scripts/lua/boot.lua
)
foreach(PXLY_DATA_FILE ${PXLY_DATA_FILES})
add_custom_command(TARGET Pixelly POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/${PXLY_DATA_FILE}
${CMAKE_BINARY_DIR}/${PXLY_DATA_FILE}
BYPRODUCTS ${CMAKE_BINARY_DIR}/${PXLY_DATA_FILE}
)
endforeach()