diff --git a/CMakeLists.txt b/CMakeLists.txt index e510c690b1..54d565d365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -751,8 +751,10 @@ find_package( CURL REQUIRED ) # Find Cairo library, required # find_package( Cairo 1.12 REQUIRED ) +include_directories( SYSTEM ${CAIRO_INCLUDE_DIR} ) find_package( Pixman 0.30 REQUIRED ) +include_directories( SYSTEM ${PIXMAN_INCLUDE_DIR} ) # # Find Boost headers and libraries, required. @@ -773,8 +775,10 @@ set( FREETYPE_MIN_VERSION 2.11.1 ) endif() find_package( Freetype ${FREETYPE_MIN_VERSION} REQUIRED ) +include_directories( SYSTEM ${FREETYPE_INCLUDE_DIRS} ) find_package( HarfBuzz REQUIRED ) +include_directories( SYSTEM ${HarfBuzz_INCLUDE_DIRS} ) find_package( Fontconfig REQUIRED ) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake index 544d49eba5..c5146f760f 100644 --- a/cmake/FindCairo.cmake +++ b/cmake/FindCairo.cmake @@ -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: -# Cairo_FOUND - system has the Cairo library -# Cairo_INCLUDE_DIR - the Cairo include directory -# Cairo_LIBRARIES - The libraries needed to use Cairo -# Cairo_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) +# CAIRO_FOUND - system has the CAIRO library +# CAIRO_INCLUDE_DIR - the CAIRO include directory +# CAIRO_LIBRARIES - The libraries needed to use CAIRO +# CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) -# ============================================================================= +#============================================================================= # Copyright 2012 Dmitry Baryshnikov -# Copyright 2023 Nimish Telang # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -16,117 +18,149 @@ # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. -# ============================================================================= +#============================================================================= # (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) -cmake_policy(SET CMP0074 NEW) if(PKG_CONFIG_FOUND) - message(CHECK_START "Looking for cairo using pkg-config") - 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() + pkg_check_modules(_CAIRO cairo) +endif (PKG_CONFIG_FOUND) -message(CHECK_START "Searching for cairo library") -FIND_LIBRARY(Cairo_LIBRARIES - cairo +SET(_CAIRO_ROOT_HINTS + $ENV{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 - lib - VC - lib/VC - lib/MINGW + include + "include/cairo" ) -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") -FIND_LIBRARY(Cairo_LIBRARIES_DEBUG - cairod - PATH_SUFFIXES - lib - VC - lib/VC - lib/MINGW +IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN) + # MINGW should go here too + IF(MSVC) + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + FIND_LIBRARY(CAIRO_DEBUG + NAMES + cairod + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) -) -if (Cairo_LIBRARIES_DEBUG_FOUND) - message(CHECK_PASS "found ${Cairo_LIBRARIES_DEBUG}") -else() - message(CHECK_FAIL "not found") -endif() + FIND_LIBRARY(CAIRO_RELEASE + NAMES + cairo + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "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") -find_path(Cairo_INCLUDE_DIRS - cairo-version.h - PATH_SUFFIXES - cairo - include/cairo -) -if(Cairo_INCLUDE_DIRS) - message(CHECK_PASS "Found: ${Cairo_INCLUDE_DIRS}") - message(CHECK_START "Extracting Cairo version") - find_file(Cairo_VERSION_H cairo-version.h HINTS ${Cairo_INCLUDE_DIRS}) - if(Cairo_VERSION_H_FOUND) - file(READ "${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} + MARK_AS_ADVANCED(CAIRO) + set( CAIRO_LIBRARIES ${CAIRO} ) + ENDIF(MSVC) +ELSE() + + FIND_LIBRARY(CAIRO_LIBRARY + NAMES + cairo + HINTS + ${_CAIRO_LIBDIR} + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "local/lib" + ) + + MARK_AS_ADVANCED(CAIRO_LIBRARY) + + # compat defines + 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") - 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() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Cairo REQUIRED_VARS - Cairo_LIBRARIES - Cairo_INCLUDE_DIRS + CAIRO_LIBRARIES + CAIRO_INCLUDE_DIR VERSION_VAR - Cairo_VERSION - HANDLE_VERSION_RANGE + CAIRO_VERSION ) -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() +MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES) diff --git a/cmake/FindFontconfig.cmake b/cmake/FindFontconfig.cmake new file mode 100644 index 0000000000..2e2541cf0c --- /dev/null +++ b/cmake/FindFontconfig.cmake @@ -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() \ No newline at end of file diff --git a/cmake/FindHarfBuzz.cmake b/cmake/FindHarfBuzz.cmake index 6fdbe7a0da..cee2a390b6 100644 --- a/cmake/FindHarfBuzz.cmake +++ b/cmake/FindHarfBuzz.cmake @@ -1,6 +1,5 @@ # Copyright (c) 2012, Intel Corporation # Copyright (c) 2019 Sony Interactive Entertainment Inc. -# Copyright (c) 2023 Kicad Contributors # # Redistribution and use in source and binary forms, with or without # 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 #]=======================================================================] -cmake_policy(SET CMP0074 NEW) 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_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION}) @@ -92,18 +90,21 @@ 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 -message(CHECK_START "Searching for harfbuzz") -if (HarfBuzz_LIBRARY) - message(CHECK_PASS "found at ${HarfBuzz_LIBRARY}") +if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY) + set(_HarfBuzz_REQUIRED_LIBS_FOUND ON) + set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}") else () - message(CHECK_FAIL "not found") + set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) + set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)") endif () if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) - message(CHECK_START "searching for harfbuzz-icu") - - pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu IMPORTED_TARGET) + pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu) set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER}) find_path(HarfBuzz_ICU_INCLUDE_DIR @@ -118,47 +119,59 @@ if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) ) if (HarfBuzz_ICU_LIBRARY) - set(HarfBuzz_ICU_FOUND true) - message(CHECK_PASS "found at ${HarfBuzz_ICU_LIBRARY}") + if (HarfBuzz_FIND_REQUIRED_ICU) + list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}") + else () + list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}") + endif () 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 () +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) find_package_handle_standard_args(HarfBuzz 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 - HANDLE_COMPONENTS - HANDLE_VERSION_RANGE ) if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz) - if (TARGET PkgConfig::PC_HARFBUZZ) - add_library(HarfBuzz::HarfBuzz ALIAS PkgConfig::PC_HARFBUZZ) - else() - add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) - set_target_properties(HarfBuzz::HarfBuzz PROPERTIES - IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" - ) - endif() + add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) + set_target_properties(HarfBuzz::HarfBuzz PROPERTIES + IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" + ) endif () if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU) - if (TARGET PkgConfig::PC_HARFBUZZ) - add_library(HarfBuzz::ICU ALIAS PkgConfig::PC_HARFBUZZ_ICU) - else() - add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) - 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() + add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) + 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 () mark_as_advanced( @@ -171,4 +184,4 @@ mark_as_advanced( if (HarfBuzz_FOUND) set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY}) set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR}) -endif () +endif () \ No newline at end of file diff --git a/cmake/FindPixman.cmake b/cmake/FindPixman.cmake index 6e09581452..128ca8237b 100644 --- a/cmake/FindPixman.cmake +++ b/cmake/FindPixman.cmake @@ -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: -# Pixman_FOUND - system has the Pixman library -# Pixman_INCLUDE_DIR - the Pixman include directory -# Pixman_LIBRARIES - The libraries needed to use Pixman -# Pixman_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) +# PIXMAN_FOUND - system has the PIXMAN library +# PIXMAN_INCLUDE_DIR - the PIXMAN include directory +# PIXMAN_LIBRARIES - The libraries needed to use PIXMAN +# PIXMAN_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) -# ============================================================================= +#============================================================================= # Copyright 2012 Dmitry Baryshnikov # Copyright 2017 Simon Richter -# Copyright 2023 Nimish Telang - +# # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. -# ============================================================================= +#============================================================================= # (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) -cmake_policy(SET CMP0074 NEW) if(PKG_CONFIG_FOUND) - message(CHECK_START "Looking for pixman using pkg-config") - 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() + pkg_check_modules(_PIXMAN pixman-1) +endif (PKG_CONFIG_FOUND) -message(CHECK_START "Searching for pixman library") -FIND_LIBRARY(Pixman_LIBRARIES - pixman - pixman-1 - pixman-1.0 - PATH_SUFFIXES - lib - VC - lib/VC -) -if (Pixman_LIBRARIES_FOUND) - message(CHECK_PASS "found ${Pixman_LIBRARIES}") -else() - message(CHECK_FAIL "not found") -endif() +SET(_PIXMAN_ROOT_HINTS + $ENV{PIXMAN} + ${PIXMAN_ROOT_DIR} + ) +SET(_PIXMAN_ROOT_PATHS + $ENV{PIXMAN}/src + /usr + /usr/local + ) +SET(_PIXMAN_ROOT_HINTS_AND_PATHS + HINTS ${_PIXMAN_ROOT_HINTS} + PATHS ${_PIXMAN_ROOT_PATHS} + ) -message(CHECK_START "Looking for pixman include dirs") -find_path(Pixman_INCLUDE_DIRS - pixman-version.h +FIND_PATH(PIXMAN_INCLUDE_DIR + NAMES + pixman.h + HINTS + ${_PIXMAN_INCLUDEDIR} + ${_PIXMAN_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES - include - include/pixman-1 + include + "include/pixman-1" ) -if(Pixman_INCLUDE_DIRS) - message(CHECK_PASS "Found: ${Pixman_INCLUDE_DIRS}") - message(CHECK_START "Extracting Pixman version") - find_file(Pixman_VERSION_H pixman-version.h HINTS ${Pixman_INCLUDE_DIRS}) - if(Pixman_VERSION_H_FOUND) - 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}) - string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*" - "\\2" Pixman_VERSION_MINOR ${_Pixman_VERSION_H_CONTENTS}) - string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_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} + +IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN) + # MINGW should go here too + IF(MSVC) + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + FIND_LIBRARY(PIXMAN + NAMES + pixman-1 + ${_PIXMAN_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "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") - 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() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Pixman REQUIRED_VARS - Pixman_LIBRARIES - Pixman_INCLUDE_DIRS + PIXMAN_LIBRARIES + PIXMAN_INCLUDE_DIR VERSION_VAR - Pixman_VERSION - HANDLE_VERSION_RANGE + PIXMAN_VERSION ) -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() +MARK_AS_ADVANCED(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARIES) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index a11122ddb5..31a877107d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -499,9 +499,9 @@ target_link_libraries( common ${wxWidgets_LIBRARIES} ${EXTRA_LIBS} # outline font support - Freetype::Freetype - HarfBuzz::HarfBuzz - Fontconfig::Fontconfig + ${FREETYPE_LIBRARIES} + ${HarfBuzz_LIBRARIES} + ${Fontconfig_LIBRARIES} ) if( KICAD_USE_SENTRY ) diff --git a/common/gal/CMakeLists.txt b/common/gal/CMakeLists.txt index 6d14ac1eff..b23190cecd 100644 --- a/common/gal/CMakeLists.txt +++ b/common/gal/CMakeLists.txt @@ -44,20 +44,24 @@ set( 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 common # This is needed until the circular dependency is removed kimath nlohmann_json ${GLEW_LIBRARIES} - Cairo::Cairo - Pixman::Pixman + ${CAIRO_LIBRARIES} + ${PIXMAN_LIBRARIES} ${OPENGL_LIBRARIES} - "$<$:gdiplus>" # required for Cairo printing + ${GDI_PLUS_LIBRARIES} # outline font support - Freetype::Freetype - HarfBuzz::HarfBuzz - Fontconfig::Fontconfig + ${FREETYPE_LIBRARIES} + ${HarfBuzz_LIBRARIES} + ${Fontconfig_LIBRARIES} ) function( add_shader outTarget inFile shaderName ) 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_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_vert.glsl glsl_smaa_pass_3_vert ) +add_shader( gal smaa_pass_3_vert.glsl glsl_smaa_pass_3_vert ) \ No newline at end of file