1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-22 18:28:52 -05:00

Add option to build API exporting object library

This will cause the GLFW public API to be exported by any shared
library or executable that links the GLFW object library.

This option is only available when GLFW_LIBRARY_TYPE is set to OBJECT.
This commit is contained in:
Camilla Löwy 2021-07-30 19:47:44 +02:00
parent d3c6a3f212
commit 0fd56917ce
3 changed files with 17 additions and 6 deletions

View File

@ -131,6 +131,8 @@ information on what to include when reporting a bug.
surface extension (#1793)
- Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type
(#279,#1307,#1497,#1574,#1928)
- Added `GLFW_EXPORT_PUBLIC_API` CMake option for building an object library that exports
the public API
- Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1

View File

@ -271,6 +271,12 @@ with the library. This is enabled by default if
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
directly with the application. This is disabled by default.
@anchor GLFW_EXPORT_PUBLIC_API
__GLFW_EXPORT_PUBLIC_API__ is only available when building GLFW as a CMake object library.
It determines whether the object files export the public GLFW API. This is useful for
example when linking GLFW into in a larger shared library. See @ref GLFW_LIBRARY_TYPE for
how to build an object library.
@subsection compile_options_win32 Windows specific CMake options

View File

@ -100,9 +100,17 @@ set_target_properties(glfw PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_STANDARD 99
C_EXTENSIONS OFF
DEFINE_SYMBOL _GLFW_BUILD_DLL
FOLDER "GLFW3")
if (GLFW_BUILD_SHARED_LIBRARY OR GLFW_EXPORT_PUBLIC_API)
target_compile_definitions(glfw PRIVATE _GLFW_BUILD_DLL)
endif()
if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif()
target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
@ -230,11 +238,6 @@ if (GLFW_BUILD_SHARED_LIBRARY)
# Clear flags again to avoid breaking later tests
set(CMAKE_REQUIRED_FLAGS)
endif()
if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif()
endif()
if (GLFW_INSTALL)