Skip to content

Commit c788038

Browse files
committed
Make FindPOPT.cmake import cmake targets
Signed-off-by: GitHub <noreply@github.com>
1 parent f2e8abb commit c788038

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

cmake/FindPOPT.cmake

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,38 @@
1111
find_package(PkgConfig QUIET)
1212
if (PKG_CONFIG_FOUND)
1313
pkg_search_module(PC_POPT QUIET popt)
14-
endif ()
14+
endif()
1515

1616
# Find the include directories
17-
FIND_PATH(POPT_INCLUDE_DIR
18-
NAMES popt.h
19-
HINTS
20-
${PC_POPT_INCLUDEDIR}
21-
${PC_POPT_INCLUDE_DIRS}
22-
DOC "Path containing the popt.h include file"
23-
)
24-
25-
FIND_LIBRARY(POPT_LIBRARY
26-
NAMES popt
27-
HINTS
28-
${PC_POPT_LIBRARYDIR}
29-
${PC_POPT_LIBRARY_DIRS}
30-
DOC "popt library path"
31-
)
17+
find_path(POPT_INCLUDE_DIR
18+
NAMES popt.h
19+
HINTS
20+
${PC_POPT_INCLUDEDIR}
21+
${PC_POPT_INCLUDE_DIRS}
22+
DOC "Path containing the popt.h include file"
23+
)
24+
25+
find_library(POPT_LIBRARY
26+
NAMES popt
27+
HINTS
28+
${PC_POPT_LIBRARYDIR}
29+
${PC_POPT_LIBRARY_DIRS}
30+
DOC "popt library path"
31+
)
3232

3333
include(FindPackageHandleStandardArgs)
3434

35-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(POPT
35+
find_package_handle_standard_args(POPT
3636
REQUIRED_VARS POPT_INCLUDE_DIR POPT_LIBRARY
3737
VERSION_VAR PC_POPT_VERSION)
3838

39-
MARK_AS_ADVANCED(POPT_INCLUDE_DIR POPT_LIBRARY)
39+
mark_as_advanced(POPT_INCLUDE_DIR POPT_LIBRARY)
40+
41+
if(POPT_FOUND AND NOT TARGET popt::popt)
42+
add_library(popt::popt UNKNOWN IMPORTED)
43+
set_target_properties(popt::popt PROPERTIES
44+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
45+
IMPORTED_LOCATION "${POPT_LIBRARY}"
46+
INTERFACE_INCLUDE_DIRECTORIES "${POPT_INCLUDE_DIR}"
47+
)
48+
endif()

0 commit comments

Comments
 (0)