FindDetours.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Once done these will be defined:
  2. #
  3. # * DETOURS_FOUND
  4. # * DETOURS_INCLUDE_DIRS
  5. # * DETOURS_LIBRARIES
  6. #
  7. # For use in OBS:
  8. #
  9. # DETOURS_INCLUDE_DIR
  10. find_package(PkgConfig QUIET)
  11. if(PKG_CONFIG_FOUND)
  12. pkg_check_modules(_DETOURS QUIET detours)
  13. endif()
  14. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  15. set(_lib_suffix 64)
  16. else()
  17. set(_lib_suffix 32)
  18. endif()
  19. find_path(
  20. DETOURS_INCLUDE_DIR
  21. NAMES detours.h
  22. HINTS ENV DETOURS_PATH ${DETOURS_PATH} ${CMAKE_SOURCE_DIR}/${DETOURS_PATH}
  23. ${_DETOURS_INCLUDE_DIRS}
  24. PATHS /usr/include /usr/local/include /opt/local/include /sw/include
  25. PATH_SUFFIXES include)
  26. find_library(
  27. DETOURS_LIB
  28. NAMES ${_DETOURS_LIBRARIES} detours
  29. HINTS ENV DETOURS_PATH ${DETOURS_PATH} ${CMAKE_SOURCE_DIR}/${DETOURS_PATH}
  30. ${_DETOURS_LIBRARY_DIRS}
  31. PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib
  32. PATH_SUFFIXES
  33. lib${_lib_suffix}
  34. lib
  35. libs${_lib_suffix}
  36. libs
  37. bin${_lib_suffix}
  38. bin
  39. ../lib${_lib_suffix}
  40. ../lib
  41. ../libs${_lib_suffix}
  42. ../libs
  43. ../bin${_lib_suffix}
  44. ../bin)
  45. include(FindPackageHandleStandardArgs)
  46. find_package_handle_standard_args(Detours DEFAULT_MSG DETOURS_LIB
  47. DETOURS_INCLUDE_DIR)
  48. mark_as_advanced(DETOURS_INCLUDE_DIR DETOURS_LIB)
  49. if(DETOURS_FOUND)
  50. set(DETOURS_INCLUDE_DIRS ${DETOURS_INCLUDE_DIR})
  51. set(DETOURS_LIBRARIES ${DETOURS_LIB})
  52. if(NOT TARGET Detours::Detours)
  53. if(IS_ABSOLUTE "${DETOURS_LIBRARIES}")
  54. add_library(Detours::Detours UNKNOWN IMPORTED)
  55. set_target_properties(Detours::Detours PROPERTIES IMPORTED_LOCATION
  56. "${DETOURS_LIBRARIES}")
  57. else()
  58. add_library(Detours::Detours INTERFACE IMPORTED)
  59. set_target_properties(Detours::Detours PROPERTIES IMPORTED_LIBNAME
  60. "${DETOURS_LIBRARIES}")
  61. endif()
  62. set_target_properties(
  63. Detours::Detours PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
  64. "${DETOURS_INCLUDE_DIRS}")
  65. endif()
  66. endif()