diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b690a1..47b0ba4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,8 @@ elseif(SCREENSHOT_BUILD) set(TMS_BACKEND "screenshot-linux") elseif(HAIKU) set(TMS_BACKEND "haiku") +elseif(APPLE) + set(TMS_BACKEND "macos") else() set(TMS_BACKEND "linux") endif() @@ -271,6 +273,8 @@ else() set(COMMON_FLAGS "${COMMON_FLAGS} -DGL_GLEXT_PROTOTYPES -DNO_UI -DTMS_BACKEND_LINUX_SS") elseif(HAIKU) set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_HAIKU") + elseif(APPLE) + set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_MACOS") else() set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_LINUX") endif() @@ -292,9 +296,12 @@ set(CMAKE_CXX_FLAGS_RELEASE "${COMMON_FLAGS_RELEASE} -O2 -fvisibility-inlines-hi set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g") set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_FLAGS_DEBUG}") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O,-s,--gc-sections") -set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-Wl,-O,--gc-sections") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +# macOS Clang's linker doesn't like these flags +if(NOT APPLE) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O,-s,--gc-sections") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-Wl,-O,--gc-sections") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +endif() if(WIN32) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows") diff --git a/src/tms/backends/macos/main.cc b/src/tms/backends/macos/main.cc new file mode 100644 index 00000000..9a6644e5 --- /dev/null +++ b/src/tms/backends/macos/main.cc @@ -0,0 +1,2 @@ +// Inherit from Linux backend +#include "../linux/main.cc" diff --git a/src/tms/core/backend.h b/src/tms/core/backend.h index 85f23ea9..bcdc9936 100644 --- a/src/tms/core/backend.h +++ b/src/tms/core/backend.h @@ -1,22 +1,6 @@ #ifndef _BACKEND__H_ #define _BACKEND__H_ -#if !defined TMS_BACKEND_LINUX \ - && !defined TMS_BACKEND_LINUX_SS \ - && !defined TMS_BACKEND_ANDROID \ - && !defined TMS_BACKEND_WINDOWS \ - && !defined TMS_BACKEND_IOS \ - && !defined TMS_BACKEND_HAIKU - #error Undefined platform, please add a TMS backend for it -#endif - -#if !defined TMS_BACKEND_PC \ - && !defined TMS_BACKEND_MOBILE - #error Either TMS_BACKEND_PC or TMS_BACKEND_MOBILE need to be defined for your platform. -#endif - -#include - #if defined(TMS_BACKEND_WINDOWS) #define OS_STRING "Windows" #elif defined(TMS_BACKEND_LINUX) || defined(TMS_BACKEND_LINUX_SS) @@ -27,10 +11,19 @@ #define OS_STRING "iOS" #elif defined(TMS_BACKEND_HAIKU) #define OS_STRING "Haiku" +#elif defined(TMS_BACKEND_MACOS) + #define OS_STRING "macOS" #else - #define OS_STRING "unknown" + #error Undefined platform, please add a TMS backend for it #endif +#if !defined TMS_BACKEND_PC \ + && !defined TMS_BACKEND_MOBILE + #error Either TMS_BACKEND_PC or TMS_BACKEND_MOBILE need to be defined for your platform. +#endif + +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/tms/core/pipeline.c b/src/tms/core/pipeline.c index a79ac906..295defb3 100644 --- a/src/tms/core/pipeline.c +++ b/src/tms/core/pipeline.c @@ -10,7 +10,7 @@ static struct tms_pipeline pipelines[TMS_NUM_PIPELINES] = {0}; static int n_local_uniforms = 0; -#if defined(TMS_BACKEND_WINDOWS) || defined(TMS_BACKEND_LINUX) || defined(TMS_BACKEND_HAIKU) +#if defined(TMS_BACKEND_PC) || !defined(TMS_BACKEND_LINUX_SS) // Some things in the pipeline are different for Windows/Linux as compared to Android (GL/GLES differences? dunno) // The desktop pipeline is the "cool" pipeline as decided by me. #define TMS_COOL_PIPELINE