From 3406f01ff9d8b80cc37f4dd11aabee7f5da1dab2 Mon Sep 17 00:00:00 2001 From: Learath2 Date: Fri, 9 Jun 2017 16:02:27 +0200 Subject: [PATCH] Fix OSX cmake build A little crude but it works. --- CMakeLists.txt | 16 ++++++++++++++-- src/engine/client/client.cpp | 6 +++--- src/osx/{notification.m => notification.mm} | 0 3 files changed, 17 insertions(+), 5 deletions(-) rename src/osx/{notification.m => notification.mm} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba967c8de..f4569525b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,9 @@ endif() if(TARGET_OS STREQUAL "windows") set(PLATFORM_CLIENT_LIBS opengl32 glu32 winmm) set(PLATFORM_LIBS ws2_32) # Windows sockets +elseif(TARGET_OS STREQUAL "mac") + set(PLATFORM_CLIENT_LIBS "-framework OpenGL" "-framework Cocoa" "-framework AGL" "-framework Carbon" "-framework NotificationCenter") + set(PLATFORM_SERVER_LIBS "-framework Carbon") else() set(PLATFORM_CLIENT_LIBS GL GLU X11) if(TARGET_OS STREQUAL "linux") @@ -252,6 +255,15 @@ else() set(DEP_WEBSOCKETS) endif() +if(TARGET_OS STREQUAL "mac") + file(GLOB DEP_OSX_SRC "src/osx/*.mm") + add_library(osx EXCLUDE_FROM_ALL OBJECT ${DEP_OSX_SRC}) + set(DEP_OSX $) + list(APPEND TARGETS_DEP osx) +else() + set(DEP_OSX) +endif() + set(DEPS ${DEP_MD5} ${DEP_WEBSOCKETS} ${DEP_ZLIB}) # Libraries @@ -275,7 +287,7 @@ if(CLIENT) set(GAME_GENERATED_CLIENT "src/game/generated/client_data.cpp" "src/game/generated/client_data.h") set(CLIENT_SRC ${ENGINE_CLIENT} ${GAME_CLIENT} ${GAME_EDITOR} ${GAME_GENERATED_CLIENT}) - set(DEPS_CLIENT ${DEPS} ${DEP_JSON} ${DEP_PNG} ${DEP_WAV}) + set(DEPS_CLIENT ${DEPS} ${DEP_JSON} ${DEP_PNG} ${DEP_WAV} ${DEP_OSX}) # Libraries set(LIBS_CLIENT @@ -337,7 +349,7 @@ else() endif() # Libraries -set(LIBS_SERVER ${LIBS} ${MYSQL_LIBRARIES}) +set(LIBS_SERVER ${LIBS} ${MYSQL_LIBRARIES} ${PLATFORM_SERVER_LIBS}) # Target set(TARGET_SERVER ${SERVER_EXECUTABLE}) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index ef0e2b687..ba75f962b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3482,14 +3482,14 @@ static CClient *CreateClient() Upstream latency */ -#if defined(CONF_PLATFORM_MACOSX) || defined(__ANDROID__) +/*#if defined(CONF_PLATFORM_MACOSX) || defined(__ANDROID__) extern "C" int SDL_main(int argc, char **argv_) // ignore_convention { const char **argv = const_cast(argv_); -#else +#else*/ int main(int argc, const char **argv) // ignore_convention { -#endif +//#endif #if defined(CONF_FAMILY_WINDOWS) for(int i = 1; i < argc; i++) // ignore_convention { diff --git a/src/osx/notification.m b/src/osx/notification.mm similarity index 100% rename from src/osx/notification.m rename to src/osx/notification.mm