Skip to content

Commit

Permalink
Add macOS support (#58)
Browse files Browse the repository at this point in the history
* Fix compiling on macOS

* Add malloc.h include path only for APPLE

* Add macOS build instructions to README

* Fix typo in CMakeLists.txt

* Fix compiling on macOS

* Add malloc.h include path only for APPLE

* Add macOS build instructions to README

* Fix typo in CMakeLists.txt
  • Loading branch information
Matherunner authored and YaLTeR committed Aug 22, 2018
1 parent 205f5e0 commit 655ffc9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
22 changes: 18 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ target_include_directories(client PRIVATE
public
utils/vgui/include)

if(APPLE)
target_include_directories(client SYSTEM PRIVATE /usr/include/malloc)
endif(APPLE)

# Set up some additional compile flags and definitions
if(MSVC)
target_compile_options(client PRIVATE
Expand Down Expand Up @@ -155,10 +159,20 @@ elseif(UNIX)
-DDISABLE_JUMP_ORIGIN
-DDISABLE_VEC_ORIGIN)

# I wasn't able to do this in any other way.
# Things like imported targets result in linking with relative path.
set_property(TARGET client PROPERTY LINK_FLAGS
"-L${CMAKE_SOURCE_DIR}/linux/release -l:vgui.so")
if(APPLE)
find_library(MAC_CARBON Carbon)
find_library(MAC_OPENGL OpenGL)
target_link_libraries(client
${MAC_CARBON}
${MAC_OPENGL}
${CMAKE_SOURCE_DIR}/linux/libSDL2-2.0.0.dylib
${CMAKE_SOURCE_DIR}/linux/release/vgui.dylib)
else(APPLE)
# I wasn't able to do this in any other way.
# Things like imported targets result in linking with relative path.
set_property(TARGET client PROPERTY LINK_FLAGS
"-L${CMAKE_SOURCE_DIR}/linux/release -l:vgui.so")
endif(APPLE)
endif(WIN32)

target_compile_definitions(client PRIVATE
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ OpenAG is an open-source client of the Half-Life promod Adrenaline Gamer, comple
5. `cmake ..`
6. `cmake --build . --config Release`

## macOS
1. Install Xcode.
2. Install CMake via Homebrew.
3. `git submodule update --init`
4. `mkdir build`
5. `cd build`
6. `cmake ..`
7. `cmake --build . --config Release`

## Linux
1. Get a 32-bit/multilib **gcc** (6 and above) or **clang** (3.9 and above) build environment set up, as well as CMake.
2. `git submodule update --init`
Expand Down
4 changes: 4 additions & 0 deletions cl_dll/hudgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include <Windows.h>
#endif

#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif

HudGL::HudGL() {
// Same steps as FillRGBA does.
Expand Down
2 changes: 2 additions & 0 deletions dlls/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ typedef int EOFFSET;
typedef int BOOL;

// In case this ever changes
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

// Keeps clutter down a bit, when declaring external entity/global method prototypes
#define DECLARE_GLOBAL_METHOD(MethodName) extern void UTIL_DLLEXPORT MethodName( void )
Expand Down

0 comments on commit 655ffc9

Please sign in to comment.