diff options
author | Chia-I Wu <olv@lunarg.com> | 2015-01-10 23:15:51 +0800 |
---|---|---|
committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-02-04 17:58:05 -0700 |
commit | 60a20b8719762f5204e2354ae3c817f3c4f1931d (patch) | |
tree | d1c9ef705b0a8397582ba0419e4f30a343bf5976 /cmake | |
parent | e6b608c03839c8488a698bef21dbad640e696cd1 (diff) |
cmake: add find modules
Add Find{DRM,UDev,XCB}.cmake. Require 2.8.11 for FOUND_VAR support in
find_package_handle_standard_args().
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindDRM.cmake | 57 | ||||
-rw-r--r-- | cmake/FindUDev.cmake | 28 | ||||
-rw-r--r-- | cmake/FindXCB.cmake | 51 |
3 files changed, 136 insertions, 0 deletions
diff --git a/cmake/FindDRM.cmake b/cmake/FindDRM.cmake new file mode 100644 index 00000000..616fd235 --- /dev/null +++ b/cmake/FindDRM.cmake @@ -0,0 +1,57 @@ +# - FindDRM +# +# Copyright 2015 LunarG, Inc. + +find_package(PkgConfig) + +if(NOT DRM_FIND_COMPONENTS) + set(DRM_FIND_COMPONENTS libdrm) +endif() + +include(FindPackageHandleStandardArgs) +set(DRM_FOUND true) +set(DRM_INCLUDE_DIRS "") +set(DRM_LIBRARIES "") +foreach(comp ${DRM_FIND_COMPONENTS}) + # component name + string(REPLACE "lib" "" compname ${comp}) + string(TOUPPER ${compname} compname) + # header name + if(comp STREQUAL "libdrm") + set(headername xf86drm.h) + elseif(comp STREQUAL "libdrm_intel") + set(headername intel_bufmgr.h) + else() + string(REPLACE "libdrm_" "" headername ${comp}) + endif() + # library name + string(REPLACE "lib" "" libname ${comp}) + + pkg_check_modules(PC_${comp} QUIET ${comp}) + + find_path(${compname}_INCLUDE_DIR NAMES ${headername} + HINTS + ${PC_${comp}_INCLUDEDIR} + ${PC_${comp}_INCLUDE_DIRS} + ) + + find_library(${compname}_LIBRARY NAMES ${libname} + HINTS + ${PC_${comp}_LIBDIR} + ${PC_${comp}_LIBRARY_DIRS} + ) + + find_package_handle_standard_args(${comp} + FOUND_VAR ${comp}_FOUND + REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY) + mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY) + + list(APPEND DRM_INCLUDE_DIRS ${${compname}_INCLUDE_DIR}) + list(APPEND DRM_LIBRARIES ${${compname}_LIBRARY}) + + if(NOT ${comp}_FOUND) + set(DRM_FOUND false) + endif() +endforeach() + +list(REMOVE_DUPLICATES DRM_INCLUDE_DIRS) diff --git a/cmake/FindUDev.cmake b/cmake/FindUDev.cmake new file mode 100644 index 00000000..9fcc04a3 --- /dev/null +++ b/cmake/FindUDev.cmake @@ -0,0 +1,28 @@ +# - FindUDev +# +# Copyright 2015 LunarG, Inc. + +find_package(PkgConfig) + +pkg_check_modules(PC_LIBUDEV QUIET libudev) + +find_path(UDEV_INCLUDE_DIR NAMES libudev.h + HINTS + ${PC_LIBUDEV_INCLUDEDIR} + ${PC_LIBUDEV_INCLUDE_DIRS} + ) + +find_library(UDEV_LIBRARY NAMES udev + HINTS + ${PC_LIBUDEV_LIBDIR} + ${PC_LIBUDEV_LIBRARY_DIRS} + ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(UDev DEFAULT_MSG + UDEV_INCLUDE_DIR UDEV_LIBRARY) + +mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARY) + +set(UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR}) +set(UDEV_LIBRARIES ${UDEV_LIBRARY}) diff --git a/cmake/FindXCB.cmake b/cmake/FindXCB.cmake new file mode 100644 index 00000000..fbe3b5de --- /dev/null +++ b/cmake/FindXCB.cmake @@ -0,0 +1,51 @@ +# - FindXCB +# +# Copyright 2015 LunarG, Inc. + +find_package(PkgConfig) + +if(NOT XCB_FIND_COMPONENTS) + set(XCB_FIND_COMPONENTS xcb) +endif() + +include(FindPackageHandleStandardArgs) +set(XCB_FOUND true) +set(XCB_INCLUDE_DIRS "") +set(XCB_LIBRARIES "") +foreach(comp ${XCB_FIND_COMPONENTS}) + # component name + string(TOUPPER ${comp} compname) + string(REPLACE "-" "_" compname ${compname}) + # header name + string(REPLACE "xcb-" "" headername xcb/${comp}.h) + # library name + set(libname ${comp}) + + pkg_check_modules(PC_${comp} QUIET ${comp}) + + find_path(${compname}_INCLUDE_DIR NAMES ${headername} + HINTS + ${PC_${comp}_INCLUDEDIR} + ${PC_${comp}_INCLUDE_DIRS} + ) + + find_library(${compname}_LIBRARY NAMES ${libname} + HINTS + ${PC_${comp}_LIBDIR} + ${PC_${comp}_LIBRARY_DIRS} + ) + + find_package_handle_standard_args(${comp} + FOUND_VAR ${comp}_FOUND + REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY) + mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY) + + list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR}) + list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY}) + + if(NOT ${comp}_FOUND) + set(XCB_FOUND false) + endif() +endforeach() + +list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS) |