Commit 32b2ea52 authored by Wes Tarro's avatar Wes Tarro
Browse files

Fixed building with GCC - needed different options and had to create a dummy

DLL entry to avoid crashes.
parent 969faeaf
...@@ -124,7 +124,9 @@ static GLenum GLEWAPIENTRY glewContextInit () ...@@ -124,7 +124,9 @@ static GLenum GLEWAPIENTRY glewContextInit ()
GLEW_VERSION_1_1 = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_1 = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
} }
for (size_t i = 0; i < sizeof(_glewExtensionLookup) / sizeof(char*); ++i) _glewExtensionString[i] = GL_FALSE; size_t n;
for (n = 0; n < sizeof(_glewExtensionString) / sizeof(_glewExtensionString[0]); ++n)
_glewExtensionString[n] = GL_FALSE;
if (GLEW_VERSION_3_0) if (GLEW_VERSION_3_0)
{ {
......
...@@ -78,6 +78,10 @@ set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c) ...@@ -78,6 +78,10 @@ set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c)
if (WIN32) if (WIN32)
list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/build/glew.rc) list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/build/glew.rc)
if ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
# GCC can't handle not having a DLL entry point, so give it a fake one
list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/src/gcc_dll_entry.c)
endif ()
endif () endif ()
add_library (glew SHARED ${GLEW_SRC_FILES}) add_library (glew SHARED ${GLEW_SRC_FILES})
...@@ -85,18 +89,21 @@ set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_N ...@@ -85,18 +89,21 @@ set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_N
add_library (glew_s STATIC ${GLEW_SRC_FILES}) add_library (glew_s STATIC ${GLEW_SRC_FILES})
set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib) set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib)
if (MSVC) if (MSVC)
# add options from visual studio project and remove stdlib dependency # add options from visual studio project
target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN") target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN")
target_compile_definitions (glew_s PRIVATE "GLEW_STATIC;VC_EXTRALEAN") target_compile_definitions (glew_s PRIVATE "GLEW_STATIC;VC_EXTRALEAN")
target_link_libraries (glew PRIVATE -BASE:0x62AA0000)
# kill security checks which are dependent on stdlib # kill security checks which are dependent on stdlib
target_compile_options (glew PRIVATE -GS-) target_compile_options (glew PRIVATE -GS-)
target_compile_options (glew_s PRIVATE -GS-) target_compile_options (glew_s PRIVATE -GS-)
target_link_libraries (glew PRIVATE -BASE:0x62AA0000 -nodefaultlib -noentry) # remove stdlib dependency
target_link_libraries (glew PRIVATE -nodefaultlib -noentry)
elseif (WIN32 AND ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))) elseif (WIN32 AND ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang")))
# remove stdlib dependency on windows with GCC and Clang (for similar reasons # remove stdlib dependency on windows with GCC and Clang (for similar reasons
# as to MSVC - to allow it to be used with any Windows compiler) # as to MSVC - to allow it to be used with any Windows compiler)
# not thoroughly tested yet! target_compile_options (glew PRIVATE -fno-builtin -fno-stack-protector)
target_link_libraries (glew PRIVATE -nostdlibs -lgcc) target_compile_options (glew_s PRIVATE -fno-builtin -fno-stack-protector)
target_link_libraries (glew PRIVATE -nostdlib)
endif () endif ()
target_link_libraries (glew PUBLIC ${GLEW_LIBRARIES}) target_link_libraries (glew PUBLIC ${GLEW_LIBRARIES})
target_link_libraries (glew_s ${GLEW_LIBRARIES}) target_link_libraries (glew_s ${GLEW_LIBRARIES})
......
#ifdef GLEW_BUILD
#include <windows.h>
BOOL WINAPI DllMainCRTStartup(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
return TRUE;
}
#endif
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment