Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Big CMake + MinGW + Sound PR #127

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More CMake Fiexes!
  • Loading branch information
TheBrokenRail committed Jun 18, 2024
commit 73846e9bc277b3c887b03de8e54951b10fed2923
48 changes: 47 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@ project(reminecraftpe)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

# WASM
if(EMSCRIPTEN)
function(add_compile_and_link_options)
add_compile_options(${ARGV})
add_link_options(${ARGV})
endfunction()
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_link_options("$<$<CONFIG:DEBUG>:-gsource-map>")
add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1)
endif()

# Clang
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register)
endif()

# Windows Linking
if(WIN32)
add_link_options(
-static-libgcc
-static-libstdc++
)
endif()

# HaikuOS Network Library
if(HAIKU)
link_libraries(network)
endif()

# Threading
if(EMSCRIPTEN)
add_compile_and_link_options(-pthread)
else()
find_package(Threads)
link_libraries(Threads::Threads)
endif()

# Android Logging
if(ANDROID)
link_libraries(log)
endif()

# Load Common Code
add_subdirectory(source)

Expand All @@ -17,4 +59,8 @@ set(REMCPE_PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "ReMCPE Platform (Check <
add_subdirectory("platforms/${REMCPE_PLATFORM}")

# Assets
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
if(EMSCRIPTEN)
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/game@/")
else()
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
endif()
33 changes: 0 additions & 33 deletions platforms/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ target_compile_definitions(reminecraftpe-core
PUBLIC HANDLE_CHARS_SEPARATELY
)

# WASM
if(EMSCRIPTEN)
function(add_compile_and_link_options)
add_compile_options(${ARGV})
add_link_options(${ARGV})
endfunction()
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_link_options("$<$<CONFIG:DEBUG>:-gsource-map>")
endif()

# Clang
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register)
endif()

# Network library
if(HAIKU)
link_libraries(network)
endif()

# Threads
if(EMSCRIPTEN)
add_compile_and_link_options(-pthread)
else()
find_package(Threads)
link_libraries(Threads::Threads)
endif()

# Build
set(SOURCES
main.cpp
Expand Down Expand Up @@ -121,8 +93,3 @@ if(EMSCRIPTEN)
# Export Resize Function
target_link_options(reminecraftpe PRIVATE -sEXPORTED_FUNCTIONS=_main,_resize_from_js -sEXPORTED_RUNTIME_METHODS=ccall)
endif()

# Embed Assets
if(EMSCRIPTEN)
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/../../game@/")
endif()
13 changes: 0 additions & 13 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,10 @@ else()
endif()
target_link_libraries(reminecraftpe-core PUBLIC zlib-interface)

# Android Logging
if(ANDROID)
target_link_libraries(reminecraftpe-core PUBLIC log)
endif()

# Sound Data
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h")
if(NOT DEFINED ENV{CI})
message(WARNING "Missing sound data! Did you run tools/grabsounds.py?")
endif()
target_compile_definitions(reminecraftpe-core PRIVATE MISSING_SOUND_DATA)
endif()

# Windows Linking
if(WIN32)
target_link_options(reminecraftpe-core
PUBLIC -static-libgcc
PUBLIC -static-libstdc++
)
endif()