Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: simplify handling of version numbers #1006

Open
wants to merge 4 commits into
base: wpe-2.38
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.12)
project(WebKit)

# Remove this cmake_policy() after upgrading cmake_minimum_required() to 3.20.
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
if (POLICY CMP0116)
cmake_policy(SET CMP0116 OLD)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion Source/cmake/BubblewrapSandboxChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (ENABLE_BUBBLEWRAP_SANDBOX)
message(FATAL_ERROR "Failed to run ${BWRAP_EXECUTABLE}")
endif ()
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" BWRAP_VERSION "${BWRAP_OUTPUT}")
if (NOT "${BWRAP_VERSION}" VERSION_GREATER_EQUAL "0.3.1")
if (BWRAP_VERSION VERSION_LESS "0.3.1")
message(FATAL_ERROR "bwrap must be >= 0.3.1 but ${BWRAP_VERSION} found")
endif ()
elseif (NOT SILENCE_CROSS_COMPILATION_NOTICES)
Expand Down
17 changes: 6 additions & 11 deletions Source/cmake/FindATSPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ find_package(PkgConfig QUIET)

pkg_check_modules(ATSPI atspi-2)

set(VERSION_OK TRUE)
if (ATSPI_VERSION)
if (ATSPI_FIND_VERSION_EXACT)
if (NOT("${ATSPI_FIND_VERSION}" VERSION_EQUAL "${ATSPI_VERSION}"))
set(VERSION_OK FALSE)
endif ()
else ()
if ("${ATSPI_VERSION}" VERSION_LESS "${ATSPI_FIND_VERSION}")
set(VERSION_OK FALSE)
endif ()
endif ()
set(ATSPI_VERSION_ARGUMENT "VERSION_VAR ATSPI_VERSION")
endif ()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ATSPI DEFAULT_MSG ATSPI_INCLUDE_DIRS ATSPI_LIBRARIES VERSION_OK)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ATSPI
REQUIRED_VARS ATSPI_INCLUDE_DIRS ATSPI_LIBRARIES
${ATSPI_VERSION_ARGUMENT})

unset(ATSPI_VERSION_ARGUMENT)
2 changes: 2 additions & 0 deletions Source/cmake/FindGLIB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ if (EXISTS "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h")
string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}")
set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}")
else ()
set(GLIB_VERSION "${PC_GLIB_VERSION}")
endif ()

# Additional Glib components. We only look for libraries, as not all of them
Expand Down
17 changes: 3 additions & 14 deletions Source/cmake/FindGTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@ endif ()
find_package(PkgConfig QUIET)
pkg_check_modules(GTK IMPORTED_TARGET ${GTK_PC_MODULE})

set(GTK_VERSION_OK TRUE)
if (GTK_VERSION)
if (GTK_FIND_VERSION_EXACT)
if (NOT("${GTK_FIND_VERSION}" VERSION_EQUAL "${GTK_VERSION}"))
set(GTK_VERSION_OK FALSE)
endif ()
else ()
if ("${GTK_VERSION}" VERSION_LESS "${GTK_FIND_VERSION}")
set(GTK_VERSION_OK FALSE)
endif ()
endif ()
endif ()

# Set all the GTK_SUPPORTS_<target> variables to FALSE initially.
foreach (gtk_target broadway quartz wayland win32 x11)
string(TOUPPER "GTK_SUPPORTS_${gtk_target}" gtk_target)
Expand Down Expand Up @@ -147,4 +134,6 @@ foreach (gtk_component ${GTK_FIND_COMPONENTS})
endforeach ()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK DEFAULT_MSG GTK_VERSION GTK_VERSION_OK)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK
REQUIRED_VARS GTK_VERSION GTK_VERSION_OK
VERSION_VAR GTK_VERSION)
4 changes: 0 additions & 4 deletions Source/cmake/FindHarfBuzz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ if (HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION)
endif ()
endif ()

if ("${HarfBuzz_FIND_VERSION}" VERSION_GREATER "${HarfBuzz_VERSION}")
message(FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} ") is higher than found version (" ${HarfBuzz_VERSION} ")")
endif ()

# Find components
if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY)
set(_HarfBuzz_REQUIRED_LIBS_FOUND ON)
Expand Down
18 changes: 6 additions & 12 deletions Source/cmake/FindLibsecret.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@
find_package(PkgConfig QUIET)
pkg_check_modules(LIBSECRET libsecret-1)

set(VERSION_OK TRUE)
if (LIBSECRET_VERSION)
if (LIBSECRET_FIND_VERSION_EXACT)
if (NOT("${LIBSECRET_FIND_VERSION}" VERSION_EQUAL "${LIBSECRET_VERSION}"))
set(VERSION_OK FALSE)
endif ()
else ()
if ("${LIBSECRET_VERSION}" VERSION_LESS "${LIBSECRET_FIND_VERSION}")
set(VERSION_OK FALSE)
endif ()
endif ()
set(LIBSECRET_VERSION_ARG "VERSION_VAR LIBSECRET_VERSION")
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libsecret REQUIRED_VARS LIBSECRET_INCLUDE_DIRS LIBSECRET_LIBRARIES VERSION_OK
FOUND_VAR LIBSECRET_FOUND)
find_package_handle_standard_args(Libsecret REQUIRED_VARS LIBSECRET_INCLUDE_DIRS LIBSECRET_LIBRARIES
FOUND_VAR LIBSECRET_FOUND
${LIBSECRET_VERSION_ARG})

unset(LIBSECRET_VERSION_ARG)
11 changes: 0 additions & 11 deletions Source/cmake/FindWOFF2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ find_library(WOFF2_LIBRARY
HINTS ${PC_WOFF2_LIBDIR} ${PC_WOFF2_LIBRARY_DIRS}
)

# There's nothing in the WOFF2 headers that could be used to detect the exact
# WOFF2 version being used so don't attempt to do so. A version can only be found
# through pkg-config
if ("${WOFF2_FIND_VERSION}" VERSION_GREATER "${WOFF2_VERSION}")
if (WOFF2_VERSION)
message(FATAL_ERROR "Required version (" ${WOFF2_FIND_VERSION} ") is higher than found version (" ${WOFF2_VERSION} ")")
else ()
message(WARNING "Cannot determine WOFF2 version without pkg-config")
endif ()
endif ()

# Find components
if (WOFF2_LIBRARY)
set(_WOFF2_REQUIRED_LIBS_FOUND ON)
Expand Down
11 changes: 0 additions & 11 deletions Source/cmake/FindWebP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ find_library(WebP_LIBRARY
HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
)

# There's nothing in the WebP headers that could be used to detect the exact
# WebP version being used so don't attempt to do so. A version can only be found
# through pkg-config
if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}")
if (WebP_VERSION)
message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${WebP_VERSION} ")")
else ()
message(WARNING "Cannot determine WebP version without pkg-config")
endif ()
endif ()

# Find components
if (WebP_INCLUDE_DIR AND WebP_LIBRARY)
set(_WebP_REQUIRED_LIBS_FOUND ON)
Expand Down
14 changes: 7 additions & 7 deletions Source/cmake/OptionsGTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SET_PROJECT_VERSION(2 38 3)

# This is required because we use the DEPFILE argument to add_custom_command().
# Remove after upgrading cmake_minimum_required() to 3.20.
if (${CMAKE_VERSION} VERSION_LESS "3.20" AND NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
if (CMAKE_VERSION VERSION_LESS "3.20" AND NOT CMAKE_GENERATOR STREQUAL "Ninja")
message(FATAL_ERROR "Building with Makefiles requires CMake 3.20 or newer. Either enable Ninja by passing -GNinja, or upgrade CMake.")
endif ()

Expand Down Expand Up @@ -44,7 +44,7 @@ endif ()

# For old versions of HarfBuzz that do not expose an API for the OpenType MATH
# table, we enable our own code to parse that table.
if ("${PC_HARFBUZZ_VERSION}" VERSION_LESS "1.3.3")
if (HarfBuzz_VERSION VERSION_LESS "1.3.3")
add_definitions(-DENABLE_OPENTYPE_MATH=1)
endif ()

Expand Down Expand Up @@ -108,10 +108,10 @@ else ()
endif ()

# Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
if (("${PC_CAIRO_VERSION}" VERSION_GREATER "1.16.0" OR "${PC_CAIRO_VERSION}" STREQUAL "1.16.0")
AND ("${PC_FONTCONFIG_VERSION}" VERSION_GREATER "2.13.0" OR "${PC_FONTCONFIG_VERSION}" STREQUAL "2.13.0")
AND ("${FREETYPE_VERSION_STRING}" VERSION_GREATER "2.9.0" OR "${FREETYPE_VERSION_STRING}" STREQUAL "2.9.0")
AND ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "1.4.2" OR "${PC_HARFBUZZ_VERSION}" STREQUAL "1.4.2"))
if ((CAIRO_VERSION VERSION_GREATER_EQUAL "1.16.0")
AND (Fontconfig_VERSION VERSION_GREATER_EQUAL "2.13.0")
AND (FREETYPE_VERSION_STRING VERSION_GREATER_EQUAL "2.9.0")
AND (HarfBuzz_VERSION VERSION_GREATER_EQUAL "1.4.2"))
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE ON)
endif ()

Expand Down Expand Up @@ -282,7 +282,7 @@ if (ENABLED_COMPILER_SANITIZERS)
endif ()

# GUri is available in GLib since version 2.66, but we only want to use it if version is >= 2.67.1.
if (PC_GLIB_VERSION VERSION_GREATER "2.67.1" OR PC_GLIB_VERSION STREQUAL "2.67.1")
if (GLIB_VERSION VERSION_GREATER_EQUAL "2.67.1")
SET_AND_EXPOSE_TO_BUILD(HAVE_GURI 1)
endif ()

Expand Down
12 changes: 6 additions & 6 deletions Source/cmake/OptionsWPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SET_PROJECT_VERSION(2 38 3)

# This is required because we use the DEPFILE argument to add_custom_command().
# Remove after upgrading cmake_minimum_required() to 3.20.
if (${CMAKE_VERSION} VERSION_LESS "3.20" AND NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
if (CMAKE_VERSION VERSION_LESS "3.20" AND NOT CMAKE_GENERATOR STREQUAL "Ninja")
message(FATAL_ERROR "Building with Makefiles requires CMake 3.20 or newer. Either enable Ninja by passing -GNinja, or upgrade CMake.")
endif ()

Expand Down Expand Up @@ -127,10 +127,10 @@ if (ENABLE_DEVELOPER_MODE)
endif ()

# Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
if (("${PC_CAIRO_VERSION}" VERSION_GREATER "1.16.0" OR "${PC_CAIRO_VERSION}" STREQUAL "1.16.0")
AND ("${PC_FONTCONFIG_VERSION}" VERSION_GREATER "2.13.0" OR "${PC_FONTCONFIG_VERSION}" STREQUAL "2.13.0")
AND ("${FREETYPE_VERSION_STRING}" VERSION_GREATER "2.9.0" OR "${FREETYPE_VERSION_STRING}" STREQUAL "2.9.0")
AND ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "1.4.2" OR "${PC_HARFBUZZ_VERSION}" STREQUAL "1.4.2"))
if ((CAIRO_VERSION VERSION_GREATER_EQUAL "1.16.0")
AND (Fontconfig_VERSION VERSION_GREATER_EQUAL "2.13.0")
AND (FREETYPE_VERSION_STRING VERSION_GREATER_EQUAL "2.9.0")
AND (HarfBuzz_VERSION VERSION_GREATER_EQUAL "1.4.2"))
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE ON)
endif ()

Expand Down Expand Up @@ -346,7 +346,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)

# GUri is available in GLib since version 2.66, but we only want to use it if version is >= 2.67.1.
if (PC_GLIB_VERSION VERSION_GREATER "2.67.1" OR PC_GLIB_VERSION STREQUAL "2.67.1")
if (GLIB_VERSION VERSION_GREATER_EQUAL "2.67.1")
SET_AND_EXPOSE_TO_BUILD(HAVE_GURI 1)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion Source/cmake/WebKitCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
endif ()

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "8.3.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.3.0")
message(FATAL_ERROR "GCC 8.3 or newer is required to build WebKit. Use a newer GCC version or Clang.")
endif ()
endif ()
Expand Down