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
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
fi

use flake . --impure
25 changes: 22 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ option ( ENABLE_CLANG_ANALYSIS "When building with clang, enable the static anal
option ( CHECK_CCACHE "Check if ccache is installed and use it" OFF )
set ( MSVC_WARNING_LEVEL 3 CACHE STRING "Visual Studio warning levels" )
option ( FORCE_INSTALL_DATA_TO_BIN "Force installation of data to binary directory" OFF )
if ( APPLE )
# Use by default since brew doesn't have legacy SDL1, sdl12-compat avalaible
option ( USE_SDL2 "Using SDL2 via SDL12 compatible layer" ON )
else ()
option ( USE_SDL2 "Using SDL2 via SDL12 compatible layer" OFF )
endif ()
set ( DATADIR "" CACHE STRING "Where to search for datafiles" )

if ( CHECK_CCACHE )
Expand Down Expand Up @@ -91,17 +97,30 @@ if(NOT UNIX AND IS_DIRECTORY ${DEPS_DIR})
else ( )
link_directories ( ${DEPS_DIR}/lib/Win32 )
endif()
set( SDL_LIBRARY SDL )
set ( SDL_LIBRARY SDL )
if ( USE_SDL2 )
# explicitly added SDL2 as dependency since needed for runtime work
set ( SDL2_LIBRARY SDL2 )
message ( STATUS "Using SDL2 via SDL12 compatible layer" )
else ( )
set ( SDL2_LIBRARY "")
endif ()
set ( SDLGFX_LIBRARY SDL_gfx )
set ( SDLMIXER_LIBRARY SDL_mixer )
set ( SDLIMAGE_LIBRARY SDL_image )
set ( PKG_DEPS_LDFLAGS ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLGFX_LIBRARY} ${SDL_LIBRARY} ${OPENGL_LIBRARIES} )
set ( PKG_DEPS_LDFLAGS ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLGFX_LIBRARY} ${SDL_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} )
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this SDL2 added to the dependecies list which trigger copy of it to macos Frameworks library

elseif(UNIX OR MINGW OR CYGWIN)
if(IS_DIRECTORY ${DEPS_DIR})
set(ENV{PKG_CONFIG_PATH} "${DEPS_DIR}/lib/pkgconfig/")
endif()

include(FindPkgConfig)
if ( USE_SDL2 )
# explicitly added SDL2 as dependency since needed for runtime work
pkg_check_modules(PKG_SDL2 REQUIRED sdl2)
else ( )
set ( PKG_SDLG2_LDFLAGS "" )
endif ()
pkg_check_modules(PKG_SDL REQUIRED sdl)
pkg_check_modules(PKG_ZLIB REQUIRED zlib)
pkg_check_modules(PKG_SDLIMAGE REQUIRED SDL_image)
Expand All @@ -110,7 +129,7 @@ elseif(UNIX OR MINGW OR CYGWIN)

include_directories(${PKG_SDL_INCLUDE_DIRS} ${PKG_ZLIB_INCLUDE_DIRS} ${PKG_SDLIMAGE_INCLUDE_DIRS})
include_directories(${PKG_SDLGFX_INCLUDE_DIRS} ${PKG_SDLMIXER_INCLUDE_DIRS})
set(PKG_DEPS_LDFLAGS ${PKG_SDL_LDFLAGS} ${PKG_ZLIB_LDFLAGS} ${PKG_SDLIMAGE_LDFLAGS} ${PKG_SDLGFX_LDFLAGS} ${PKG_SDLMIXER_LDFLAGS} ${OPENGL_LIBRARIES})
set(PKG_DEPS_LDFLAGS ${PKG_SDL_LDFLAGS} ${PKG_SDL2_LDFLAGS} ${PKG_ZLIB_LDFLAGS} ${PKG_SDLIMAGE_LDFLAGS} ${PKG_SDLGFX_LDFLAGS} ${PKG_SDLMIXER_LDFLAGS} ${OPENGL_LIBRARIES})
Copy link
Author

@vkravets vkravets Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using all dependecies of SDL2, which trigger copy of webp and etc libraries which is needed for runtime work


if (UNIX)
set(PKG_DEPS_LDFLAGS "${PKG_DEPS_LDFLAGS};dl")
Expand Down
15 changes: 14 additions & 1 deletion README-OSX.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Building for MacOS

## Dependencies
## Using brew

### Dependencies
To successfully build an OpenXcom OSX bundle you will need to ensure all the relevant dependencies installed in /usr/local/.

The dependencies you require are following:
Expand All @@ -16,6 +18,17 @@ $ brew install cmake sdl sdl_gfx sdl_image sdl_mixer --with-flac --with-libmikmo
```
This should install all of these necessary dependencies to their appropriate place under /usr/local.


## Using Nix

All needed stuff related to installing and configure shell already described at flake.nix, just execute

```
$ nix develop -c $SHELL
```

Note: After it all below building command are applicable

## Building
This project has two ways to build: one with make and the other with Xcode. The make way is typically used for CI builds and produces a similar artifact as the Linux build. If you're just looking to get a quick build, this is a good way to do so. The Xcode way is useful if you're developing features (or bug fixes) and require the need for a debugger or an IDE experience.

Expand Down
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
inputs = {
systems.url = "github:nix-systems/default";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};

outputs =
{
self,
nixpkgs,
systems,
}:
let
forEachSystem =
f: nixpkgs.lib.genAttrs (import systems) (system: f { pkgs = import nixpkgs { inherit system; }; });
in
{
devShells = forEachSystem (
{ pkgs }:
{
default =
pkgs.mkShell.override
{
# override clang 16 runtime
stdenv = pkgs.lowPrio pkgs.llvmPackages_16.stdenv;
}
{
propagatedBuildInputs = [
pkgs.SDL_compat
pkgs.SDL_image
pkgs.libwebp
];

buildInputs = with pkgs; [
git
pkg-config
apple-sdk_15

# Need to use brew cmake since nix use old one 3.30.5
# which has issues with copy libraries to macOs app
cmake
# use clang explicitly since don't use cmake
clang_16
# OpenXcom dependecies
rapidyaml
zlib
#SDL_mixer
# SDL_image
# SDL_gfx
Comment on lines +47 to +49
Copy link
Author

@vkravets vkravets Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This old libraries avalaible for SDL1, using it teh sound and the software rendering is not working, only OpenGL works and there is no video support also

# Try to build using SDL12_compat
(SDL_compat.overrideAttrs (old: {
postInstall = ''
ln -s $out/lib/pkgconfig/sdl12_compat.pc $out/lib/pkgconfig/sdl.pc
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workaround to have working dependecies checking in cmake flow.

Note: The same behavior done in the brew formula

'';
}))
(SDL_mixer.override (old: {
SDL = SDL_compat;
smpeg = old.smpeg.override {
SDL = SDL_compat;
};
}))
(SDL_gfx.override (old: {
SDL = SDL_compat;
}))
(
(SDL_image.override (old: {
SDL = SDL_compat;
})).overrideAttrs
(old: {
propagatedBuildInputs = [ SDL_compat ];
src = pkgs.fetchurl {
url = "https://github.com/libsdl-org/SDL_image/archive/refs/heads/SDL-1.2.tar.gz";
hash = "sha256-ytt87YL2zrvLun7bi5Jd4m5N7/UR09Y3I1kRDAqf6nQ=";
};
patches = [ ];
})
)
];
};
}
);
};
}