-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
126 lines (103 loc) · 4.12 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
cmake_minimum_required(VERSION 3.13)
project(mcswitch CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Use response files when linking objects because of the large number of source files
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS ON)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
# Required to silence "unused argument" warnings for -stdlib=libc++ when using distcc
add_compile_options(-Wno-unused-command-line-argument)
# Required to fix source paths in debug info when using distcc
add_compile_options(-fdebug-prefix-map=/tmp=${CMAKE_CURRENT_BINARY_DIR})
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
file(GLOB_RECURSE SOURCES_GAME ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.c ${PROJECT_SOURCE_DIR}/src/*.hpp ${PROJECT_SOURCE_DIR}/src/*.h ${PROJECT_SOURCE_DIR}/lib/windows.cpp)
add_executable(mcswitch ${SOURCES_GAME})
# Writing sources to a file so build.py script knows the sources
set(SOURCES_OUTPUT_FILE "${CMAKE_BINARY_DIR}/.build_sources")
file(WRITE ${SOURCES_OUTPUT_FILE} "")
get_target_property(SOURCES_COMBINED mcswitch SOURCES)
foreach (SOURCE ${SOURCES_COMBINED})
file(APPEND ${SOURCES_OUTPUT_FILE} "${SOURCE}\n")
endforeach()
set(NN_SDK_MAJOR 4)
set(NN_SDK_MINOR 4)
set(NN_SDK_PATCH 1)
set(NN_SDK_TYPE "Release")
target_include_directories(mcswitch PRIVATE src)
target_include_directories(mcswitch PUBLIC lib/nnheaders/include)
target_include_directories(mcswitch PUBLIC lib/stb_image)
target_include_directories(mcswitch PUBLIC lib/libpng)
target_include_directories(mcswitch PUBLIC lib)
target_compile_definitions(mcswitch PRIVATE NON_MATCHING)
target_compile_options(mcswitch PRIVATE -fno-exceptions)
target_compile_options(mcswitch PRIVATE -fno-strict-aliasing)
target_compile_options(mcswitch PRIVATE -fsigned-char)
target_compile_options(mcswitch PRIVATE -Wall -Wextra -Wdeprecated)
target_compile_options(mcswitch PRIVATE -Wno-unused-parameter -Wno-unused-private-field)
target_compile_options(mcswitch PRIVATE -Wno-invalid-offsetof)
target_compile_options(mcswitch PRIVATE -Wextra-semi)
target_compile_options(mcswitch PRIVATE -fno-inline -fno-inline-functions)
target_compile_options(mcswitch PRIVATE -fno-builtin)
add_definitions(-D SAFETY_CHECKS)
# Add zlib and libpng as subdirectories
#add_subdirectory(lib/zlib)
#add_subdirectory(lib/libpng)
# Include necessary directories from submodules
#include_directories("${PROJECT_SOURCE_DIR}/lib/zlib" "${PROJECT_SOURCE_DIR}/lib/libpng")
# Link with zlib and libpng libraries statically
#target_link_libraries(mcswitch PRIVATE zlibstatic png)
## include(FetchContent)
##
## # zlib
## FetchContent_Declare(
## zlib
## GIT_REPOSITORY https://github.com/madler/zlib.git
## GIT_TAG 9712272c78b9d9c93746d9c8e156a3728c65ca72
## )
## FetchContent_Populate(zlib)
## list(FILTER zlib_POPULATED_INCLUDE_DIRS EXCLUDE REGEX ".*/zconf\\.h$")
##
## # Specify the ZLIB_LIBRARY variable
## set(ZLIB_LIBRARY ${zlib_POPULATED_LIBRARIES})
##
## # libpng
## FetchContent_Declare(
## libpng
## GIT_REPOSITORY https://github.com/pnggroup/libpng.git
## GIT_TAG 809355b4aa84ae06f9a4e063c7e9d22fd7930170
## )
## FetchContent_Populate(libpng)
##
## # stb_image.h
## FetchContent_Declare(
## stb_image
## GIT_REPOSITORY https://github.com/nothings/stb.git
## GIT_TAG ec9db6f84b39988a6a3375058e97598fe63fca4e
## )
## FetchContent_MakeAvailable(stb_image)
#
## target_link_libraries(mcswitch PRIVATE zlib libpng16::libpng16)
#
## libpng configurable options
#set(PNG_SHARED ON CACHE BOOL "" FORCE)
#set(PNG_STATIC ON CACHE BOOL "" FORCE)
#set(PNG_EXECUTABLES OFF CACHE BOOL "" FORCE) # we only want lib
#set(PNG_TESTS OFF CACHE BOOL "" FORCE) # we only want lib
#set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE) # we only want lib
#
#include_directories(${PROJECT_SOURCE_DIR}/lib/libpng)
#
## Find ZLIB using ZLIB_ROOT variable
#find_package(ZLIB REQUIRED)
#
#if(ZLIB_FOUND)
# include_directories(${ZLIB_INCLUDE_DIRS})
#endif()
#
#add_subdirectory(lib/zlib)
#add_subdirectory(lib/libpng)