Skip to content

Commit 17540a3

Browse files
authored
CMake Support for Linux (#10)
* CMake Support for Linux Changed the readme to reflect this too * fixes
1 parent ed7d94d commit 17540a3

File tree

4 files changed

+248
-1
lines changed

4 files changed

+248
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[Rr]elease/
1717
[Rr]eleases/
1818
[Bb]uild/
19+
[Oo]bjects/
1920
x64/
2021
x86/
2122
bld/
@@ -241,4 +242,4 @@ GeneratedArtifacts/
241242
_Pvt_Extensions/
242243
ModelManifest.xml
243244

244-
Ignored/
245+
Ignored/

CMakeLists.txt

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
cmake_minimum_required(VERSION 3.7)
2+
3+
project(RetroEngine)
4+
5+
option(FORCE_CASE_INSENSITIVE "Forces case insensivity." OFF)
6+
option(RETRO_MOD_LOADER "Enables or disables the mod loader." ON)
7+
option(RETRO_USE_ORIGINAL_CODE "Removes any change that differs from the original code, a playable game can't be built this way." OFF)
8+
9+
set(RETRO_SDL_VERSION 2 CACHE STRING "Select between SDL2 and SDL1, defaults to SDL2")
10+
11+
if(RETRO_ORIGINAL_CODE)
12+
set(RETRO_MOD_LOADER OFF)
13+
endif()
14+
15+
set(RETRO_NAME "Nexus")
16+
17+
set(RETRO_OUTPUT_NAME ${RETRO_NAME} CACHE STRING "The exported name of the executable.")
18+
19+
set(RETRO_FILES
20+
Nexus/Animation.cpp
21+
Nexus/Audio.cpp
22+
Nexus/Collision.cpp
23+
Nexus/Debug.cpp
24+
Nexus/Drawing.cpp
25+
Nexus/Ini.cpp
26+
Nexus/Input.cpp
27+
Nexus/fcaseopen.c
28+
Nexus/main.cpp
29+
Nexus/Math.cpp
30+
Nexus/Object.cpp
31+
Nexus/Palette.cpp
32+
Nexus/Player.cpp
33+
Nexus/Reader.cpp
34+
Nexus/RetroEngine.cpp
35+
Nexus/Scene.cpp
36+
Nexus/Script.cpp
37+
Nexus/Sprite.cpp
38+
Nexus/String.cpp
39+
Nexus/Text.cpp
40+
Nexus/Userdata.cpp
41+
Nexus/Video.cpp
42+
)
43+
44+
if(NOT PLATFORM)
45+
if(WIN32) # THIS ASSUMES VCPKG OR SOURCES !!!!!!!
46+
set(PLATFORM "Windows" CACHE STRING "The platform to compile for.")
47+
elseif(ANDROID)
48+
set(PLATFORM "Android" CACHE STRING "The platform to compile for.")
49+
else()
50+
set(PLATFORM ${CMAKE_SYSTEM_NAME} CACHE STRING "The platform to compile for.")
51+
endif()
52+
endif()
53+
54+
include(platforms/${PLATFORM}.cmake)
55+
56+
set_target_properties(RetroEngine PROPERTIES OUTPUT_NAME ${RETRO_OUTPUT_NAME})
57+
58+
if(COMPILE_OGG)
59+
set(OGG_DIR dependencies/${DEP_PATH}/libogg)
60+
add_library(
61+
libogg
62+
STATIC
63+
${OGG_DIR}/src/bitwise.c
64+
${OGG_DIR}/src/framing.c
65+
)
66+
67+
target_compile_options(libogg PRIVATE ${OGG_FLAGS})
68+
69+
target_include_directories(libogg PRIVATE ${OGG_DIR}/include)
70+
target_include_directories(RetroEngine PRIVATE ${OGG_DIR}/include)
71+
target_link_libraries(RetroEngine libogg)
72+
endif()
73+
74+
if(COMPILE_VORBIS)
75+
set(VORBIS_DIR dependencies/${DEP_PATH}/libvorbis)
76+
set(OGG_DIR dependencies/${DEP_PATH}/libogg)
77+
add_library(libvorbis STATIC
78+
${VORBIS_DIR}/lib/analysis.c
79+
${VORBIS_DIR}/lib/barkmel.c
80+
${VORBIS_DIR}/lib/bitrate.c
81+
${VORBIS_DIR}/lib/block.c
82+
${VORBIS_DIR}/lib/codebook.c
83+
${VORBIS_DIR}/lib/envelope.c
84+
${VORBIS_DIR}/lib/floor0.c
85+
${VORBIS_DIR}/lib/floor1.c
86+
${VORBIS_DIR}/lib/info.c
87+
${VORBIS_DIR}/lib/lookup.c
88+
${VORBIS_DIR}/lib/lpc.c
89+
${VORBIS_DIR}/lib/lsp.c
90+
${VORBIS_DIR}/lib/mapping0.c
91+
${VORBIS_DIR}/lib/mdct.c
92+
${VORBIS_DIR}/lib/psy.c
93+
${VORBIS_DIR}/lib/registry.c
94+
${VORBIS_DIR}/lib/res0.c
95+
${VORBIS_DIR}/lib/sharedbook.c
96+
${VORBIS_DIR}/lib/smallft.c
97+
${VORBIS_DIR}/lib/synthesis.c
98+
${VORBIS_DIR}/lib/tone.c
99+
${VORBIS_DIR}/lib/vorbisenc.c
100+
${VORBIS_DIR}/lib/vorbisfile.c
101+
${VORBIS_DIR}/lib/window.c
102+
)
103+
104+
target_compile_options(libvorbis PRIVATE ${VORBIS_FLAGS})
105+
106+
target_include_directories(libvorbis
107+
PRIVATE
108+
${VORBIS_DIR}/include
109+
${VORBIS_DIR}/lib
110+
${OGG_DIR}/include
111+
)
112+
target_include_directories(RetroEngine PRIVATE ${VORBIS_DIR}/include)
113+
target_link_libraries(RetroEngine libvorbis libogg)
114+
endif()
115+
116+
if(COMPILE_THEORA)
117+
set(THEORA_DIR dependencies/${DEP_PATH}/libtheora)
118+
119+
add_library(libtheora STATIC
120+
${THEORA_DIR}/lib/analyze.c
121+
${THEORA_DIR}/lib/apiwrapper.c
122+
${THEORA_DIR}/lib/bitpack.c
123+
${THEORA_DIR}/lib/cpu.c
124+
${THEORA_DIR}/lib/decapiwrapper.c
125+
${THEORA_DIR}/lib/decinfo.c
126+
${THEORA_DIR}/lib/decode.c
127+
${THEORA_DIR}/lib/dequant.c
128+
${THEORA_DIR}/lib/encapiwrapper.c
129+
${THEORA_DIR}/lib/encfrag.c
130+
${THEORA_DIR}/lib/encinfo.c
131+
${THEORA_DIR}/lib/encode.c
132+
${THEORA_DIR}/lib/encoder_disabled.c
133+
${THEORA_DIR}/lib/enquant.c
134+
${THEORA_DIR}/lib/fdct.c
135+
${THEORA_DIR}/lib/fragment.c
136+
${THEORA_DIR}/lib/huffdec.c
137+
${THEORA_DIR}/lib/huffenc.c
138+
${THEORA_DIR}/lib/idct.c
139+
${THEORA_DIR}/lib/info.c
140+
${THEORA_DIR}/lib/internal.c
141+
${THEORA_DIR}/lib/mathops.c
142+
${THEORA_DIR}/lib/mcenc.c
143+
${THEORA_DIR}/lib/quant.c
144+
${THEORA_DIR}/lib/rate.c
145+
${THEORA_DIR}/lib/state.c
146+
${THEORA_DIR}/lib/tokenize.c
147+
)
148+
149+
target_compile_options(libtheora PRIVATE ${THEORA_FLAGS})
150+
151+
target_include_directories(libtheora PRIVATE ${THEORA_DIR}/include ${OGG_DIR}/include)
152+
target_include_directories(RetroEngine PRIVATE ${THEORA_DIR}/include)
153+
target_link_libraries(RetroEngine libtheora)
154+
endif()
155+
156+
target_include_directories(RetroEngine PRIVATE
157+
Nexus/
158+
)
159+
160+
if(DEFINED DEP_PATH)
161+
target_include_directories(RetroEngine PRIVATE
162+
dependencies/${DEP_PATH}/
163+
)
164+
endif()
165+
166+
167+
target_compile_definitions(RetroEngine PRIVATE
168+
RETRO_USE_MOD_LOADER=$<BOOL:${RETRO_USE_MOD_LOADER}>
169+
FORCE_CASE_INSENSITIVE=$<BOOL:${FORCE_CASE_INSENSITIVE}>
170+
RETRO_USE_ORIGINAL_CODE=$<BOOL:${RETRO_USE_ORIGINAL_CODE}>
171+
)

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Without assets from the Sonic Nexus 2008 demo, this decompilation will not run.
1919
* Clone the repo, follow the instructions in the [depencencies readme for Mac](./dependencies/mac/dependencies.txt) to setup dependencies, then build via the Xcode project.
2020

2121
## Linux
22+
### Make
2223
* To setup your build enviroment and library dependecies, run the following commands:
2324
* Ubuntu (Mint, Pop!_OS, etc...): `sudo apt install build-essential git libsdl2-dev libvorbis-dev libogg-dev libtheora-dev`
2425
* Arch Linux: `sudo pacman -S base-devel git sdl2 libvorbis libogg libtheora`
@@ -29,6 +30,21 @@ Without assets from the Sonic Nexus 2008 demo, this decompilation will not run.
2930
* The `CXXFLAGS` option can be removed if you do not want optimizations.
3031
* -j switch is optional, but will make building faster by running it parallel on multiple cores (8 cores would be -j9.)
3132

33+
### CMake
34+
* Install the following dependencies depending on your platform through your terminal:
35+
* **pacman (Arch):** `sudo pacman -S base-devel cmake sdl2 libogg libtheora libvorbis`
36+
* **apt (Debian/Ubuntu):** `sudo apt install build-essential cmake libsdl2-dev libogg-dev libtheora-dev libvorbis-dev`
37+
* **rpm (Fedora):** `sudo dnf install make gcc cmake sdl2-devel libogg-devel libtheora-devel libvorbis-devel zlib-devel`
38+
* **apk (Alpine/PostmarketOS)** `sudo apk add build-base cmake sdl2-dev libogg-dev libtheora-dev libvorbis-dev`
39+
* Your favorite package manager here, [make a pull request](https://github.com/RSDKModding/RSDKv2-Decompilation/fork)
40+
41+
42+
* Then just run the following in the root repository directory:
43+
```
44+
cmake -B build
45+
cmake --build build --config release
46+
```
47+
3248
## Unofficial Branches
3349
Follow the installation instructions in the readme of each branch.
3450
* For the **Nintendo Switch**, go to [LittlePlanetCD's fork](https://github.com/LittlePlanetCD/Sonic-Nexus-Switch).

platforms/Linux.cmake

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
find_package(PkgConfig REQUIRED)
2+
3+
add_executable(RetroEngine ${RETRO_FILES})
4+
5+
pkg_check_modules(OGG ogg)
6+
7+
if(NOT OGG_FOUND)
8+
set(COMPILE_OGG TRUE)
9+
message(NOTICE "libogg not found, attempting to build from source")
10+
else()
11+
message("found libogg")
12+
target_link_libraries(RetroEngine ${OGG_STATIC_LIBRARIES})
13+
target_link_options(RetroEngine PRIVATE ${OGG_STATIC_LDLIBS_OTHER})
14+
target_compile_options(RetroEngine PRIVATE ${OGG_STATIC_CFLAGS})
15+
endif()
16+
17+
pkg_check_modules(THEORA theora theoradec)
18+
19+
if(NOT THEORA_FOUND)
20+
message("could not find libtheora, attempting to build manually")
21+
set(COMPILE_THEORA TRUE)
22+
else()
23+
message("found libtheora")
24+
target_link_libraries(RetroEngine ${THEORA_STATIC_LIBRARIES})
25+
target_link_options(RetroEngine PRIVATE ${THEORA_STATIC_LDLIBS_OTHER})
26+
target_compile_options(RetroEngine PRIVATE ${THEORA_STATIC_CFLAGS})
27+
endif()
28+
29+
pkg_check_modules(VORBIS vorbis vorbisfile) #idk what the names are
30+
31+
if(NOT VORBIS_FOUND)
32+
set(COMPILE_VORBIS TRUE)
33+
message(NOTICE "libvorbis not found, attempting to build from source")
34+
else()
35+
message("found libvorbis")
36+
target_link_libraries(RetroEngine ${VORBIS_STATIC_LIBRARIES})
37+
target_link_options(RetroEngine PRIVATE ${VORBIS_STATIC_LDLIBS_OTHER})
38+
target_compile_options(RetroEngine PRIVATE ${VORBIS_STATIC_CFLAGS})
39+
endif()
40+
41+
42+
if(RETRO_SDL_VERSION STREQUAL "2")
43+
pkg_check_modules(SDL2 sdl2 REQUIRED)
44+
target_link_libraries(RetroEngine ${SDL2_STATIC_LIBRARIES})
45+
target_link_options(RetroEngine PRIVATE ${SDL2_STATIC_LDLIBS_OTHER})
46+
target_compile_options(RetroEngine PRIVATE ${SDL2_STATIC_CFLAGS})
47+
elseif(RETRO_SDL_VERSION STREQUAL "1")
48+
pkg_check_modules(SDL1 sdl1 REQUIRED)
49+
target_link_libraries(RetroEngine ${SDL1_STATIC_LIBRARIES})
50+
target_link_options(RetroEngine PRIVATE ${SDL1_STATIC_LDLIBS_OTHER})
51+
target_compile_options(RetroEngine PRIVATE ${SDL1_STATIC_CFLAGS})
52+
endif()
53+
54+
if(RETRO_USE_MOD_LOADER)
55+
set_target_properties(RetroEngine PROPERTIES
56+
CXX_STANDARD 17
57+
CXX_STANDARD_REQUIRED ON
58+
)
59+
endif()

0 commit comments

Comments
 (0)