-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libmagic] Add CMake config. (#35274)
* [libmagic] Add CMake config. * Fix license information and add usage. * Address PR feedback. Co-authored-by: Kai Pastor <dg0yt@darc.de> * Set some missing properties. * Fix location to import library. * Update version database.
- Loading branch information
1 parent
ca9ac0b
commit 16ee2ec
Showing
6 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@PACKAGE_INIT@ | ||
|
||
if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(unofficial-tre) | ||
endif() | ||
|
||
# Compute the installation prefix relative to this file. | ||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) | ||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) | ||
if(_IMPORT_PREFIX STREQUAL "/") | ||
set(_IMPORT_PREFIX "") | ||
endif() | ||
|
||
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") | ||
add_library(unofficial::libmagic::libmagic STATIC IMPORTED) | ||
else() | ||
add_library(unofficial::libmagic::libmagic SHARED IMPORTED) | ||
endif() | ||
|
||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" | ||
) | ||
|
||
if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") | ||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES | ||
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:unofficial::tre::tre>" | ||
) | ||
endif() | ||
|
||
macro(add_library_config config prefix) | ||
set_property(TARGET unofficial::libmagic::libmagic APPEND PROPERTY IMPORTED_CONFIGURATIONS ${config}) | ||
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") | ||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES | ||
IMPORTED_LOCATION_${config} "${_IMPORT_PREFIX}/${prefix}lib/@VCPKG_TARGET_STATIC_LIBRARY_PREFIX@magic@VCPKG_TARGET_STATIC_LIBRARY_SUFFIX@" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES_${config} "C" | ||
) | ||
else() | ||
if(WIN32) | ||
set(library_dir "${_IMPORT_PREFIX}/${prefix}bin/") | ||
set(soversion_suffix "-1") | ||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES | ||
IMPORTED_IMPLIB_${config} "${_IMPORT_PREFIX}/${prefix}/lib/@VCPKG_TARGET_IMPORT_LIBRARY_PREFIX@magic@VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX@" | ||
) | ||
else() | ||
set(library_dir "${_IMPORT_PREFIX}/${prefix}lib/") | ||
endif() | ||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES | ||
IMPORTED_LOCATION_${config} "${library_dir}@VCPKG_TARGET_SHARED_LIBRARY_PREFIX@magic${soversion_suffix}@VCPKG_TARGET_SHARED_LIBRARY_SUFFIX@" | ||
) | ||
unset(soversion_suffix) | ||
unset(library_dir) | ||
endif() | ||
endmacro() | ||
|
||
if("@VCPKG_BUILD_TYPE@" STREQUAL "" OR "@VCPKG_BUILD_TYPE@" STREQUAL "debug") | ||
add_library_config(DEBUG "debug/") | ||
endif() | ||
|
||
if("@VCPKG_BUILD_TYPE@" STREQUAL "" OR "@VCPKG_BUILD_TYPE@" STREQUAL "release") | ||
add_library_config(RELEASE "") | ||
endif() | ||
|
||
set_and_check(unofficial-libmagic_DICTIONARY "${_IMPORT_PREFIX}/share/libmagic/misc/magic.mgc") | ||
|
||
unset(_IMPORT_PREFIX) | ||
|
||
check_required_components(unofficial-libmagic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
libmagic provides CMake targets: | ||
|
||
find_package(unofficial-libmagic REQUIRED) | ||
target_link_libraries(main PRIVATE unofficial::libmagic::libmagic) | ||
|
||
The magic.mgc file can be accessed from the unofficial-libmagic_DICTIONARY variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters