Skip to content

Commit 55c7c3d

Browse files
committed
[CMake] Use an imported target for the libtasn1 find-module
https://bugs.webkit.org/show_bug.cgi?id=302860 Reviewed by Michael Catanzaro. Rename the find-module for libtasn1 as FindTasn1.cmake to follow a more idiomatic naming convention, and update it to define an imported target. * Source/WebCore/PlatformGTK.cmake: * Source/WebCore/PlatformWPE.cmake: * Source/cmake/FindLibtasn1.cmake: Removed. * Source/cmake/FindTasn1.cmake: Added. * Source/cmake/OptionsGTK.cmake: * Source/cmake/OptionsWPE.cmake: Canonical link: https://commits.webkit.org/303333@main
1 parent 68e5b29 commit 55c7c3d

File tree

6 files changed

+102
-54
lines changed

6 files changed

+102
-54
lines changed

‎Source/WebCore/PlatformGTK.cmake‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
6767
platform/text/enchant/TextCheckerEnchant.h
6868
)
6969

70+
list(APPEND WebCore_PRIVATE_LIBRARIES
71+
Tasn1::Tasn1
72+
)
73+
7074
list(APPEND WebCore_LIBRARIES
7175
${ENCHANT_LIBRARIES}
7276
${LIBSECRET_LIBRARIES}
73-
${LIBTASN1_LIBRARIES}
7477
${UPOWERGLIB_LIBRARIES}
7578
${X11_X11_LIB}
7679
Cairo::Cairo
@@ -80,7 +83,6 @@ list(APPEND WebCore_LIBRARIES
8083
list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
8184
${ENCHANT_INCLUDE_DIRS}
8285
${LIBSECRET_INCLUDE_DIRS}
83-
${LIBTASN1_INCLUDE_DIRS}
8486
${UPOWERGLIB_INCLUDE_DIRS}
8587
)
8688

‎Source/WebCore/PlatformWPE.cmake‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
7070

7171
set(WebCore_USER_AGENT_SCRIPTS_DEPENDENCIES ${WEBCORE_DIR}/platform/wpe/RenderThemeWPE.cpp)
7272

73+
list(APPEND WebCore_PRIVATE_LIBRARIES
74+
Tasn1::Tasn1
75+
)
76+
7377
list(APPEND WebCore_LIBRARIES
7478
GLib::Module
7579
WPE::libwpe
76-
${LIBTASN1_LIBRARIES}
7780
${UPOWERGLIB_LIBRARIES}
7881
)
7982

8083
list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
81-
${LIBTASN1_INCLUDE_DIRS}
8284
${UPOWERGLIB_INCLUDE_DIRS}
8385
)
8486

‎Source/cmake/FindLibtasn1.cmake‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎Source/cmake/FindTasn1.cmake‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright (C) 2017, 2025 Igalia S.L.
2+
# Copyright (C) 2017 Metrological Group B.V.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions
6+
# are met:
7+
# 1. Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
#
13+
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
# THE POSSIBILITY OF SUCH DAMAGE.
24+
25+
#[=======================================================================[.rst:
26+
FindTasn1
27+
---------
28+
29+
Find the libtasn1 headers and library.
30+
31+
32+
Imported Targets
33+
^^^^^^^^^^^^^^^^
34+
35+
``Tasn1::Tasn1``
36+
The libtasn1 library, if found.
37+
38+
Result Variables
39+
^^^^^^^^^^^^^^^^
40+
41+
``Tasn1_FOUND``
42+
True if (the requested version of) libtasn1 is available.
43+
``Tasn1_VERSION``
44+
Version of the libtasn1 library.
45+
46+
#]=======================================================================]
47+
48+
find_package(PkgConfig QUIET)
49+
pkg_check_modules(PC_Tasn1 QUIET IMPORTED_TARGET libtasn1)
50+
51+
set(Tasn1_COMPILE_OPTIONS ${PC_Tasn1_CFLAGS_OTHER})
52+
set(Tasn1_VERSION ${PC_Tasn1_VERSION})
53+
54+
if (PC_Tasn1_FOUND AND TARGET PkgConfig::PC_Tasn1 AND NOT TARGET Tasn1::Tasn1)
55+
get_target_property(Tasn1_LIBRARY PkgConfig::PC_Tasn1 INTERFACE_LINK_LIBRARIES)
56+
list(GET Tasn1_LIBRARY 0 Tasn1_LIBRARY)
57+
add_library(Tasn1::Tasn1 INTERFACE IMPORTED GLOBAL)
58+
set_property(TARGET Tasn1::Tasn1 PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::PC_Tasn1)
59+
endif ()
60+
61+
# Search the library by hand, as a fallback.
62+
if (NOT TARGET Tasn1::Tasn1)
63+
find_path(Tasn1_INCLUDE_DIR
64+
NAMES libtasn1.h
65+
HINTS ${PC_Tasn1_INCLUDEDIR}
66+
${PC_Tasn1_INCLUDE_DIRS}
67+
)
68+
find_library(Tasn1_LIBRARY
69+
NAMES tasn1
70+
HINTS ${PC_Tasn1_LIBDIR}
71+
${PC_Tasn1_LIBRARY_DIRS}
72+
)
73+
if (Tasn1_LIBRARY)
74+
add_library(Tasn1::Tasn1 UNKNOWN IMPORTED GLOBAL)
75+
set_target_properties(Tasn1::Tasn1 PROPERTIES
76+
IMPORTED_LOCATION "${Tasn1_LIBRARY}"
77+
INTERFACE_COMPILE_OPTIONS "${Tasn1_COMPILE_OPTIONS}"
78+
INTERFACE_INCLUDE_DIRECTORIES "${Tasn1_INCLUDE_DIR}"
79+
)
80+
endif ()
81+
endif ()
82+
83+
include(FindPackageHandleStandardArgs)
84+
find_package_handle_standard_args(Tasn1
85+
REQUIRED_VARS Tasn1_LIBRARY
86+
VERSION_VAR Tasn1_VERSION
87+
)
88+
89+
mark_as_advanced(
90+
Tasn1_INCLUDE_DIR
91+
Tasn1_LIBRARY
92+
)

‎Source/cmake/OptionsGTK.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ find_package(GLib 2.70.0 REQUIRED COMPONENTS GioUnix Thread Module)
1212
find_package(Cairo 1.16.0 REQUIRED)
1313
find_package(LibGcrypt 1.7.0 REQUIRED)
1414
find_package(Soup3 3.0.0 REQUIRED)
15-
find_package(Libtasn1 REQUIRED)
15+
find_package(Tasn1 REQUIRED)
1616
find_package(HarfBuzz 2.7.4 REQUIRED COMPONENTS ICU)
1717
find_package(ICU 70.1 REQUIRED COMPONENTS data i18n uc)
1818
find_package(JPEG REQUIRED)

‎Source/cmake/OptionsWPE.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ find_package(JPEG REQUIRED)
1313
find_package(Epoxy 1.5.4 REQUIRED)
1414
find_package(LibGcrypt 1.7.0 REQUIRED)
1515
find_package(Soup3 3.0.0 REQUIRED)
16-
find_package(Libtasn1 REQUIRED)
16+
find_package(Tasn1 REQUIRED)
1717
find_package(XkbCommon 0.4.0 REQUIRED)
1818
find_package(LibXml2 2.9.13 REQUIRED)
1919
find_package(PNG REQUIRED)

0 commit comments

Comments
 (0)