Compare commits

...

3 Commits

Author SHA1 Message Date
Camilla Löwy
a576a56a8d Remove unused CMake find module for OSMesa 2024-11-27 16:26:00 +01:00
Camilla Löwy
b850107a32 Update minimum CMake version to 3.16
This replaces some workarounds and manual logic with new features
available with CMake 3.16, including list(FILTER), list(JOIN),
foreach(IN LISTS) and enable_language(OBJC).  Policy settings no longer
needed with 3.16 have been removed.

Related to #2541
2024-11-27 16:25:07 +01:00
Camilla Löwy
043378876a Use CMakePushCheckState for check state management 2024-05-09 17:18:39 +02:00
6 changed files with 36 additions and 82 deletions

View File

@ -1,6 +1,8 @@
# Usage: # Usage:
# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h> # cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
cmake_policy(VERSION 3.16)
set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
set(template_path "${CMAKE_ARGV3}") set(template_path "${CMAKE_ARGV3}")
@ -22,8 +24,9 @@ if (status_code)
endif() endif()
file(STRINGS "${source_path}" lines) file(STRINGS "${source_path}" lines)
foreach(line ${lines}) list(FILTER lines INCLUDE REGEX "^[0-9a-fA-F]")
if (line MATCHES "^[0-9a-fA-F]")
foreach(line IN LISTS lines)
if (line MATCHES "platform:Windows") if (line MATCHES "platform:Windows")
if (GLFW_WIN32_MAPPINGS) if (GLFW_WIN32_MAPPINGS)
string(APPEND GLFW_WIN32_MAPPINGS "\n") string(APPEND GLFW_WIN32_MAPPINGS "\n")
@ -40,7 +43,6 @@ foreach(line ${lines})
endif() endif()
string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
endif() endif()
endif()
endforeach() endforeach()
configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX) configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)

View File

@ -1,18 +0,0 @@
# Try to find OSMesa on a Unix system
#
# This will define:
#
# OSMESA_LIBRARIES - Link these to use OSMesa
# OSMESA_INCLUDE_DIR - Include directory for OSMesa
#
# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
if (NOT WIN32)
find_package (PkgConfig)
pkg_check_modules (PKG_OSMESA QUIET osmesa)
set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES})
endif ()

View File

@ -1,14 +1,6 @@
cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR)
project(GLFW VERSION 3.5.0 LANGUAGES C) project(GLFW VERSION 3.5.0 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/")
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@ -80,25 +72,8 @@ endif()
# This is here because it also applies to tests and examples # This is here because it also applies to tests and examples
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL) if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (CMAKE_VERSION VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
if (flag MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (flag MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
endforeach()
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif() endif()
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Create generated files # Create generated files

View File

@ -90,7 +90,7 @@ in the documentation for more information.
## Dependencies ## Dependencies
GLFW itself needs only CMake 3.4 or later and the headers and libraries for your GLFW itself needs only CMake 3.16 or later and the headers and libraries for your
OS and window system. OS and window system.
The examples and test programs depend on a number of tiny libraries. These are The examples and test programs depend on a number of tiny libraries. These are
@ -123,6 +123,7 @@ information on what to include when reporting a bug.
- Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
the limit of the mouse button tokens to be reported (#2423) the limit of the mouse button tokens to be reported (#2423)
- Updated minimum CMake version to 3.16 (#2541)
- [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Added `QuartzCore` framework as link-time dependency
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: The fractional scaling related objects were not destroyed

View File

@ -264,8 +264,8 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th
static library version of the Visual C++ runtime library. When enabled, the static library version of the Visual C++ runtime library. When enabled, the
DLL version of the Visual C++ library is used. This is enabled by default. DLL version of the Visual C++ library is used. This is enabled by default.
On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY][] It is recommended to set the standard CMake variable [CMAKE_MSVC_RUNTIME_LIBRARY][]
variable instead of this GLFW-specific option. instead of this GLFW-specific option.
[CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html [CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html

View File

@ -30,6 +30,7 @@ add_custom_target(update_mappings
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
if (GLFW_BUILD_COCOA) if (GLFW_BUILD_COCOA)
enable_language(OBJC)
target_compile_definitions(glfw PRIVATE _GLFW_COCOA) target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
cocoa_joystick.m cocoa_monitor.m cocoa_window.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m
@ -137,13 +138,6 @@ target_include_directories(glfw PRIVATE
"${GLFW_BINARY_DIR}/src") "${GLFW_BINARY_DIR}/src")
target_link_libraries(glfw PRIVATE Threads::Threads) target_link_libraries(glfw PRIVATE Threads::Threads)
# Workaround for CMake not knowing about .m files before version 3.16
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m nsgl_context.m PROPERTIES
LANGUAGE C)
endif()
if (GLFW_BUILD_WIN32) if (GLFW_BUILD_WIN32)
list(APPEND glfw_PKG_LIBS "-lgdi32") list(APPEND glfw_PKG_LIBS "-lgdi32")
endif() endif()
@ -313,30 +307,34 @@ if (GLFW_BUILD_SHARED_LIBRARY)
if (MINGW) if (MINGW)
# Enable link-time exploit mitigation features enabled by default on MSVC # Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CMakePushCheckState)
# Compatibility with data execution prevention (DEP) # Compatibility with data execution prevention (DEP)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP) check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP) if (_GLFW_HAS_DEP)
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
endif() endif()
cmake_pop_check_state()
# Compatibility with address space layout randomization (ASLR) # Compatibility with address space layout randomization (ASLR)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR) check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR) if (_GLFW_HAS_ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
endif() endif()
cmake_pop_check_state()
# Compatibility with 64-bit address space layout randomization (ASLR) # Compatibility with 64-bit address space layout randomization (ASLR)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR) check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR) if (_GLFW_HAS_64ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
endif() endif()
cmake_pop_check_state()
# Clear flags again to avoid breaking later tests
set(CMAKE_REQUIRED_FLAGS)
endif() endif()
if (UNIX) if (UNIX)
@ -345,12 +343,8 @@ if (GLFW_BUILD_SHARED_LIBRARY)
endif() endif()
endif() endif()
foreach(arg ${glfw_PKG_DEPS}) list(JOIN glfw_PKG_DEPS " " deps)
string(APPEND deps " ${arg}") list(JOIN glfw_PKG_LIBS " " libs)
endforeach()
foreach(arg ${glfw_PKG_LIBS})
string(APPEND libs " ${arg}")
endforeach()
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
"GLFW pkg-config Requires.private") "GLFW pkg-config Requires.private")