Modernizes search for Cairo, Fontconfig, Freetype, HarfBuzz and Pixman

This commit is contained in:
Nimish Telang 2023-04-07 16:15:53 +00:00 committed by Seth Hillbrand
parent e91b53fc39
commit 9efd24a69d
7 changed files with 224 additions and 421 deletions

View File

@ -760,10 +760,8 @@ find_package( CURL REQUIRED )
# Find Cairo library, required # Find Cairo library, required
# #
find_package( Cairo 1.12 REQUIRED ) find_package( Cairo 1.12 REQUIRED )
include_directories( SYSTEM ${CAIRO_INCLUDE_DIR} )
find_package( Pixman 0.30 REQUIRED ) find_package( Pixman 0.30 REQUIRED )
include_directories( SYSTEM ${PIXMAN_INCLUDE_DIR} )
# #
# Find Boost headers and libraries, required. # Find Boost headers and libraries, required.
@ -784,10 +782,8 @@ set( FREETYPE_MIN_VERSION 2.11.1 )
endif() endif()
find_package( Freetype ${FREETYPE_MIN_VERSION} REQUIRED ) find_package( Freetype ${FREETYPE_MIN_VERSION} REQUIRED )
include_directories( SYSTEM ${FREETYPE_INCLUDE_DIRS} )
find_package( HarfBuzz REQUIRED ) find_package( HarfBuzz REQUIRED )
include_directories( SYSTEM ${HarfBuzz_INCLUDE_DIRS} )
find_package( Fontconfig REQUIRED ) find_package( Fontconfig REQUIRED )

View File

@ -1,16 +1,14 @@
# - Try to find the CAIRO library # - Try to find the Cairo library
# Once done this will define
#
# CAIRO_ROOT_DIR - Set this variable to the root installation of CAIRO
# #
# Read-Only variables: # Read-Only variables:
# CAIRO_FOUND - system has the CAIRO library # Cairo_FOUND - system has the Cairo library
# CAIRO_INCLUDE_DIR - the CAIRO include directory # Cairo_INCLUDE_DIR - the Cairo include directory
# CAIRO_LIBRARIES - The libraries needed to use CAIRO # Cairo_LIBRARIES - The libraries needed to use Cairo
# CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) # Cairo_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8)
#============================================================================= # =============================================================================
# Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru> # Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru>
# Copyright 2023 Nimish Telang <nimish@telang.net>
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
@ -18,149 +16,117 @@
# This software is distributed WITHOUT ANY WARRANTY; without even the # This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information. # See the License for more information.
#============================================================================= # =============================================================================
# (To distribute this file outside of CMake, substitute the full # (To distribute this file outside of CMake, substitute the full
# License text for the above reference.) # License text for the above reference.)
find_package(PkgConfig) find_package(PkgConfig)
cmake_policy(SET CMP0074 NEW)
if(PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_check_modules(_CAIRO cairo) message(CHECK_START "Looking for cairo using pkg-config")
endif (PKG_CONFIG_FOUND) pkg_check_modules(Cairo cairo IMPORTED_TARGET)
if (Cairo_FOUND)
message(CHECK_PASS "found by pkg-config")
else()
message(CHECK_FAIL "not found by pkg-config")
endif()
endif()
SET(_CAIRO_ROOT_HINTS message(CHECK_START "Searching for cairo library")
$ENV{CAIRO} FIND_LIBRARY(Cairo_LIBRARIES
${CAIRO_ROOT_DIR} cairo
)
SET(_CAIRO_ROOT_PATHS
$ENV{CAIRO}/src
/usr
/usr/local
)
SET(_CAIRO_ROOT_HINTS_AND_PATHS
HINTS ${_CAIRO_ROOT_HINTS}
PATHS ${_CAIRO_ROOT_PATHS}
)
FIND_PATH(CAIRO_INCLUDE_DIR
NAMES
cairo.h
HINTS
${_CAIRO_INCLUDEDIR}
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
include lib
"include/cairo" VC
lib/VC
lib/MINGW
) )
if (Cairo_LIBRARIES_FOUND)
message(CHECK_PASS "found ${Cairo_LIBRARIES}")
else()
message(CHECK_FAIL "not found")
endif()
IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN) message(CHECK_START "Searching for Cairo debug library")
# MINGW should go here too FIND_LIBRARY(Cairo_LIBRARIES_DEBUG
IF(MSVC) cairod
# Implementation details: PATH_SUFFIXES
# We are using the libraries located in the VC subdir instead of the parent directory eventhough : lib
FIND_LIBRARY(CAIRO_DEBUG VC
NAMES lib/VC
cairod lib/MINGW
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
FIND_LIBRARY(CAIRO_RELEASE )
NAMES if (Cairo_LIBRARIES_DEBUG_FOUND)
cairo message(CHECK_PASS "found ${Cairo_LIBRARIES_DEBUG}")
${_CAIRO_ROOT_HINTS_AND_PATHS} else()
PATH_SUFFIXES message(CHECK_FAIL "not found")
"lib" endif()
"VC"
"lib/VC"
)
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
if(NOT CAIRO_DEBUG)
set(CAIRO_DEBUG ${CAIRO_RELEASE})
endif(NOT CAIRO_DEBUG)
set( CAIRO_LIBRARIES
optimized ${CAIRO_RELEASE} debug ${CAIRO_DEBUG}
)
else()
set( CAIRO_LIBRARIES ${CAIRO_RELEASE})
endif()
MARK_AS_ADVANCED(CAIRO_DEBUG CAIRO_RELEASE)
ELSEIF(MINGW)
# same player, for MingW
FIND_LIBRARY(CAIRO
NAMES
cairo
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
)
MARK_AS_ADVANCED(CAIRO)
set( CAIRO_LIBRARIES ${CAIRO})
ELSE(MSVC)
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
FIND_LIBRARY(CAIRO
NAMES
cairo
HINTS
${_CAIRO_LIBDIR}
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
MARK_AS_ADVANCED(CAIRO) message(CHECK_START "Looking for cairo include dirs")
set( CAIRO_LIBRARIES ${CAIRO} ) find_path(Cairo_INCLUDE_DIRS
ENDIF(MSVC) cairo-version.h
ELSE() PATH_SUFFIXES
cairo
FIND_LIBRARY(CAIRO_LIBRARY include/cairo
NAMES )
cairo if(Cairo_INCLUDE_DIRS)
HINTS message(CHECK_PASS "Found: ${Cairo_INCLUDE_DIRS}")
${_CAIRO_LIBDIR} message(CHECK_START "Extracting Cairo version")
${_CAIRO_ROOT_HINTS_AND_PATHS} find_file(Cairo_VERSION_H cairo-version.h HINTS ${Cairo_INCLUDE_DIRS})
PATH_SUFFIXES if(Cairo_VERSION_H_FOUND)
"lib" file(READ "${Cairo_VERSION_H}" _Cairo_VERSION_H_CONTENTS)
"local/lib" string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*"
) "\\2" Cairo_VERSION_MAJOR ${_Cairo_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*"
MARK_AS_ADVANCED(CAIRO_LIBRARY) "\\2" Cairo_VERSION_MINOR ${_Cairo_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*"
# compat defines "\\2" Cairo_VERSION_MICRO ${_Cairo_VERSION_H_CONTENTS})
SET(CAIRO_LIBRARIES ${CAIRO_LIBRARY}) set(Cairo_VERSION ${Cairo_VERSION_MAJOR}.${Cairo_VERSION_MINOR}.${Cairo_VERSION_MICRO}
ENDIF()
#message( STATUS "Cairo_FIND_VERSION=${Cairo_FIND_VERSION}.")
#message( STATUS "CAIRO_INCLUDE_DIR=${CAIRO_INCLUDE_DIR}.")
# Fetch version from cairo-version.h if a version was requested by find_package()
if(CAIRO_INCLUDE_DIR AND Cairo_FIND_VERSION)
file(READ "${CAIRO_INCLUDE_DIR}/cairo-version.h" _CAIRO_VERSION_H_CONTENTS)
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*"
"\\2" CAIRO_VERSION_MAJOR ${_CAIRO_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*"
"\\2" CAIRO_VERSION_MINOR ${_CAIRO_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*"
"\\2" CAIRO_VERSION_MICRO ${_CAIRO_VERSION_H_CONTENTS})
set(CAIRO_VERSION ${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}
CACHE INTERNAL "The version number for Cairo libraries") CACHE INTERNAL "The version number for Cairo libraries")
endif()
if (Cairo_VERSION)
message(CHECK_PASS "found Cairo version ${Cairo_VERSION}")
else()
message(CHECK_FAIL "failed")
endif()
else()
message(CHECK_FAIL "none found")
endif() endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cairo find_package_handle_standard_args(Cairo
REQUIRED_VARS REQUIRED_VARS
CAIRO_LIBRARIES Cairo_LIBRARIES
CAIRO_INCLUDE_DIR Cairo_INCLUDE_DIRS
VERSION_VAR VERSION_VAR
CAIRO_VERSION Cairo_VERSION
HANDLE_VERSION_RANGE
) )
MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES) MARK_AS_ADVANCED(Cairo_INCLUDE_DIRS Cairo_LIBRARIES)
if(Cairo_FOUND AND NOT TARGET Cairo::Cairo)
if(TARGET PkgConfig::Cairo)
add_library(Cairo::Cairo ALIAS PkgConfig::Cairo)
else()
add_library(Cairo::Cairo IMPORTED SHARED)
target_include_directories(Cairo::Cairo INTERFACE ${Cairo_INCLUDE_DIRS})
target_link_libraries(Cairo::Cairo INTERFACE ${Cairo_LIBRARIES})
set_target_properties(Cairo::Cairo PROPERTIES
IMPORTED_LOCATION ${Cairo_LIBRARIES}
)
if (Cairo_DEBUG_LIBRARIES_FOUND)
set_target_properties(Cairo::Cairo PROPERTIES
IMPORTED_LOCATION_DEBUG ${Cairo_LIBRARIES_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${Cairo_LIBRARIES_DEBUG}
)
endif()
endif()
endif()

View File

@ -1,103 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindFontconfig
--------------
.. versionadded:: 3.14
Find Fontconfig headers and library.
Imported Targets
^^^^^^^^^^^^^^^^
``Fontconfig::Fontconfig``
The Fontconfig library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables in your project:
``Fontconfig_FOUND``
true if (the requested version of) Fontconfig is available.
``Fontconfig_VERSION``
the version of Fontconfig.
``Fontconfig_LIBRARIES``
the libraries to link against to use Fontconfig.
``Fontconfig_INCLUDE_DIRS``
where to find the Fontconfig headers.
``Fontconfig_COMPILE_OPTIONS``
this should be passed to target_compile_options(), if the
target is not used for linking
#]=======================================================================]
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig QUIET)
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
set(Fontconfig_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
set(Fontconfig_VERSION ${PKG_FONTCONFIG_VERSION})
find_path( Fontconfig_INCLUDE_DIR
NAMES
fontconfig/fontconfig.h
HINTS
${PKG_FONTCONFIG_INCLUDE_DIRS}
/usr/X11/include
)
find_library( Fontconfig_LIBRARY
NAMES
fontconfig
PATHS
${PKG_FONTCONFIG_LIBRARY_DIRS}
)
if (Fontconfig_INCLUDE_DIR AND NOT Fontconfig_VERSION)
file(STRINGS ${Fontconfig_INCLUDE_DIR}/fontconfig/fontconfig.h _contents REGEX "^#define[ \t]+FC_[A-Z]+[ \t]+[0-9]+$")
unset(Fontconfig_VERSION)
foreach(VPART MAJOR MINOR REVISION)
foreach(VLINE ${_contents})
if(VLINE MATCHES "^#define[\t ]+FC_${VPART}[\t ]+([0-9]+)$")
set(Fontconfig_VERSION_PART "${CMAKE_MATCH_1}")
if(Fontconfig_VERSION)
string(APPEND Fontconfig_VERSION ".${Fontconfig_VERSION_PART}")
else()
set(Fontconfig_VERSION "${Fontconfig_VERSION_PART}")
endif()
endif()
endforeach()
endforeach()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fontconfig
FOUND_VAR
Fontconfig_FOUND
REQUIRED_VARS
Fontconfig_LIBRARY
Fontconfig_INCLUDE_DIR
VERSION_VAR
Fontconfig_VERSION
)
if(Fontconfig_FOUND AND NOT TARGET Fontconfig::Fontconfig)
add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
set_target_properties(Fontconfig::Fontconfig PROPERTIES
IMPORTED_LOCATION "${Fontconfig_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Fontconfig_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${Fontconfig_INCLUDE_DIR}"
)
endif()
mark_as_advanced(Fontconfig_LIBRARY Fontconfig_INCLUDE_DIR)
if(Fontconfig_FOUND)
set(Fontconfig_LIBRARIES ${Fontconfig_LIBRARY})
set(Fontconfig_INCLUDE_DIRS ${Fontconfig_INCLUDE_DIR})
endif()

View File

@ -1,5 +1,6 @@
# Copyright (c) 2012, Intel Corporation # Copyright (c) 2012, Intel Corporation
# Copyright (c) 2019 Sony Interactive Entertainment Inc. # Copyright (c) 2019 Sony Interactive Entertainment Inc.
# Copyright (c) 2023 Kicad Contributors
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -64,9 +65,10 @@ This will define the following variables in your project:
target is not used for linking target is not used for linking
#]=======================================================================] #]=======================================================================]
cmake_policy(SET CMP0074 NEW)
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz) pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz IMPORTED_TARGET)
set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER}) set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER})
set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION}) set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION})
@ -90,21 +92,18 @@ if (HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION)
endif () endif ()
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 # Find components
if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY) message(CHECK_START "Searching for harfbuzz")
set(_HarfBuzz_REQUIRED_LIBS_FOUND ON) if (HarfBuzz_LIBRARY)
set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}") message(CHECK_PASS "found at ${HarfBuzz_LIBRARY}")
else () else ()
set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) message(CHECK_FAIL "not found")
set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)")
endif () endif ()
if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu) message(CHECK_START "searching for harfbuzz-icu")
pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu IMPORTED_TARGET)
set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER}) set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER})
find_path(HarfBuzz_ICU_INCLUDE_DIR find_path(HarfBuzz_ICU_INCLUDE_DIR
@ -119,59 +118,47 @@ if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
) )
if (HarfBuzz_ICU_LIBRARY) if (HarfBuzz_ICU_LIBRARY)
if (HarfBuzz_FIND_REQUIRED_ICU) set(HarfBuzz_ICU_FOUND true)
list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}") message(CHECK_PASS "found at ${HarfBuzz_ICU_LIBRARY}")
else ()
list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}")
endif ()
else () else ()
if (HarfBuzz_FIND_REQUIRED_ICU) message(CHECK_FAIL "not found")
set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF)
list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (required)")
else ()
list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (optional)")
endif ()
endif () endif ()
endif () endif ()
if (NOT HarfBuzz_FIND_QUIETLY)
if (HarfBuzz_LIBS_FOUND)
message(STATUS "Found the following HarfBuzz libraries:")
foreach (found ${HarfBuzz_LIBS_FOUND})
message(STATUS " ${found}")
endforeach ()
endif ()
if (HarfBuzz_LIBS_NOT_FOUND)
message(STATUS "The following HarfBuzz libraries were not found:")
foreach (found ${HarfBuzz_LIBS_NOT_FOUND})
message(STATUS " ${found}")
endforeach ()
endif ()
endif ()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HarfBuzz find_package_handle_standard_args(HarfBuzz
FOUND_VAR HarfBuzz_FOUND FOUND_VAR HarfBuzz_FOUND
REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY
VERSION_VAR HarfBuzz_VERSION VERSION_VAR HarfBuzz_VERSION
HANDLE_COMPONENTS
HANDLE_VERSION_RANGE
) )
if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz) if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz)
add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) if (TARGET PkgConfig::PC_HARFBUZZ)
set_target_properties(HarfBuzz::HarfBuzz PROPERTIES add_library(HarfBuzz::HarfBuzz ALIAS PkgConfig::PC_HARFBUZZ)
IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" else()
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL)
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" set_target_properties(HarfBuzz::HarfBuzz PROPERTIES
) IMPORTED_LOCATION "${HarfBuzz_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}"
)
endif()
endif () endif ()
if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU) if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU)
add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) if (TARGET PkgConfig::PC_HARFBUZZ)
set_target_properties(HarfBuzz::ICU PROPERTIES add_library(HarfBuzz::ICU ALIAS PkgConfig::PC_HARFBUZZ_ICU)
IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}" else()
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}" add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL)
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}" set_target_properties(HarfBuzz::ICU PROPERTIES
) IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}"
)
endif()
endif () endif ()
mark_as_advanced( mark_as_advanced(
@ -184,4 +171,4 @@ mark_as_advanced(
if (HarfBuzz_FOUND) if (HarfBuzz_FOUND)
set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY}) set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY})
set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR}) set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR})
endif () endif ()

View File

@ -1,148 +1,109 @@
# - Try to find the PIXMAN library # - Try to find the Pixman library
# Once done this will define
#
# PIXMAN_ROOT_DIR - Set this variable to the root installation of PIXMAN
# #
# Read-Only variables: # Read-Only variables:
# PIXMAN_FOUND - system has the PIXMAN library # Pixman_FOUND - system has the Pixman library
# PIXMAN_INCLUDE_DIR - the PIXMAN include directory # Pixman_INCLUDE_DIR - the Pixman include directory
# PIXMAN_LIBRARIES - The libraries needed to use PIXMAN # Pixman_LIBRARIES - The libraries needed to use Pixman
# PIXMAN_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) # Pixman_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8)
#============================================================================= # =============================================================================
# Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru> # Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru>
# Copyright 2017 Simon Richter <Simon.Richter at hogyros dot de> # Copyright 2017 Simon Richter <Simon.Richter at hogyros dot de>
# # Copyright 2023 Nimish Telang <nimish@telang.net>
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
# #
# This software is distributed WITHOUT ANY WARRANTY; without even the # This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information. # See the License for more information.
#============================================================================= # =============================================================================
# (To distribute this file outside of CMake, substitute the full # (To distribute this file outside of CMake, substitute the full
# License text for the above reference.) # License text for the above reference.)
find_package(PkgConfig) find_package(PkgConfig)
cmake_policy(SET CMP0074 NEW)
if(PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_check_modules(_PIXMAN pixman-1) message(CHECK_START "Looking for pixman using pkg-config")
endif (PKG_CONFIG_FOUND) pkg_check_modules(Pixman pixman-1 IMPORTED_TARGET)
if (Pixman_FOUND)
message(CHECK_PASS "found by pkg-config")
else()
message(CHECK_FAIL "not found by pkg-config")
endif()
endif()
SET(_PIXMAN_ROOT_HINTS message(CHECK_START "Searching for pixman library")
$ENV{PIXMAN} FIND_LIBRARY(Pixman_LIBRARIES
${PIXMAN_ROOT_DIR} pixman
) pixman-1
SET(_PIXMAN_ROOT_PATHS pixman-1.0
$ENV{PIXMAN}/src
/usr
/usr/local
)
SET(_PIXMAN_ROOT_HINTS_AND_PATHS
HINTS ${_PIXMAN_ROOT_HINTS}
PATHS ${_PIXMAN_ROOT_PATHS}
)
FIND_PATH(PIXMAN_INCLUDE_DIR
NAMES
pixman.h
HINTS
${_PIXMAN_INCLUDEDIR}
${_PIXMAN_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
include lib
"include/pixman-1" VC
lib/VC
) )
if (Pixman_LIBRARIES_FOUND)
message(CHECK_PASS "found ${Pixman_LIBRARIES}")
else()
message(CHECK_FAIL "not found")
endif()
IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN) message(CHECK_START "Looking for pixman include dirs")
# MINGW should go here too find_path(Pixman_INCLUDE_DIRS
IF(MSVC) pixman-version.h
# Implementation details: PATH_SUFFIXES
# We are using the libraries located in the VC subdir instead of the parent directory eventhough : include
FIND_LIBRARY(PIXMAN include/pixman-1
NAMES )
pixman-1 if(Pixman_INCLUDE_DIRS)
${_PIXMAN_ROOT_HINTS_AND_PATHS} message(CHECK_PASS "Found: ${Pixman_INCLUDE_DIRS}")
PATH_SUFFIXES message(CHECK_START "Extracting Pixman version")
"lib" find_file(Pixman_VERSION_H pixman-version.h HINTS ${Pixman_INCLUDE_DIRS})
"VC" if(Pixman_VERSION_H_FOUND)
"lib/VC" file(READ "${Pixman_VERSION_H}" _Pixman_VERSION_H_CONTENTS)
) string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*"
"\\2" Pixman_VERSION_MAJOR ${_Pixman_VERSION_H_CONTENTS})
MARK_AS_ADVANCED(PIXMAN) string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*"
set( PIXMAN_LIBRARIES ${PIXMAN}) "\\2" Pixman_VERSION_MINOR ${_Pixman_VERSION_H_CONTENTS})
ELSEIF(MINGW) string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*"
# same player, for MingW "\\2" Pixman_VERSION_MICRO ${_Pixman_VERSION_H_CONTENTS})
FIND_LIBRARY(PIXMAN set(Pixman_VERSION ${Pixman_VERSION_MAJOR}.${Pixman_VERSION_MINOR}.${Pixman_VERSION_MICRO}
NAMES
pixman-1
${_PIXMAN_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
)
MARK_AS_ADVANCED(PIXMAN)
set( PIXMAN_LIBRARIES ${PIXMAN})
ELSE(MSVC)
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
FIND_LIBRARY(PIXMAN
NAMES
pixman-1
HINTS
${_PIXMAN_LIBDIR}
${_PIXMAN_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
MARK_AS_ADVANCED(PIXMAN)
set( PIXMAN_LIBRARIES ${PIXMAN} )
ENDIF(MSVC)
ELSE()
FIND_LIBRARY(PIXMAN_LIBRARY
NAMES
pixman-1
HINTS
${_PIXMAN_LIBDIR}
${_PIXMAN_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"local/lib"
)
MARK_AS_ADVANCED(PIXMAN_LIBRARY)
# compat defines
SET(PIXMAN_LIBRARIES ${PIXMAN_LIBRARY})
ENDIF()
#message( STATUS "Pixman_FIND_VERSION=${Pixman_FIND_VERSION}.")
#message( STATUS "PIXMAN_INCLUDE_DIR=${PIXMAN_INCLUDE_DIR}.")
# Fetch version from pixman-version.h if a version was requested by find_package()
if(PIXMAN_INCLUDE_DIR AND Pixman_FIND_VERSION)
file(READ "${PIXMAN_INCLUDE_DIR}/pixman-version.h" _PIXMAN_VERSION_H_CONTENTS)
string(REGEX REPLACE "^(.*\n)?#define[ \t]+PIXMAN_VERSION_MAJOR[ \t]+([0-9]+).*"
"\\2" PIXMAN_VERSION_MAJOR ${_PIXMAN_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+PIXMAN_VERSION_MINOR[ \t]+([0-9]+).*"
"\\2" PIXMAN_VERSION_MINOR ${_PIXMAN_VERSION_H_CONTENTS})
string(REGEX REPLACE "^(.*\n)?#define[ \t]+PIXMAN_VERSION_MICRO[ \t]+([0-9]+).*"
"\\2" PIXMAN_VERSION_MICRO ${_PIXMAN_VERSION_H_CONTENTS})
set(PIXMAN_VERSION ${PIXMAN_VERSION_MAJOR}.${PIXMAN_VERSION_MINOR}.${PIXMAN_VERSION_MICRO}
CACHE INTERNAL "The version number for Pixman libraries") CACHE INTERNAL "The version number for Pixman libraries")
endif()
if (Pixman_VERSION)
message(CHECK_PASS "found Pixman version ${Pixman_VERSION}")
else()
message(CHECK_FAIL "failed")
endif()
else()
message(CHECK_FAIL "none found")
endif() endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Pixman find_package_handle_standard_args(Pixman
REQUIRED_VARS REQUIRED_VARS
PIXMAN_LIBRARIES Pixman_LIBRARIES
PIXMAN_INCLUDE_DIR Pixman_INCLUDE_DIRS
VERSION_VAR VERSION_VAR
PIXMAN_VERSION Pixman_VERSION
HANDLE_VERSION_RANGE
) )
MARK_AS_ADVANCED(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARIES) MARK_AS_ADVANCED(Pixman_INCLUDE_DIRS Pixman_LIBRARIES)
if(Pixman_FOUND AND NOT TARGET Pixman::Pixman)
if(TARGET PkgConfig::Pixman)
add_library(Pixman::Pixman ALIAS PkgConfig::Pixman)
else()
add_library(Pixman::Pixman IMPORTED SHARED)
target_include_directories(Pixman::Pixman INTERFACE ${Pixman_INCLUDE_DIRS})
target_link_libraries(Pixman::Pixman INTERFACE ${Pixman_LIBRARIES})
set_target_properties(Pixman::Pixman PROPERTIES
IMPORTED_LOCATION ${Pixman_LIBRARIES}
)
endif()
endif()

View File

@ -499,9 +499,9 @@ target_link_libraries( common
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
${EXTRA_LIBS} ${EXTRA_LIBS}
# outline font support # outline font support
${FREETYPE_LIBRARIES} Freetype::Freetype
${HarfBuzz_LIBRARIES} HarfBuzz::HarfBuzz
${Fontconfig_LIBRARIES} Fontconfig::Fontconfig
) )
if( KICAD_USE_SENTRY ) if( KICAD_USE_SENTRY )

View File

@ -44,24 +44,20 @@ set( GAL_SRCS
add_library( gal STATIC ${GAL_SRCS} ) add_library( gal STATIC ${GAL_SRCS} )
if( WIN32 )
# we need the gdiplus library for cairo printing on windows
set( GDI_PLUS_LIBRARIES gdiplus )
endif()
target_link_libraries( gal target_link_libraries( gal
common # This is needed until the circular dependency is removed common # This is needed until the circular dependency is removed
kimath kimath
nlohmann_json nlohmann_json
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${CAIRO_LIBRARIES} Cairo::Cairo
${PIXMAN_LIBRARIES} Pixman::Pixman
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${GDI_PLUS_LIBRARIES} "$<$<PLATFORM_ID:Windows>:gdiplus>" # required for Cairo printing
# outline font support # outline font support
${FREETYPE_LIBRARIES} Freetype::Freetype
${HarfBuzz_LIBRARIES} HarfBuzz::HarfBuzz
${Fontconfig_LIBRARIES} Fontconfig::Fontconfig
) )
function( add_shader outTarget inFile shaderName ) function( add_shader outTarget inFile shaderName )
set(outCppName "${shaderName}.cpp") set(outCppName "${shaderName}.cpp")
@ -95,4 +91,4 @@ add_shader( gal smaa_pass_1_vert.glsl glsl_smaa_pass_1_vert )
add_shader( gal smaa_pass_2_frag.glsl glsl_smaa_pass_2_frag ) add_shader( gal smaa_pass_2_frag.glsl glsl_smaa_pass_2_frag )
add_shader( gal smaa_pass_2_vert.glsl glsl_smaa_pass_2_vert ) add_shader( gal smaa_pass_2_vert.glsl glsl_smaa_pass_2_vert )
add_shader( gal smaa_pass_3_frag.glsl glsl_smaa_pass_3_frag ) add_shader( gal smaa_pass_3_frag.glsl glsl_smaa_pass_3_frag )
add_shader( gal smaa_pass_3_vert.glsl glsl_smaa_pass_3_vert ) add_shader( gal smaa_pass_3_vert.glsl glsl_smaa_pass_3_vert )