summaryrefslogtreecommitdiffhomepage
path: root/cmake/opentrack-pkg-config.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/opentrack-pkg-config.cmake')
-rw-r--r--cmake/opentrack-pkg-config.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/opentrack-pkg-config.cmake b/cmake/opentrack-pkg-config.cmake
new file mode 100644
index 00000000..0f13defc
--- /dev/null
+++ b/cmake/opentrack-pkg-config.cmake
@@ -0,0 +1,31 @@
+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()
+
+