mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 13:32:01 +00:00
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
This commit is contained in:
parent
043378876a
commit
b850107a32
@ -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)
|
||||||
|
@ -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,24 +72,7 @@ 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()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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()
|
||||||
@ -349,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")
|
||||||
|
Loading…
Reference in New Issue
Block a user