Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
43 changes: 35 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.24)

cmake_policy(SET CMP0135 NEW)

Expand All @@ -39,6 +39,11 @@ include(LoadVersionFromJson)

project(ror-dependencies VERSION 30)

option(ROR_MACOS_GL3 "Build the pinned native macOS GL3 source profile" OFF)
if(ROR_MACOS_GL3 AND (NOT APPLE OR CMAKE_CROSSCOMPILING))
message(FATAL_ERROR "ROR_MACOS_GL3 requires a native macOS toolchain")
endif()


# ------------------------------------------------------------------------------------------------#
# Options to enable/disable building specific dependencies
Expand All @@ -55,15 +60,16 @@ option(BUILD_CAELUM "Build Caelum library" ON)
option(BUILD_RAPIDJSON "Build RapidJSON library" ON)
option(BUILD_FMT "Build fmt" ON)

# Options with different default values on Windows and Linux
cmake_dependent_option(BUILD_CURL "Build cURL library" ON WIN32 OFF)
cmake_dependent_option(BUILD_OIS "Build ois" ON WIN32 OFF)
# Options with platform-specific default values
cmake_dependent_option(BUILD_CURL "Build cURL library" ON "WIN32 OR APPLE" OFF)
cmake_dependent_option(BUILD_OIS "Build ois" ON "WIN32 OR APPLE" OFF)

# ------------------------------------------------------------------------------------------------#
# General setup and initialization
# ------------------------------------------------------------------------------------------------#

set(PATCH_TOOL_SCRIPT python ${CMAKE_SOURCE_DIR}/tools/patch.py --verbose)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
set(PATCH_TOOL_SCRIPT ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/patch.py --verbose)

set(FETCHCONTENT_QUIET FALSE)

Expand All @@ -73,7 +79,9 @@ set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR})


# Determine the name for the output directory where dependencies are going to be installed
if (WIN32)
if(DEPENDENCIES_OUTPUT_DIR)
get_filename_component(DEPENDENCIES_OUTPUT_DIR "${DEPENDENCIES_OUTPUT_DIR}" ABSOLUTE)
elseif (WIN32)
set(DEPENDENCIES_OUTPUT_DIR ${CMAKE_BINARY_DIR}/Dependencies_${CMAKE_SYSTEM_NAME}_${CMAKE_GENERATOR})
string(REPLACE " " "-" DEPENDENCIES_OUTPUT_DIR ${DEPENDENCIES_OUTPUT_DIR})
else ()
Expand Down Expand Up @@ -102,7 +110,7 @@ if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /w")
endif ()

if (UNIX)
if (UNIX AND NOT ROR_MACOS_GL3)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-deprecated-declarations -Wno-attributes")
endif ()
Expand All @@ -123,6 +131,13 @@ if (UNIX)
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPENDENCIES_LIB_DIR}/pkgconfig")
endif ()

include(MacOS)

if(ROR_MACOS_GL3)
add_subdirectory(openssl)
add_subdirectory(zlib)
endif()

if (BUILD_OPENAL)
add_subdirectory(openal)
endif ()
Expand All @@ -135,12 +150,20 @@ if (BUILD_RAPIDJSON)
add_subdirectory(rapidjson)
endif ()

if(ROR_MACOS_GL3)
add_subdirectory(discord-rpc)
endif()

if (BUILD_OIS)
add_subdirectory(ois)
endif ()

if (BUILD_OGRE)
if (WIN32)
if(ROR_MACOS_GL3)
add_subdirectory(freetype)
add_subdirectory(zziplib)
set(OGRE_DEPS freetype zziplib)
elseif (WIN32)
add_subdirectory(freetype)
add_subdirectory(freeimage)
add_subdirectory(zlib)
Expand Down Expand Up @@ -173,3 +196,7 @@ endif ()
if (BUILD_FMT)
add_subdirectory(fmt)
endif ()

if(ROR_MACOS_GL3)
ror_macos_manifest()
endif()
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,102 @@ Install with [Chocolatey](https://chocolatey.org/): ```choco install cmake git``

The resulting dependencies will be placed inside the `Dependencies_Linux` directory.


## Native macOS ARM64 GL3 source profile

The opt-in profile builds a separate pinned source prefix with the existing
ExternalProject recipes. CMake 3.24+, Python 3, Perl, make, Ninja and the Apple
command-line toolchain are required. The default Windows/Linux source versions
and renderer choices are retained. Do not reuse an installed or archived prefix.

```sh
sdk="$(xcrun --sdk macosx --show-sdk-path)"
cmake -S . -B build-macos -G Ninja \
-DROR_MACOS_GL3=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT="$sdk" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DDEPENDENCIES_OUTPUT_DIR="$PWD/prefix-macos"
cmake --build build-macos --target macos-downloads --parallel 1
cmake --build build-macos --target macos-patches --parallel 1
cmake --build build-macos --parallel 1
```

Keep the outer build serial: each dependency builds with at most three jobs.
Keep at least 4 GiB free and stop the build before exhausting disk space. The
prefix is the only install destination; no system or Homebrew installation is
performed. Select a fresh build directory when changing source/patch versions.
A repeat patch step accepts an unchanged verified patched source tree and rejects
modified sources. Some upstream projects generate source headers during their
configuration; recreate their source/build tree before explicitly replaying patches.

The Apple profile requires every listed game dependency, including OpenSSL and
Discord RPC, and fails if any `BUILD_*` game feature is disabled. OGRE uses GL3+,
STBI and ZIP with Bites, Overlay, Paging, RTSS, MeshLOD and Terrain. Legacy GL,
Cg, FreeImage, optional SDL integration, samples and tools are explicitly off.
RoR owns native Cocoa window/event integration. FreeType uses the pinned zlib;
optional PNG/BZip2/Brotli/HarfBuzz support is not part of this graph. curl uses
the pinned OpenSSL/zlib, with optional SSH, PSL, Brotli, Zstd, GSSAPI, libidn2 and nghttp2 integrations
off. No game content is downloaded by this dependency build.

User C/C++/ASM flags and selected SDK/architecture/deployment target are forwarded
to every dependency. An SDK header-search workaround, when needed for a local
Apple toolchain, can be supplied explicitly as `CMAKE_CXX_FLAGS`; it is not baked
into the source profile. The OpenSSL recipe currently supports native arm64 only.
When configuring RoR, select `OPENAL_LIBRARY=<prefix>/lib/libopenal.dylib` and
`OPENAL_INCLUDE_DIR=<prefix>/include/AL` explicitly: CMake's FindOpenAL can otherwise
prefer Apple's SDK framework. Set `CMAKE_FIND_FRAMEWORK=LAST` for prefix discovery.
The legacy Caelum headers require C++11; initialize `Threads` before importing
AngelScript, as current RoR already does. PagedGeometry is static because its
pinned upstream CMake hardcodes that choice.
The documented 11.0 deployment setting is a compile target; a build on a newer
SDK does not establish runtime support on macOS 11.

See [profile provenance](cmake/macos-profile-notes.md) and the exact
[source inventory](cmake/macos-sources.json). The installed
`share/ror-dependencies/manifest.json`, `licenses/`, `build-receipt.json` and
`build-receipt.txt` retain source pins, patch hashes, options, source notices and
completed build settings beside the existing `version.cmake` contract (30).
Configure snapshots the inventory and recipe inputs in the build directory;
changing the source inventory requires a fresh build directory. Metadata is
published only after every configured dependency has completed installation.
Configuring another build type or toolchain does not overwrite a completed receipt.
Before any component installs, completed metadata is replaced with a JSON receipt
whose state is `in-progress`; the completed manifest and text receipt are absent.
Consumers must require the JSON `complete` state and matching manifest hashes.
An interrupted install remains visibly incomplete until the entire graph succeeds.
The in-progress receipt owns the prefix for its configured build: another build
cannot begin installing or publish metadata over it. Complete that owning build
or choose a fresh prefix. A completed prefix may be replaced by another build,
but the replacement earns a new installation ID and every component must install
into that generation before completion. Older build directories cannot refresh
or complete over the new owner. Metadata updates use a prefix-level process lock;
configuration alone does not acquire ownership or write metadata.

The JSON receipt has `schema_version: 1`, `state: "complete"`, `profile`,
`dependencies_version`, `source_inventory_sha256`, `configuration_sha256`,
`recipe_revision`, `recipe_tree_dirty`, `completed_at` (UTC ISO 8601),
`installation_id` (32 hexadecimal digits), and a
`toolchain` object. Its string fields are `cmake_version`, `compiler`, `sdk_version`,
`architecture`, `deployment_target`, and `build_type`. The manifest shares the
receipt's schema, state, hashes, recipe identity, installation ID and completion time. Private paths
and full compiler flags remain in the configured build context, outside installed
metadata. The configuration hash binds that context, including inventory, recipe
input hashes and build settings; it is not a hash of the installed binaries.

Recipe revision/dirty status describes the repository at metadata publication.
After a metadata-only commit, refresh it without rebuilding libraries:

```sh
python3 tools/macos_manifest.py refresh --configured build-macos/macos-configured-build.json
```

Refresh requires unchanged configured inputs and a prior successful completion
of that configuration. Changed recipe code requires reconfiguration; changed
source/patch inventory requires a fresh build directory and build. A refresh
cannot certify an unbuilt graph.

This is a compile foundation. Native window/event behavior, GL3 UI/RTSS shader
integration, feature rendering, Retina/input behavior, application packaging and
binary redistribution clearance remain separate gates. In particular the inventory
preserves mixed Caelum notices and zziplib's dual-license texts without asserting
that a future binary bundle is cleared for distribution.
2 changes: 1 addition & 1 deletion angelscript/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load_from_json()

ExternalProject_Add(
ror_add_dependency(
angelscript
URL ${DOWNLOAD_URL}
URL_HASH SHA256=${DOWNLOAD_SHA256}
Expand Down
8 changes: 7 additions & 1 deletion caelum/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(ROR_MACOS_GL3)
set(CAELUM_MACOS_PATCH PATCH_COMMAND ${ROR_PATCH_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/patches/ogre-include.patch)
endif()

if (WIN32)
# Set paths to help find Ogre on Windows
set(CAELUM_CMAKE_ARGS
Expand All @@ -12,11 +16,12 @@ elseif (UNIX)
)
endif ()

ExternalProject_Add(
ror_add_dependency(
caelum
DEPENDS ogre
URL https://github.com/RigsOfRods/ogre-caelum/archive/70fcf62f306288c9472cc03a42367c9625c839ea.tar.gz
URL_MD5 6fa41168cb93d67e7169d0e8e2d73f24
${CAELUM_MACOS_PATCH}
CMAKE_ARGS
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DCaelum_BUILD_SAMPLES=FALSE
Expand All @@ -28,6 +33,7 @@ ExternalProject_Add(
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
${CAELUM_MACOS_ARGS}
)

if (WIN32)
Expand Down
26 changes: 26 additions & 0 deletions caelum/patches/ogre-include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/main/include/CaelumPrecompiled.h b/main/include/CaelumPrecompiled.h
index e93bd84..69a5460 100644
--- a/main/include/CaelumPrecompiled.h
+++ b/main/include/CaelumPrecompiled.h
@@ -19,7 +19,7 @@ along with Caelum. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __APPLE__
-#include "Ogre/Ogre.h"
+#include <Ogre.h>
#else
#include "Ogre.h"
#endif
diff --git a/main/include/CaelumPrerequisites.h b/main/include/CaelumPrerequisites.h
index 94201e5..f2136ee 100644
--- a/main/include/CaelumPrerequisites.h
+++ b/main/include/CaelumPrerequisites.h
@@ -7,7 +7,7 @@

// Include external headers
#ifdef __APPLE__
-#include "Ogre/Ogre.h"
+#include <Ogre.h>
#else
#include "Ogre.h"
#include "OgreBuildSettings.h"
Loading