FindDetours.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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} ${_DETOURS_INCLUDE_DIRS}
  23. PATHS /usr/include /usr/local/include /opt/local/include /sw/include
  24. PATH_SUFFIXES include)
  25. find_library(
  26. DETOURS_LIB
  27. NAMES ${_DETOURS_LIBRARIES} detours
  28. HINTS ENV DETOURS_PATH ${DETOURS_PATH} ${CMAKE_SOURCE_DIR}/${DETOURS_PATH} ${_DETOURS_LIBRARY_DIRS}
  29. PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib
  30. PATH_SUFFIXES
  31. lib${_lib_suffix}
  32. lib
  33. libs${_lib_suffix}
  34. libs
  35. bin${_lib_suffix}
  36. bin
  37. ../lib${_lib_suffix}
  38. ../lib
  39. ../libs${_lib_suffix}
  40. ../libs
  41. ../bin${_lib_suffix}
  42. ../bin)
  43. include(FindPackageHandleStandardArgs)
  44. find_package_handle_standard_args(Detours DEFAULT_MSG DETOURS_LIB DETOURS_INCLUDE_DIR)
  45. mark_as_advanced(DETOURS_INCLUDE_DIR DETOURS_LIB)
  46. if(DETOURS_FOUND)
  47. set(DETOURS_INCLUDE_DIRS ${DETOURS_INCLUDE_DIR})
  48. set(DETOURS_LIBRARIES ${DETOURS_LIB})
  49. if(NOT TARGET Detours::Detours)
  50. if(IS_ABSOLUTE "${DETOURS_LIBRARIES}")
  51. add_library(Detours::Detours UNKNOWN IMPORTED)
  52. set_target_properties(Detours::Detours PROPERTIES IMPORTED_LOCATION "${DETOURS_LIBRARIES}")
  53. else()
  54. add_library(Detours::Detours INTERFACE IMPORTED)
  55. set_target_properties(Detours::Detours PROPERTIES IMPORTED_LIBNAME "${DETOURS_LIBRARIES}")
  56. endif()
  57. set_target_properties(Detours::Detours PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${DETOURS_INCLUDE_DIRS}")
  58. endif()
  59. endif()