Remove configuration header

This commit is contained in:
Camilla Löwy 2021-04-15 15:33:19 +02:00
parent efe764b492
commit 0a9488e3f0
6 changed files with 37 additions and 88 deletions

View File

@ -61,15 +61,6 @@ else()
set(GLFW_LIB_NAME glfw3)
endif()
if (GLFW_VULKAN_STATIC)
if (GLFW_BUILD_SHARED_LIBRARY)
# If you absolutely must do this, remove this line and add the Vulkan
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
endif()
set(_GLFW_VULKAN_STATIC 1)
endif()
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED)
@ -154,12 +145,7 @@ endif()
# Use Win32 for window creation
#--------------------------------------------------------------------
if (_GLFW_WIN32)
list(APPEND glfw_PKG_LIBS "-lgdi32")
if (GLFW_USE_HYBRID_HPG)
set(_GLFW_USE_HYBRID_HPG 1)
endif()
endif()
#--------------------------------------------------------------------
@ -217,11 +203,6 @@ if (_GLFW_WAYLAND)
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
include(CheckIncludeFiles)
include(CheckFunctionExists)
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(EpollShim)
if (EPOLLSHIM_FOUND)
@ -249,6 +230,11 @@ endif()
# Add the Vulkan loader as a dependency if necessary
#--------------------------------------------------------------------
if (GLFW_VULKAN_STATIC)
if (BUILD_SHARED_LIBS)
# If you absolutely must do this, remove this line and add the Vulkan
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
endif()
list(APPEND glfw_PKG_DEPS "vulkan")
endif()

View File

@ -140,6 +140,7 @@ information on what to include when reporting a bug.
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1
- Disabled tests and examples by default when built as a CMake subdirectory
- Removed CMake generated configuration header
- Bugfix: The CMake config-file package used an absolute path and was not
relocatable (#1470)
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)

View File

@ -341,11 +341,10 @@ a configuration macro to be defined in order to know what window system it is
being compiled for and also has optional, platform-specific ones for various
features.
When building with CMake, the `glfw_config.h` configuration header is generated
based on the current platform and CMake options. The GLFW CMake environment
defines @b GLFW_USE_CONFIG_H, which causes this header to be included by
`internal.h`. Without this macro, GLFW will expect the necessary configuration
macros to be defined on the command-line.
When building, GLFW will expect the necessary configuration macros to be defined
on the command-line. The GLFW CMake files set these as private compile
definitions on the GLFW target but if you compile the GLFW sources manually you
will need to define them yourself.
The window creation API is used to create windows, handle input, monitors, gamma
ramps and clipboard. The options are:

View File

@ -104,8 +104,7 @@ Examples: `isValidElementForJoystick`
@section internals_config Configuration macros
GLFW uses a number of configuration macros to select at compile time which
interfaces and code paths to use. They are defined in the glfw_config.h header file,
which is generated from the `glfw_config.h.in` file by CMake.
interfaces and code paths to use. They are defined in the GLFW CMake target.
Configuration macros the same style as tokens in the public interface, except
with a leading underscore.

View File

@ -15,18 +15,21 @@ add_custom_target(update_mappings
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
if (_GLFW_COCOA)
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
nsgl_context.h egl_context.h osmesa_context.h
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m cocoa_time.c posix_thread.c
nsgl_context.m egl_context.c osmesa_context.c)
elseif (_GLFW_WIN32)
target_compile_definitions(glfw PRIVATE _GLFW_WIN32)
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
egl_context.h osmesa_context.h win32_init.c
win32_joystick.c win32_monitor.c win32_time.c
win32_thread.c win32_window.c wgl_context.c
egl_context.c osmesa_context.c)
elseif (_GLFW_X11)
target_compile_definitions(glfw PRIVATE _GLFW_X11)
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h
posix_thread.h glx_context.h egl_context.h
osmesa_context.h x11_init.c x11_monitor.c
@ -34,12 +37,14 @@ elseif (_GLFW_X11)
posix_thread.c glx_context.c egl_context.c
osmesa_context.c)
elseif (_GLFW_WAYLAND)
target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
xkb_unicode.h egl_context.h osmesa_context.h
wl_init.c wl_monitor.c wl_window.c posix_time.c
posix_thread.c xkb_unicode.c egl_context.c
osmesa_context.c)
elseif (_GLFW_OSMESA)
target_compile_definitions(glfw PRIVATE _GLFW_OSMESA)
target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
posix_thread.h osmesa_context.h null_init.c
null_monitor.c null_window.c null_joystick.c
@ -55,6 +60,17 @@ if (_GLFW_X11 OR _GLFW_WAYLAND)
endif()
if (_GLFW_WAYLAND)
include(CheckIncludeFiles)
include(CheckFunctionExists)
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
if (HAVE_XKBCOMMON_COMPOSE_H)
target_compile_definitions(glfw PRIVATE HAVE_XKBCOMMON_COMPOSE_H)
endif()
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
if (HAVE_MEMFD_CREATE)
target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
endif()
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
@ -102,10 +118,6 @@ if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
endif()
configure_file(glfw_config.h.in glfw_config.h @ONLY)
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME}
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
@ -132,6 +144,10 @@ if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
LANGUAGE C)
endif()
if (GLFW_VULKAN_STATIC)
target_compile_definitions(glfw PRIVATE _GLFW_VULKAN_STATIC)
endif()
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
# source files that VS will build (Clang ignores this because we set -std=c99)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
@ -143,6 +159,12 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
COMPILE_FLAGS -Wdeclaration-after-statement)
endif()
if (WIN32)
if (GLFW_USE_HYBRID_HPG)
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
endif()
endif()
# Enable a reasonable set of warnings
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
if (MSVC)

View File

@ -1,58 +0,0 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// As glfw_config.h.in, this file is used by CMake to produce the
// glfw_config.h configuration header file. If you are adding a feature
// requiring conditional compilation, this is where to add the macro.
//========================================================================
// As glfw_config.h, this file defines compile-time option macros for a
// specific platform and development environment. If you are using the
// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
// are using your own build system, make this file define the appropriate
// macros in whatever way is suitable.
//========================================================================
// Define this to 1 if building GLFW for X11
#cmakedefine _GLFW_X11
// Define this to 1 if building GLFW for Win32
#cmakedefine _GLFW_WIN32
// Define this to 1 if building GLFW for Cocoa
#cmakedefine _GLFW_COCOA
// Define this to 1 if building GLFW for Wayland
#cmakedefine _GLFW_WAYLAND
// Define this to 1 if building GLFW for OSMesa
#cmakedefine _GLFW_OSMESA
// 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
// Define this to 1 if xkbcommon supports the compose key
#cmakedefine HAVE_XKBCOMMON_COMPOSE_H
// Define this to 1 if the libc supports memfd_create()
#cmakedefine HAVE_MEMFD_CREATE