aboutsummaryrefslogtreecommitdiff
path: root/cmake/MultiFind.cmake
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-23 17:10:45 +0100
committerMarvin W <git@larma.de>2017-03-23 17:16:08 +0100
commite6f89f8751e6e65d4a36a125cc3fe398098ba504 (patch)
tree54acce89355ee07b05db761d6d0dad8dad4e0f36 /cmake/MultiFind.cmake
parentef0483765a0fd567f25b1f0af6df04e8973e5624 (diff)
downloaddino-e6f89f8751e6e65d4a36a125cc3fe398098ba504.tar.gz
dino-e6f89f8751e6e65d4a36a125cc3fe398098ba504.zip
New CMake
- add install and uninstall targets - compatibility for systems without pkg-config
Diffstat (limited to 'cmake/MultiFind.cmake')
-rw-r--r--cmake/MultiFind.cmake45
1 files changed, 45 insertions, 0 deletions
diff --git a/cmake/MultiFind.cmake b/cmake/MultiFind.cmake
new file mode 100644
index 00000000..b40a4677
--- /dev/null
+++ b/cmake/MultiFind.cmake
@@ -0,0 +1,45 @@
+include(CMakeParseArguments)
+
+function(find_packages result)
+ cmake_parse_arguments(ARGS "" "" "REQUIRED;OPTIONAL" ${ARGN})
+ set(_res "")
+ set(_res_libs "")
+ foreach(pkg ${ARGS_REQUIRED})
+ string(REPLACE ">=" ";" pkg_ ${pkg})
+ list(GET pkg_ "0" pkg)
+ list(LENGTH pkg_ pkg_has_version)
+ if(pkg_has_version GREATER 1)
+ list(GET pkg_ "1" pkg_version)
+ else()
+ if(${pkg}_GLOBAL_VERSION)
+ set(pkg_version ${${pkg}_GLOBAL_VERSION})
+ else()
+ unset(pkg_version)
+ endif()
+ endif()
+ find_package(${pkg} ${pkg_version} REQUIRED)
+ list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
+ list(APPEND _res_libs ${${pkg}_LIBRARIES})
+ endforeach(pkg)
+ foreach(pkg ${ARGS_OPTIONAL})
+ string(REPLACE ">=" ";" pkg_ ${pkg})
+ list(GET pkg_ "0" pkg)
+ list(LENGTH pkg_ pkg_has_version)
+ if(pkg_has_version GREATER 1)
+ list(GET pkg_ "1" pkg_version)
+ else()
+ if(${pkg}_GLOBAL_VERSION)
+ set(pkg_version ${${pkg}_GLOBAL_VERSION})
+ else()
+ unset(pkg_version)
+ endif()
+ endif()
+ find_package(${pkg} ${pkg_version})
+ if(${pkg}_FOUND)
+ list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
+ list(APPEND _res_libs ${${pkg}_LIBRARIES})
+ endif()
+ endforeach(pkg)
+ set(${result} "${_res}" PARENT_SCOPE)
+ set(${result}_LIBS "${_res_libs}" PARENT_SCOPE)
+endfunction()