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

This reverts commit 9efd24a69d.

Breaks MSW builds, so this is a non-starter for now
This commit is contained in:
Seth Hillbrand 2023-04-07 10:12:43 -07:00
parent 2cd854af14
commit 5fcc1135a8
7 changed files with 421 additions and 224 deletions

View File

@ -751,8 +751,10 @@ 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.
@ -773,8 +775,10 @@ 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,14 +1,16 @@
# - 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.
@ -16,117 +18,149 @@
# 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)
message(CHECK_START "Looking for cairo using pkg-config") pkg_check_modules(_CAIRO cairo)
pkg_check_modules(Cairo cairo IMPORTED_TARGET) endif (PKG_CONFIG_FOUND)
if (Cairo_FOUND)
message(CHECK_PASS "found by pkg-config")
else()
message(CHECK_FAIL "not found by pkg-config")
endif()
endif()
message(CHECK_START "Searching for cairo library") SET(_CAIRO_ROOT_HINTS
FIND_LIBRARY(Cairo_LIBRARIES $ENV{CAIRO}
cairo ${CAIRO_ROOT_DIR}
)
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
lib include
VC "include/cairo"
lib/VC
lib/MINGW
) )
if (Cairo_LIBRARIES_FOUND)
message(CHECK_PASS "found ${Cairo_LIBRARIES}")
else()
message(CHECK_FAIL "not found")
endif()
message(CHECK_START "Searching for Cairo debug library") IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN)
FIND_LIBRARY(Cairo_LIBRARIES_DEBUG # MINGW should go here too
cairod IF(MSVC)
PATH_SUFFIXES # Implementation details:
lib # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
VC FIND_LIBRARY(CAIRO_DEBUG
lib/VC NAMES
lib/MINGW cairod
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
) FIND_LIBRARY(CAIRO_RELEASE
if (Cairo_LIBRARIES_DEBUG_FOUND) NAMES
message(CHECK_PASS "found ${Cairo_LIBRARIES_DEBUG}") cairo
else() ${_CAIRO_ROOT_HINTS_AND_PATHS}
message(CHECK_FAIL "not found") PATH_SUFFIXES
endif() "lib"
"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
)
message(CHECK_START "Looking for cairo include dirs") MARK_AS_ADVANCED(CAIRO)
find_path(Cairo_INCLUDE_DIRS set( CAIRO_LIBRARIES ${CAIRO} )
cairo-version.h ENDIF(MSVC)
PATH_SUFFIXES ELSE()
cairo
include/cairo FIND_LIBRARY(CAIRO_LIBRARY
) NAMES
if(Cairo_INCLUDE_DIRS) cairo
message(CHECK_PASS "Found: ${Cairo_INCLUDE_DIRS}") HINTS
message(CHECK_START "Extracting Cairo version") ${_CAIRO_LIBDIR}
find_file(Cairo_VERSION_H cairo-version.h HINTS ${Cairo_INCLUDE_DIRS}) ${_CAIRO_ROOT_HINTS_AND_PATHS}
if(Cairo_VERSION_H_FOUND) PATH_SUFFIXES
file(READ "${Cairo_VERSION_H}" _Cairo_VERSION_H_CONTENTS) "lib"
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*" "local/lib"
"\\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}) MARK_AS_ADVANCED(CAIRO_LIBRARY)
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*"
"\\2" Cairo_VERSION_MICRO ${_Cairo_VERSION_H_CONTENTS}) # compat defines
set(Cairo_VERSION ${Cairo_VERSION_MAJOR}.${Cairo_VERSION_MINOR}.${Cairo_VERSION_MICRO} SET(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
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_DIRS CAIRO_INCLUDE_DIR
VERSION_VAR VERSION_VAR
Cairo_VERSION CAIRO_VERSION
HANDLE_VERSION_RANGE
) )
MARK_AS_ADVANCED(Cairo_INCLUDE_DIRS Cairo_LIBRARIES) MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR 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()

103
cmake/FindFontconfig.cmake Normal file
View File

@ -0,0 +1,103 @@
# 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,6 +1,5 @@
# 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:
@ -65,10 +64,9 @@ 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 IMPORTED_TARGET) pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz)
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})
@ -92,18 +90,21 @@ 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
message(CHECK_START "Searching for harfbuzz") if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY)
if (HarfBuzz_LIBRARY) set(_HarfBuzz_REQUIRED_LIBS_FOUND ON)
message(CHECK_PASS "found at ${HarfBuzz_LIBRARY}") set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}")
else () else ()
message(CHECK_FAIL "not found") set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF)
set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)")
endif () endif ()
if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
message(CHECK_START "searching for harfbuzz-icu") pkg_check_modules(PC_HARFBUZZ_ICU QUIET 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
@ -118,47 +119,59 @@ if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
) )
if (HarfBuzz_ICU_LIBRARY) if (HarfBuzz_ICU_LIBRARY)
set(HarfBuzz_ICU_FOUND true) if (HarfBuzz_FIND_REQUIRED_ICU)
message(CHECK_PASS "found at ${HarfBuzz_ICU_LIBRARY}") list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}")
else ()
list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}")
endif ()
else () else ()
message(CHECK_FAIL "not found") if (HarfBuzz_FIND_REQUIRED_ICU)
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 REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND
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)
if (TARGET PkgConfig::PC_HARFBUZZ) add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL)
add_library(HarfBuzz::HarfBuzz ALIAS PkgConfig::PC_HARFBUZZ) set_target_properties(HarfBuzz::HarfBuzz PROPERTIES
else() IMPORTED_LOCATION "${HarfBuzz_LIBRARY}"
add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}"
set_target_properties(HarfBuzz::HarfBuzz PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}"
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)
if (TARGET PkgConfig::PC_HARFBUZZ) add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL)
add_library(HarfBuzz::ICU ALIAS PkgConfig::PC_HARFBUZZ_ICU) set_target_properties(HarfBuzz::ICU PROPERTIES
else() IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}"
add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}"
set_target_properties(HarfBuzz::ICU PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}"
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(
@ -171,4 +184,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,109 +1,148 @@
# - 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)
message(CHECK_START "Looking for pixman using pkg-config") pkg_check_modules(_PIXMAN pixman-1)
pkg_check_modules(Pixman pixman-1 IMPORTED_TARGET) endif (PKG_CONFIG_FOUND)
if (Pixman_FOUND)
message(CHECK_PASS "found by pkg-config")
else()
message(CHECK_FAIL "not found by pkg-config")
endif()
endif()
message(CHECK_START "Searching for pixman library") SET(_PIXMAN_ROOT_HINTS
FIND_LIBRARY(Pixman_LIBRARIES $ENV{PIXMAN}
pixman ${PIXMAN_ROOT_DIR}
pixman-1 )
pixman-1.0 SET(_PIXMAN_ROOT_PATHS
PATH_SUFFIXES $ENV{PIXMAN}/src
lib /usr
VC /usr/local
lib/VC )
) SET(_PIXMAN_ROOT_HINTS_AND_PATHS
if (Pixman_LIBRARIES_FOUND) HINTS ${_PIXMAN_ROOT_HINTS}
message(CHECK_PASS "found ${Pixman_LIBRARIES}") PATHS ${_PIXMAN_ROOT_PATHS}
else() )
message(CHECK_FAIL "not found")
endif()
message(CHECK_START "Looking for pixman include dirs") FIND_PATH(PIXMAN_INCLUDE_DIR
find_path(Pixman_INCLUDE_DIRS NAMES
pixman-version.h pixman.h
HINTS
${_PIXMAN_INCLUDEDIR}
${_PIXMAN_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
include include
include/pixman-1 "include/pixman-1"
) )
if(Pixman_INCLUDE_DIRS)
message(CHECK_PASS "Found: ${Pixman_INCLUDE_DIRS}") IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN)
message(CHECK_START "Extracting Pixman version") # MINGW should go here too
find_file(Pixman_VERSION_H pixman-version.h HINTS ${Pixman_INCLUDE_DIRS}) IF(MSVC)
if(Pixman_VERSION_H_FOUND) # Implementation details:
file(READ "${Pixman_VERSION_H}" _Pixman_VERSION_H_CONTENTS) # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*" FIND_LIBRARY(PIXMAN
"\\2" Pixman_VERSION_MAJOR ${_Pixman_VERSION_H_CONTENTS}) NAMES
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*" pixman-1
"\\2" Pixman_VERSION_MINOR ${_Pixman_VERSION_H_CONTENTS}) ${_PIXMAN_ROOT_HINTS_AND_PATHS}
string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*" PATH_SUFFIXES
"\\2" Pixman_VERSION_MICRO ${_Pixman_VERSION_H_CONTENTS}) "lib"
set(Pixman_VERSION ${Pixman_VERSION_MAJOR}.${Pixman_VERSION_MINOR}.${Pixman_VERSION_MICRO} "VC"
"lib/VC"
)
MARK_AS_ADVANCED(PIXMAN)
set( PIXMAN_LIBRARIES ${PIXMAN})
ELSEIF(MINGW)
# same player, for MingW
FIND_LIBRARY(PIXMAN
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_DIRS PIXMAN_INCLUDE_DIR
VERSION_VAR VERSION_VAR
Pixman_VERSION PIXMAN_VERSION
HANDLE_VERSION_RANGE
) )
MARK_AS_ADVANCED(Pixman_INCLUDE_DIRS Pixman_LIBRARIES) MARK_AS_ADVANCED(PIXMAN_INCLUDE_DIR 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::Freetype ${FREETYPE_LIBRARIES}
HarfBuzz::HarfBuzz ${HarfBuzz_LIBRARIES}
Fontconfig::Fontconfig ${Fontconfig_LIBRARIES}
) )
if( KICAD_USE_SENTRY ) if( KICAD_USE_SENTRY )

View File

@ -44,20 +44,24 @@ 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::Cairo ${CAIRO_LIBRARIES}
Pixman::Pixman ${PIXMAN_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
"$<$<PLATFORM_ID:Windows>:gdiplus>" # required for Cairo printing ${GDI_PLUS_LIBRARIES}
# outline font support # outline font support
Freetype::Freetype ${FREETYPE_LIBRARIES}
HarfBuzz::HarfBuzz ${HarfBuzz_LIBRARIES}
Fontconfig::Fontconfig ${Fontconfig_LIBRARIES}
) )
function( add_shader outTarget inFile shaderName ) function( add_shader outTarget inFile shaderName )
set(outCppName "${shaderName}.cpp") set(outCppName "${shaderName}.cpp")
@ -91,4 +95,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 )