From 286c41af5264511073c1da73d6b5d7de324c22ab Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 29 Jul 2018 22:42:10 +0200 Subject: [PATCH] Sync with upstream GLFW pull request The GLFW tree distributed with raylib has two modifications: - GLFW_PKG_{DEPS,LIBS} are exported to PARENT_SCOPE, so we can use them in our pkg-config file - An intermediary glfw_objlib target is added, so we can reexport GLFW symbols from libraylib.a rglfw can fix the second point, but for Wayland usage, we would have to replicate protocol generation, so we just leverage GLFW's existing support instead. To make maintenance easier, I have submitted a pull request for including these modifications to upstream GLFW. And to make that one easier, this patch dog-foods the modifications, so raylib users can help find regressions. :-) glfw/glfw#1307 --- src/CMakeLists.txt | 4 ---- src/external/glfw/CMakeLists.txt | 6 ++++-- src/external/glfw/src/CMakeLists.txt | 13 ++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70cb55277..5581cc7ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,12 +33,8 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE) set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE) - if (WITH_PIC OR SHARED) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - endif() add_subdirectory(external/glfw) - include_directories(BEFORE SYSTEM external/glfw/include) list(APPEND raylib_sources $) else() diff --git a/src/external/glfw/CMakeLists.txt b/src/external/glfw/CMakeLists.txt index 0eb7e7ea0..83fe954e0 100644 --- a/src/external/glfw/CMakeLists.txt +++ b/src/external/glfw/CMakeLists.txt @@ -327,10 +327,12 @@ endif() # Export GLFW library dependencies #-------------------------------------------------------------------- foreach(arg ${glfw_PKG_DEPS}) - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" PARENT_SCOPE) + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL + "GLFW pkg-config Requires.private") endforeach() foreach(arg ${glfw_PKG_LIBS}) - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" PARENT_SCOPE) + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL + "GLFW pkg-config Libs.private") endforeach() #-------------------------------------------------------------------- diff --git a/src/external/glfw/src/CMakeLists.txt b/src/external/glfw/src/CMakeLists.txt index fe0608449..76460769a 100644 --- a/src/external/glfw/src/CMakeLists.txt +++ b/src/external/glfw/src/CMakeLists.txt @@ -94,18 +94,20 @@ endif() add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS}) add_library(glfw $) - +set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION} SOVERSION ${GLFW_VERSION_MAJOR} - POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw_objlib PUBLIC "$" "$/include>") +target_include_directories(glfw PUBLIC + "$" + "$/include>") target_include_directories(glfw_objlib PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" @@ -143,17 +145,17 @@ if (BUILD_SHARED_LIBS) INSTALL_NAME_DIR "lib${LIB_SUFFIX}") elseif (UNIX) # Hide symbols not explicitly tagged for export from the shared library - target_compile_options(glfw PRIVATE "-fvisibility=hidden") + target_compile_options(glfw_objlib PRIVATE "-fvisibility=hidden") endif() - target_compile_definitions(glfw INTERFACE GLFW_DLL) + target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL) target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) else() target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) endif() if (MSVC) - target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) + target_compile_definitions(glfw_objlib PRIVATE _CRT_SECURE_NO_WARNINGS) endif() if (GLFW_INSTALL) @@ -163,3 +165,4 @@ if (GLFW_INSTALL) ARCHIVE DESTINATION "lib${LIB_SUFFIX}" LIBRARY DESTINATION "lib${LIB_SUFFIX}") endif() +