diff --git a/.gitmodules b/.gitmodules index a9e0a5c1a..29f8850ef 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "externals/nihstro"] path = externals/nihstro url = https://github.com/neobrain/nihstro.git +[submodule "externals/libepoxy/libepoxy"] + path = externals/libepoxy/libepoxy + url = https://github.com/anholt/libepoxy.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 9151fe479..6a3bcba01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ else() endif() add_definitions(-DSINGLETHREADED) +find_package(PkgConfig) + find_package(PNG QUIET) if (PNG_FOUND) add_definitions(-DHAVE_PNG) @@ -55,6 +57,16 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) +pkg_search_module(LIBEPOXY epoxy) +if(LIBEPOXY_FOUND) + message("Using shared libepoxy") +else() + message("Using static libepoxy from externals") + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/externals/libepoxy) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/externals/libepoxy/include + ${CMAKE_CURRENT_SOURCE_DIR}/externals/libepoxy/libepoxy/include) +endif() + option(ENABLE_GLFW "Enable the GLFW frontend" ON) if (ENABLE_GLFW) if (WIN32) diff --git a/externals/libepoxy/CMakeLists.txt b/externals/libepoxy/CMakeLists.txt new file mode 100644 index 000000000..910552727 --- /dev/null +++ b/externals/libepoxy/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 2.6) + +project(libepoxy) + +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") +add_definitions(-std=c99) + +set(top_srcdir ${CMAKE_CURRENT_SOURCE_DIR}/libepoxy) +set(top_builddir ${CMAKE_CURRENT_BINARY_DIR}) +set(srcdir ${top_srcdir}/src) +set(builddir ${top_builddir}/src) + +make_directory(${top_builddir}/include/epoxy) +make_directory(${top_builddir}/src) + +foreach(REGISTRY gl egl glx wgl) + execute_process(COMMAND python3 ${srcdir}/gen_dispatch.py --dir ${top_builddir} ${top_srcdir}/registry/${REGISTRY}.xml) +endforeach() + +include_directories(${top_srcdir}/include) + +set(SRCS ${srcdir}/dispatch_common.c ${builddir}/gl_generated_dispatch.c) + +if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if (WIN32) + set(SRCS ${SRCS} ${srcdir}/dispatch_wgl.c ${builddir}/wgl_generated_dispatch.c) + elseif (NOT APPLE) + find_package(X11) + if (NOT X11_FOUND) + set(SRCS ${SRCS} ${srcdir}/dispatch_glx.c ${builddir}/glx_generated_dispatch.c) + endif() + set(SRCS ${SRCS} ${srcdir}/dispatch_egl.c ${builddir}/egl_generated_dispatch.c) + endif() +endif() + +add_library(epoxy STATIC ${SRCS}) diff --git a/externals/libepoxy/libepoxy b/externals/libepoxy/libepoxy new file mode 160000 index 000000000..20062c25e --- /dev/null +++ b/externals/libepoxy/libepoxy @@ -0,0 +1 @@ +Subproject commit 20062c25e7612cab023cdef44d3277ba1bd0b2de