1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix compile and link on MAC_OS_X

This commit is contained in:
Sergey Lipskiy 2017-03-03 17:41:18 +07:00
parent 2116d91916
commit 72fef1d9a9
9 changed files with 73 additions and 21 deletions

View File

@ -268,13 +268,18 @@ else(EGL)
endif(NOT OPENGL_FOUND)
endif(EGL)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
#check for G++ 4.8+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#check for compiler version
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION)
if (G++_VERSION VERSION_LESS 4.8)
message(SEND_ERROR "You need at least G++ 4.8 to compile GLideN64!")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND G++_VERSION VERSION_LESS 4.8)
message("Found compiler version " ${G++_VERSION})
message(SEND_ERROR "You need at least G++ 4.8 to compile GLideN64!")
elseif(G++_VERSION VERSION_LESS 3.3)
message("Found compiler version " ${G++_VERSION})
message(SEND_ERROR "You need at least Clang 3.3 to compile GLideN64!")
endif()
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x -static-libgcc")
# SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x -static-libgcc")
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CPP11_COMPILE_FLAGS}" )
SET(GCC_STATIC_LINK_FLAGS "-static-libgcc")
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_STATIC_LINK_FLAGS}" )

View File

@ -34,10 +34,17 @@ if(GLES2)
endif(GLES2)
if(UNIX)
add_definitions(
-DNDEBUG
-DOS_LINUX
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(
-DOS_MAC_OS_X
)
set(APPLE ON)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(
-DNDEBUG
-DOS_LINUX
)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif(UNIX)
if(WIN32)
@ -67,7 +74,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_definitions( -D__MSC__)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x")
if( NOT GHQCHK )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CPP11_COMPILE_FLAGS} -static -fPIC " )
@ -88,7 +95,7 @@ if( NOT GHQCHK )
set_target_properties(GLideNHQd PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(GLideNHQd PROPERTIES LINK_SEARCH_END_STATIC 1)
if(MINGW OR BCMHOST)
if(MINGW OR BCMHOST OR APPLE)
FIND_PACKAGE( ZLIB REQUIRED )
FIND_PACKAGE( PNG REQUIRED )
target_link_libraries(GLideNHQd
@ -96,14 +103,14 @@ if( NOT GHQCHK )
${ZLIB_LIBRARIES}
osald
)
else(MINGW OR BCMHOST)
else(MINGW OR BCMHOST OR APPLE)
target_link_libraries(GLideNHQd PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib/libpng.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libz.a
dl
osald
)
endif(MINGW OR BCMHOST)
endif(MINGW OR BCMHOST OR APPLE)
endif( CMAKE_BUILD_TYPE STREQUAL "Debug")
if( CMAKE_BUILD_TYPE STREQUAL "Release")
@ -120,7 +127,7 @@ if( NOT GHQCHK )
/mnt/utmp/codeblocks/usr/lib/libz.a
osal
)
elseif(BCMHOST OR MINGW)
elseif(BCMHOST OR MINGW OR APPLE)
FIND_PACKAGE( ZLIB REQUIRED )
FIND_PACKAGE( PNG REQUIRED )
target_link_libraries(GLideNHQ

View File

@ -53,8 +53,11 @@
#include <GLES3/gl3ext.h>
#define GL_COLOR_INDEX8_EXT 0x80E5
#elif defined(OS_MAC_OS_X)
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/gl3.h>
#include <GL/glext.h>
#ifndef GL_COLOR_INDEX8_EXT
#define GL_COLOR_INDEX8_EXT 0x80E5
#endif
#elif defined(OS_LINUX)
#include <GL/gl.h>
#include <GL/glext.h>

View File

@ -24,14 +24,17 @@
#include "TxUtil.h"
#include "TxDbg.h"
#include <zlib.h>
#include <malloc.h>
#include <assert.h>
#if defined (OS_MAC_OS_X)
#if defined (OS_WINDOWS)
#include <malloc.h>
#elif defined (OS_MAC_OS_X)
#include <sys/param.h>
#include <sys/sysctl.h>
#elif defined OS_LINUX
#include <stdlib.h>
#elif defined (OS_LINUX)
#include <unistd.h>
#include <malloc.h>
#endif
/*

View File

@ -32,6 +32,26 @@ typedef struct __GLXFBConfigRec *GLXFBConfig;
#define glGetProcAddress glXGetProcAddress
#define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress((const GLubyte*)#proc_name)
#elif defined(OS_MAC_OS_X)
#import <mach-o/dyld.h>
#import <stdlib.h>
#import <string.h>
void * MyNSGLGetProcAddress (const char *name)
{
NSSymbol symbol;
char *symbolName;
symbolName = (char*)malloc (strlen (name) + 2); // 1
strcpy(symbolName + 1, name); // 2
symbolName[0] = '_'; // 3
symbol = NULL;
if (NSIsSymbolNameDefined (symbolName)) // 4
symbol = NSLookupAndBindSymbol (symbolName);
free (symbolName); // 5
return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
}
#define glGetProcAddress MyNSGLGetProcAddress
#define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress(#proc_name)
#endif
//GL Fucntions

View File

@ -10,6 +10,11 @@
#ifdef EGL
#include <GL/glcorearb.h>
#elif defined(OS_MAC_OS_X)
#include <OpenGL/OpenGL.h>
#include <stddef.h>
#include <OpenGL/gl3.h>
//#include <OpenGL/gl3ext.h>
#else
#include <GL/gl.h>
#endif

View File

@ -58,7 +58,7 @@ const char* GLErrorString(GLenum errorCode)
{ GL_INVALID_ENUM, "invalid enumerant" },
{ GL_INVALID_VALUE, "invalid value" },
{ GL_INVALID_OPERATION, "invalid operation" },
#ifndef GLESX
#if !defined(GLESX) && !defined(OS_MAC_OS_X)
{ GL_STACK_OVERFLOW, "stack overflow" },
{ GL_STACK_UNDERFLOW, "stack underflow" },
#endif

View File

@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "Log.h"
#include "PluginAPI.h"
#include "wst.h"

View File

@ -1,9 +1,16 @@
#include "GLideN64_mupenplus.h"
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <Platform.h>
#include "../PluginAPI.h"
#include "../RSP.h"
#if defined(OS_MAC_OS_X)
#include <mach-o/dyld.h>
#endif
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
_initiateGFX(_gfxInfo);
@ -61,9 +68,10 @@ void PluginAPI::FindPluginPath(wchar_t * _strPath)
_getWSPath(path, _strPath);
}
#elif defined(OS_MAC_OS_X)
#define MAXPATHLEN 256
char path[MAXPATHLEN];
uint32_t pathLen = MAXPATHLEN * 2;
if (_NSGetExecutablePath(path, pathLen) == 0) {
if (_NSGetExecutablePath(path, &pathLen) == 0) {
_getWSPath(path, _strPath);
}
#elif defined(OS_ANDROID)