include_guard(GLOBAL) include(FindPkgConfig) function(_otr_pkgconfig_add target k) target_compile_options(${target} PRIVATE "${${k}_CFLAGS}") target_link_options(${target} PRIVATE ${${k}_LDFLAGS}) target_include_directories(${target} SYSTEM PRIVATE ${${k}_INCLUDE_DIRS} ${${k}_INCLUDEDIR}) target_link_libraries(${target} ${${k}_LIBRARIES}) endfunction() function(otr_pkgconfig_ ret target) set(${ret} 1 PARENT_SCOPE) foreach(i ${ARGN}) set(k pkg-config_${i}) pkg_check_modules(${k} ${i}) if(${k}_FOUND) _otr_pkgconfig_add(${target} ${k}) else() set(${ret} 0 PARENT_SCOPE) endif() endforeach() endfunction() function(otr_pkgconfig target) foreach(i ${ARGN}) set(k pkg-config_${i}) pkg_check_modules(${k} ${i}) if(NOT ${k}_FOUND) message(FATAL_ERROR "can't find ${i} for ${target}") endif() _otr_pkgconfig_add(${target} ${k}) endforeach() endfunction()