Cleanup of 8bdb105897.

Add build macro to configuration header and documentation.  Add
corresponding CMake option.  Add change log entry and credit.  Add
loader static library to link dependencies and add detection to
FindVulkan.cmake.
This commit is contained in:
Camilla Berglund 2016-08-05 00:23:16 +02:00
parent 8bdb105897
commit 7c3706763a
8 changed files with 43 additions and 7 deletions

View File

@ -12,6 +12,9 @@ if (WIN32)
find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS
"$ENV{VULKAN_SDK}/Bin"
"$ENV{VK_SDK_PATH}/Bin")
find_library(VULKAN_STATIC_LIBRARY NAMES vkstatic.1 HINTS
"$ENV{VULKAN_SDK}/Bin"
"$ENV{VK_SDK_PATH}/Bin")
else()
find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS
"$ENV{VULKAN_SDK}/Bin32"
@ -27,5 +30,5 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY)
mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY VULKAN_STATIC_LIBRARY)

View File

@ -25,6 +25,7 @@ option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
option(GLFW_INSTALL "Generate installation target" ON)
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
if (WIN32)
@ -57,6 +58,10 @@ else()
set(GLFW_LIB_NAME glfw3)
endif()
if (GLFW_VULKAN_STATIC)
set(_GLFW_VULKAN_STATIC 1)
endif()
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED)
@ -148,6 +153,21 @@ else()
message(FATAL_ERROR "No supported platform was detected")
endif()
#--------------------------------------------------------------------
# Add Vulkan static library if requested
#--------------------------------------------------------------------
if (GLFW_VULKAN_STATIC)
if (VULKAN_FOUND AND VULKAN_STATIC_LIBRARY)
list(APPEND glfw_LIBRARIES ${VULKAN_STATIC_LIBRARY})
else()
if (BUILD_SHARED_LIBS OR GLFW_BUILD_EXAMPLES OR GLFW_BUILD_TESTS)
message(FATAL_ERROR "Vulkan loader static library not found")
else()
message(WARNING "Vulkan loader static library not found")
endif()
endif()
endif()
#--------------------------------------------------------------------
# Find and add Unix math and time libraries
#--------------------------------------------------------------------

View File

@ -93,6 +93,8 @@ information on what to include when reporting a bug.
## Changelog
- Added on-demand loading of Vulkan and context creation API libraries
- Added `_GLFW_VULKAN_STATIC` build macro to make the library use the Vulkan
loader linked statically into the application
- Bugfix: Single compilation unit builds failed due to naming conflicts (#783)
- Bugfix: The range checks for `glfwSetCursorPos` used the wrong minimum (#773)
- [Win32] Bugfix: `glfwSetClipboardString` created an unnecessary intermediate
@ -208,6 +210,7 @@ skills.
- Emmanuel Gil Peyrot
- Cyril Pichard
- Pieroman
- Philip Rideout
- Jorge Rodriguez
- Ed Ropple
- Aleksey Rybalkin

View File

@ -197,6 +197,9 @@ built along with the library.
`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
the library.
`GLFW_VULKAN_STATIC` determines whether to use the Vulkan loader linked
statically into the application.
@subsubsection compile_options_osx OS X specific CMake options
@ -251,6 +254,10 @@ ramps and clipboard. The options are:
If you are building GLFW as a shared library / dynamic library / DLL then you
must also define `_GLFW_BUILD_DLL`. Otherwise, you must not define it.
If you are linking the Vulkan loader statically into your application then you
must also define `_GLFW_VULKAN_STATIC`. Otherwise, GLFW will attempt to use the
external version.
For the EGL context creation API, the following options are available:
- `_GLFW_USE_EGLPLATFORM_H` to use `EGL/eglplatform.h` for native handle

View File

@ -47,6 +47,8 @@
// Define this to 1 if building as a shared library / dynamic library / DLL
#cmakedefine _GLFW_BUILD_DLL
// Define this to 1 to use Vulkan loader linked statically into application
#cmakedefine _GLFW_VULKAN_STATIC
// Define this to 1 to force use of high-performance GPU on hybrid systems
#cmakedefine _GLFW_USE_HYBRID_HPG

View File

@ -450,10 +450,10 @@ struct _GLFWlibrary
void* handle;
char** extensions;
uint32_t extensionCount;
#if !defined(_GLFW_VULKAN_STATIC)
#if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
#endif
#endif
GLFWbool KHR_surface;
GLFWbool KHR_win32_surface;
GLFWbool KHR_xlib_surface;

View File

@ -80,7 +80,6 @@ GLFWbool _glfwInitVulkan(void)
_glfwTerminateVulkan();
return GLFW_FALSE;
}
#endif // _GLFW_VULKAN_STATIC
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);

View File

@ -48,7 +48,9 @@ set(CONSOLE_BINARIES clipboard events msaa gamma glfwinfo
if (VULKAN_FOUND)
add_executable(vulkan WIN32 vulkan.c ${ICON})
target_include_directories(vulkan PRIVATE "${VULKAN_INCLUDE_DIR}")
if (NOT GLFW_VULKAN_STATIC)
target_link_libraries(vulkan "${VULKAN_LIBRARY}")
endif()
list(APPEND WINDOWS_BINARIES vulkan)
endif()