include_guard(GLOBAL) include(FindPkgConfig) function(otr_pkgconfig_ ret target) set(${ret} 1 PARENT_SCOPE) foreach(i ${ARGN}) set(k pkg-config_${i}) pkg_check_modules(${k} QUIET ${i}) if(${${k}_FOUND}) 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}) else() set(${ret} 0 PARENT_SCOPE) endif() endforeach() endfunction() function(otr_pkgconfig target) set(ret "") otr_pkgconfig_(ret "${target}" ${ARGN}) foreach(i ${ARGN}) set(k pkg-config_${i}) if(NOT ${${k}_FOUND}) message(FATAL_ERROR "Can't find '${i}'. Please install development files for this package.") endif() endforeach() endfunction()