mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 17:02:51 +08:00
CMake: Remove duplicate find_package
Packages of third-party dependencies were searched twice. Once when adding them via wx_add_thirdparty_library to determine if they are available or of the built-in library should be used. And then again when including the third-party cmake file. Move all the logic into the third-party library cmake file. This also removes the need to move the WebP variables into the parent scope.
This commit is contained in:
@@ -718,14 +718,6 @@ function(wx_add_thirdparty_library var_name lib_name help_str)
|
||||
wx_option(${var_name} ${help_str} ${thirdparty_lib_default}
|
||||
STRINGS builtin sys OFF)
|
||||
|
||||
if(${var_name} STREQUAL "sys")
|
||||
# If the sys library can not be found use builtin
|
||||
find_package(${lib_name})
|
||||
if(NOT ${lib_name}_FOUND)
|
||||
wx_option_force_value(${var_name} builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} ${var_name} "${help_str}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_EXPAT STREQUAL "sys")
|
||||
find_package(EXPAT)
|
||||
if(NOT EXPAT_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_EXPAT builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_EXPAT STREQUAL "builtin")
|
||||
# TODO: implement building expat via its CMake file, using
|
||||
# add_subdirectory or ExternalProject_Add
|
||||
@@ -17,6 +25,4 @@ if(wxUSE_EXPAT STREQUAL "builtin")
|
||||
)
|
||||
set(EXPAT_LIBRARIES wxexpat)
|
||||
set(EXPAT_INCLUDE_DIRS ${wxSOURCE_DIR}/src/expat/expat/lib)
|
||||
elseif(wxUSE_EXPAT)
|
||||
find_package(EXPAT REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_LIBJPEG STREQUAL "sys")
|
||||
find_package(JPEG)
|
||||
if(NOT JPEG_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_LIBJPEG builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_LIBJPEG STREQUAL "builtin")
|
||||
wx_add_builtin_library(wxjpeg
|
||||
src/jpeg/jaricom.c
|
||||
@@ -62,6 +70,4 @@ if(wxUSE_LIBJPEG STREQUAL "builtin")
|
||||
)
|
||||
set(JPEG_LIBRARIES wxjpeg)
|
||||
set(JPEG_INCLUDE_DIR ${wxSOURCE_DIR}/src/jpeg)
|
||||
elseif(wxUSE_LIBJPEG)
|
||||
find_package(JPEG REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_NANOSVG STREQUAL "sys")
|
||||
find_package(NanoSVG)
|
||||
if(NOT NanoSVG_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_NANOSVG builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_NANOSVG STREQUAL "builtin")
|
||||
set(wxUSE_NANOSVG_EXTERNAL 0 PARENT_SCOPE)
|
||||
elseif(wxUSE_NANOSVG)
|
||||
@@ -16,8 +24,6 @@ elseif(wxUSE_NANOSVG)
|
||||
set(NANOSVG_INCLUDE_DIRS )
|
||||
set(wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL TRUE)
|
||||
|
||||
find_package(NanoSVG REQUIRED)
|
||||
|
||||
foreach(TARGETNAME NanoSVG::nanosvg NanoSVG::nanosvgrast unofficial::nanosvg)
|
||||
if(NOT TARGET ${TARGETNAME})
|
||||
continue()
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_LIBPNG STREQUAL "sys")
|
||||
find_package(PNG)
|
||||
if(NOT PNG_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_LIBPNG builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_LIBPNG STREQUAL "builtin")
|
||||
# TODO: implement building libpng via its CMake file, using
|
||||
# add_subdirectory or ExternalProject_Add
|
||||
@@ -53,6 +61,4 @@ if(wxUSE_LIBPNG STREQUAL "builtin")
|
||||
target_link_libraries(wxpng PRIVATE ${ZLIB_LIBRARIES})
|
||||
set(PNG_LIBRARIES wxpng)
|
||||
set(PNG_INCLUDE_DIRS ${wxSOURCE_DIR}/src/png)
|
||||
elseif(wxUSE_LIBPNG)
|
||||
find_package(PNG REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,17 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_REGEX STREQUAL "sys")
|
||||
find_package(PCRE2)
|
||||
if(NOT PCRE2_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_REGEX builtin)
|
||||
else()
|
||||
set(REGEX_LIBRARIES ${PCRE2_LIBRARIES})
|
||||
set(REGEX_INCLUDE_DIRS ${PCRE2_INCLUDE_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_REGEX STREQUAL "builtin")
|
||||
# TODO: implement building PCRE2 via its CMake file, using
|
||||
# add_subdirectory or ExternalProject_Add
|
||||
@@ -45,8 +56,4 @@ if(wxUSE_REGEX STREQUAL "builtin")
|
||||
set(REGEX_INCLUDE_DIRS ${wxSOURCE_DIR}/3rdparty/pcre/src/wx)
|
||||
target_compile_definitions(wxregex PRIVATE __WX__ HAVE_CONFIG_H)
|
||||
target_include_directories(wxregex PRIVATE ${wxSETUP_HEADER_PATH} ${wxSOURCE_DIR}/include ${REGEX_INCLUDE_DIRS})
|
||||
elseif(wxUSE_REGEX)
|
||||
find_package(PCRE2 REQUIRED)
|
||||
set(REGEX_LIBRARIES ${PCRE2_LIBRARIES})
|
||||
set(REGEX_INCLUDE_DIRS ${PCRE2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_LIBTIFF STREQUAL "sys")
|
||||
find_package(TIFF)
|
||||
if(NOT TIFF_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_LIBTIFF builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_LIBTIFF STREQUAL "builtin")
|
||||
# TODO: implement building libtiff via its CMake file, using
|
||||
# add_subdirectory or ExternalProject_Add
|
||||
@@ -76,6 +84,4 @@ if(wxUSE_LIBTIFF STREQUAL "builtin")
|
||||
target_link_libraries(wxtiff PRIVATE ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES})
|
||||
set(TIFF_LIBRARIES wxtiff)
|
||||
set(TIFF_INCLUDE_DIRS ${wxSOURCE_DIR}/src/tiff/libtiff)
|
||||
elseif(wxUSE_LIBTIFF)
|
||||
find_package(TIFF REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_LIBWEBP STREQUAL "sys")
|
||||
find_package(WebP)
|
||||
if(NOT WebP_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_LIBWEBP builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_LIBWEBP STREQUAL "builtin")
|
||||
set(WEBP_ROOT "${wxSOURCE_DIR}/3rdparty/libwebp")
|
||||
set(WEBP_BUILD_ROOT "${CMAKE_CURRENT_BINARY_DIR}/webp-build")
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# Licence: wxWindows licence
|
||||
#############################################################################
|
||||
|
||||
if(wxUSE_ZLIB STREQUAL "sys")
|
||||
find_package(ZLIB)
|
||||
if(NOT ZLIB_FOUND)
|
||||
# If the sys library can not be found use builtin
|
||||
wx_option_force_value(wxUSE_ZLIB builtin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_ZLIB STREQUAL "builtin")
|
||||
# TODO: implement building zlib via its CMake file, using
|
||||
# add_subdirectory or ExternalProject_Add
|
||||
@@ -40,6 +48,4 @@ if(wxUSE_ZLIB STREQUAL "builtin")
|
||||
endif()
|
||||
set(ZLIB_LIBRARIES wxzlib)
|
||||
set(ZLIB_INCLUDE_DIRS ${wxSOURCE_DIR}/src/zlib)
|
||||
elseif(wxUSE_ZLIB)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -6,6 +6,3 @@ if(NOT WebP_FOUND)
|
||||
pkg_check_modules(WebP libwebp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(WebP_LIBRARIES ${WebP_LIBRARIES} PARENT_SCOPE)
|
||||
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
|
||||
Reference in New Issue
Block a user