Fix generate pkg config

This commit is contained in:
Gyusun Yeom 2020-12-29 22:55:52 +09:00
parent 397f383c53
commit b7aa06157b

View File

@ -1,5 +1,5 @@
function(GeneratePkgConfigFile target description) function(GeneratePkgConfigFile target description)
cmake_parse_arguments(pc "" "NAME;REQUIRES;LIBRARY_DIR" "" ${ARGV}) cmake_parse_arguments(pc "" "NAME;LIBRARY_DIR" "REQUIRES" ${ARGV})
if(NOT pc_LIBRARY_DIR) if(NOT pc_LIBRARY_DIR)
set(pc_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) set(pc_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
endif() endif()
@ -31,8 +31,11 @@ function(GeneratePkgConfigFile target description)
if(link MATCHES "-l") if(link MATCHES "-l")
list(APPEND links ${link}) list(APPEND links ${link})
elseif(TARGET ${link}) elseif(TARGET ${link})
get_property(link_target TARGET ${link} PROPERTY OUTPUT_NAME) get_property(is_imported TARGET ${link} PROPERTY IMPORTED)
list(APPEND links ${link_target}) if(NOT is_imported)
get_property(link_target TARGET ${link} PROPERTY OUTPUT_NAME)
list(APPEND links ${link_target})
endif()
else() else()
list(APPEND links "-l${link}") list(APPEND links "-l${link}")
endif() endif()
@ -52,7 +55,8 @@ function(GeneratePkgConfigFile target description)
file(APPEND ${out_file} "Cflags: -I\${includedir} ${definitions}\n") file(APPEND ${out_file} "Cflags: -I\${includedir} ${definitions}\n")
file(APPEND ${out_file} "Libs: -L\${libdir} ${links}\n") file(APPEND ${out_file} "Libs: -L\${libdir} ${links}\n")
if(pc_REQUIRES) if(pc_REQUIRES)
file(APPEND ${out_file} "Requires: ${pc_REQUIRES}") string(REPLACE ";" " " REQUIRES "${pc_REQUIRES}")
file(APPEND ${out_file} "Requires: ${REQUIRES}")
endif() endif()
install(FILES ${out_file} DESTINATION "${PKGCONFIG_INSTALL_DIR}") install(FILES ${out_file} DESTINATION "${PKGCONFIG_INSTALL_DIR}")
endfunction() endfunction()