-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (69 loc) · 2.77 KB
/
CMakeLists.txt
File metadata and controls
84 lines (69 loc) · 2.77 KB
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
cmake_minimum_required(VERSION 3.16)
project(mojozork)
set(MOJOZORK_STANDALONE_DEFAULT ON)
set(MOJOZORK_MULTIZORK_DEFAULT ON)
set(MOJOZORK_LIBRETRO_DEFAULT ON)
set(MOJOZORK_SDL3_DEFAULT ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(EMSCRIPTEN TRUE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(ANDROID TRUE)
endif()
if(MSVC OR EMSCRIPTEN) # the daemon is pretty Unixy.
set(MOJOZORK_MULTIZORK_DEFAULT OFF)
endif()
# Building as part of RetroArch? Turn off everything but the libretro plugin by default.
if(LIBRETRO)
set(MOJOZORK_STANDALONE_DEFAULT OFF)
set(MOJOZORK_MULTIZORK_DEFAULT OFF)
set(MOJOZORK_SDL3_DEFAULT OFF)
endif()
option(MOJOZORK_STANDALONE "Build the MojoZork standalone app" ${MOJOZORK_STANDALONE_DEFAULT})
option(MOJOZORK_MULTIZORK "Build the Multizork server" ${MOJOZORK_MULTIZORK_DEFAULT})
option(MOJOZORK_LIBRETRO "Build the MojoZork libretro core" ${MOJOZORK_LIBRETRO_DEFAULT})
option(MOJOZORK_SDL3 "Build the MojoZork standalone SDL3 app" ${MOJOZORK_SDL3_DEFAULT})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
else() # This assumes you have GCC or Clang at the moment.
add_definitions(-Wall)
endif()
if(MOJOZORK_STANDALONE)
add_executable(mojozork mojozork.c)
endif()
if(MOJOZORK_MULTIZORK)
add_executable(multizorkd multizorkd.c)
target_link_libraries(multizorkd -lsqlite3)
endif()
if(MOJOZORK_LIBRETRO)
add_library(mojozork_libretro SHARED mojozork-libretro.c)
if(ANDROID) # Android builds of libretro cores need specific names.
set_target_properties(mojozork_libretro PROPERTIES LIBRARY_OUTPUT_NAME mojozork_libretro_android)
endif()
set_target_properties(mojozork_libretro PROPERTIES PREFIX "")
endif()
if(MOJOZORK_SDL3)
find_package(SDL3 QUIET)
if (NOT SDL3_FOUND)
message(STATUS "SDL3 not available, will download a copy and build it.")
# FetchContent downloads and configures dependencies
include(FetchContent)
FetchContent_Declare(
SDL3
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
GIT_TAG "main"
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(SDL3)
endif()
add_executable(mojozork_sdl3 mojozork-sdl3.c)
set_target_properties(mojozork_sdl3 PROPERTIES OUTPUT_NAME "mojozork-sdl3")
set_target_properties(mojozork_sdl3 PROPERTIES WIN32_EXECUTABLE TRUE) # safe to set this on non-Windows platforms, too.
target_link_libraries(mojozork_sdl3 SDL3::SDL3)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set_target_properties(mojozork_sdl3 PROPERTIES LINK_FLAGS "-s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=0 -lidbfs.js")
endif()
endif()
# end of CMakeLists.txt ...