-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable compilation with MinGW on Windows
- Loading branch information
1 parent
1e76224
commit 0bbbac8
Showing
3 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,79 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) | ||
set(PROJECT_NAME 3rd_${MODULE_NAME}) | ||
project(${PROJECT_NAME}) | ||
project(${PROJECT_NAME} C) | ||
|
||
include(GNUInstallDirs) | ||
|
||
if (POLICY CMP0003) | ||
cmake_policy(SET CMP0003 NEW) | ||
endif () | ||
|
||
add_library(${PROJECT_NAME} STATIC | ||
include/GL/eglew.h | ||
include/GL/glew.h | ||
include/GL/glxew.h | ||
include/GL/wglew.h | ||
src/glew.c | ||
) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
FOLDER "3rd_party") | ||
if (POLICY CMP0042) | ||
cmake_policy(SET CMP0042 NEW) | ||
endif () | ||
|
||
if (POLICY CMP0072) | ||
cmake_policy(SET CMP0072 NEW) | ||
endif (POLICY CMP0072) | ||
|
||
option(GLEW_X11 "X11 mode" ON) | ||
|
||
set(GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
# get version from config/version | ||
file(STRINGS ${GLEW_DIR}/config/version _VERSION_MAJOR_STRING REGEX "GLEW_MAJOR[ ]*=[ ]*[0-9]+.*") | ||
string(REGEX REPLACE "GLEW_MAJOR[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${_VERSION_MAJOR_STRING}) | ||
file(STRINGS ${GLEW_DIR}/config/version _VERSION_MINOR_STRING REGEX "GLEW_MINOR[ ]*=[ ]*[0-9]+.*") | ||
string(REGEX REPLACE "GLEW_MINOR[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_MINOR ${_VERSION_MINOR_STRING}) | ||
file(STRINGS ${GLEW_DIR}/config/version _VERSION_PATCH_STRING REGEX "GLEW_MICRO[ ]*=[ ]*[0-9]+.*") | ||
string(REGEX REPLACE "GLEW_MICRO[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${_VERSION_PATCH_STRING}) | ||
set(GLEW_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE ${ADTREE_glew_INCLUDE_DIR}) | ||
if (NOT GLEW_CUSTOM_OUTPUT_DIRS) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
endif () | ||
|
||
find_package(OpenGL REQUIRED) | ||
|
||
# cmake<3.10 doesn't detect EGL/GLX | ||
if (CMAKE_VERSION VERSION_LESS 3.10) | ||
find_library(OPENGL_egl_LIBRARY NAMES EGL) | ||
if (OPENGL_egl_LIBRARY) | ||
set(OpenGL_EGL_FOUND TRUE) | ||
endif () | ||
endif () | ||
|
||
# prefer GLVND | ||
if (OPENGL_opengl_LIBRARY) | ||
set(GLEW_LIBRARIES ${OPENGL_opengl_LIBRARY}) | ||
else () | ||
set(GLEW_LIBRARIES ${OPENGL_gl_LIBRARY}) | ||
endif () | ||
|
||
# X11 required except for Windows and Apple OSX platforms | ||
if (GLEW_X11 AND NOT WIN32 AND NOT APPLE) | ||
find_package(X11) | ||
list(APPEND GLEW_LIBRARIES ${X11_LIBRARIES}) | ||
endif () | ||
|
||
add_library(${PROJECT_NAME} STATIC | ||
${GLEW_DIR}/include/GL/wglew.h | ||
${GLEW_DIR}/include/GL/glew.h | ||
${GLEW_DIR}/include/GL/glxew.h | ||
${GLEW_DIR}/include/GL/eglew.h | ||
${GLEW_DIR}/src/glew.c | ||
) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "3rd_party") | ||
|
||
target_compile_definitions(${PROJECT_NAME} PRIVATE GLEW_STATIC) | ||
if (MSVC) | ||
# add options from visual studio project | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE "GLEW_STATIC;VC_EXTRALEAN") | ||
# kill security checks which are dependent on stdlib | ||
target_compile_options(${PROJECT_NAME} PRIVATE -GS-) | ||
endif () | ||
|
||
target_compile_definitions(${PROJECT_NAME} PUBLIC GLEW_NO_GLU) | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_DIR}/include ${X11_INCLUDE_DIR}) | ||
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${GLEW_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
GLEW_MAJOR = 2 | ||
GLEW_MINOR = 2 | ||
GLEW_MICRO = 0 | ||
GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO) | ||
GLEW_NAME = GLEW | ||
SO_MAJOR = $(GLEW_MAJOR).$(GLEW_MINOR) | ||
SO_VERSION = $(GLEW_VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters