mirror of
https://github.com/glfw/glfw.git
synced 2025-06-15 20:22:15 +00:00
Created a more generalized helper module
I think this will help glfw's cmake build system be more readable and adaptable to changes to cmake.
This commit is contained in:
parent
5f2d8fb9a4
commit
8ab920ea67
@ -1,7 +1,13 @@
|
||||
if (DEFINED glfw_msvc_runtime_library_include_guard)
|
||||
# This cmake module is meant to hold helper functions/macros
|
||||
# that make maintaining the cmake build system much easier.
|
||||
# This is especially helpful since glfw needs to provide coverage
|
||||
# for multiple versions of cmake.
|
||||
#
|
||||
# Any functions/macros should have a glfw_* prefix to avoid problems
|
||||
if (DEFINED glfw_include_guard)
|
||||
return()
|
||||
endif()
|
||||
set(glfw_msvc_runtime_library_include_guard ON)
|
||||
set(glfw_include_guard ON)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
@ -53,3 +59,25 @@ macro(glfw_msvc_runtime_library GLFW_STANDALONE)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Despite the fact that glfw is using a range to cover newer projects
|
||||
# cmake_minimum_required(VERSION 3.1...3.X FATAL_ERROR)
|
||||
# This still doesn't cover all cmake versions since this range functionality was only added
|
||||
# in cmake 3.12, so explicitly setting these policies allow for more projects to work properly
|
||||
# in between cmake 3.1 -> 3.11
|
||||
macro(glfw_set_new_policies)
|
||||
if (${CMAKE_VERSION} VERSION_LESS "3.12")
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0069)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
@ -1,22 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Cmake/")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/modules")
|
||||
include(glfw)
|
||||
|
||||
project(GLFW VERSION 3.4.0 LANGUAGES C)
|
||||
|
||||
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
|
||||
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0069)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
glfw_set_new_policies()
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
@ -33,7 +25,6 @@ option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the applicati
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakeDependentOption)
|
||||
include(glfw_msvc_runtime_library)
|
||||
|
||||
cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
|
||||
"UNIX" OFF)
|
||||
@ -60,8 +51,6 @@ if (GLFW_VULKAN_STATIC)
|
||||
set(_GLFW_VULKAN_STATIC 1)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if (GLFW_BUILD_DOCS)
|
||||
|
Loading…
Reference in New Issue
Block a user