FindGFlags.cmake 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #COPYRIGHT
  2. #
  3. #All contributions by the University of California:
  4. #Copyright (c) 2014-2017 The Regents of the University of California (Regents)
  5. #All rights reserved.
  6. #
  7. #All other contributions:
  8. #Copyright (c) 2014-2017, the respective contributors
  9. #All rights reserved.
  10. #
  11. #Caffe uses a shared copyright model: each contributor holds copyright over
  12. #their contributions to Caffe. The project versioning records all such
  13. #contribution and copyright details. If a contributor wants to further mark
  14. #their specific copyright on a particular contribution, they should indicate
  15. #their copyright solely in the commit message of the change when it is
  16. #committed.
  17. #
  18. #LICENSE
  19. #
  20. #Redistribution and use in source and binary forms, with or without
  21. #modification, are permitted provided that the following conditions are met:
  22. #
  23. #1. Redistributions of source code must retain the above copyright notice, this
  24. # list of conditions and the following disclaimer.
  25. #2. Redistributions in binary form must reproduce the above copyright notice,
  26. # this list of conditions and the following disclaimer in the documentation
  27. # and/or other materials provided with the distribution.
  28. #
  29. #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  30. #ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  31. #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  32. #DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  33. #ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  34. #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  35. #LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  36. #ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. #
  40. #CONTRIBUTION AGREEMENT
  41. #
  42. #By contributing to the BVLC/caffe repository through pull-request, comment,
  43. #or otherwise, the contributor releases their content to the
  44. #license and copyright terms herein.
  45. #
  46. # - Try to find GFLAGS
  47. #
  48. # The following variables are optionally searched for defaults
  49. # GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found
  50. #
  51. # The following are set after configuration is done:
  52. # GFLAGS_FOUND
  53. # GFLAGS_INCLUDE_DIRS
  54. # GFLAGS_LIBRARIES
  55. # GFLAGS_LIBRARYRARY_DIRS
  56. include(FindPackageHandleStandardArgs)
  57. set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")
  58. # We are testing only a couple of files in the include directories
  59. if(WIN32)
  60. find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
  61. PATHS ${GFLAGS_ROOT_DIR}/src/windows)
  62. else()
  63. find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
  64. PATHS ${GFLAGS_ROOT_DIR})
  65. endif()
  66. if(MSVC)
  67. find_library(GFLAGS_LIBRARY_RELEASE
  68. NAMES libgflags
  69. PATHS ${GFLAGS_ROOT_DIR}
  70. PATH_SUFFIXES Release)
  71. find_library(GFLAGS_LIBRARY_DEBUG
  72. NAMES libgflags-debug
  73. PATHS ${GFLAGS_ROOT_DIR}
  74. PATH_SUFFIXES Debug)
  75. set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG})
  76. else()
  77. find_library(GFLAGS_LIBRARY gflags)
  78. endif()
  79. find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
  80. if(GFLAGS_FOUND)
  81. set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
  82. set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY})
  83. message(STATUS "Found gflags (include: ${GFLAGS_INCLUDE_DIR}, library: ${GFLAGS_LIBRARY})")
  84. mark_as_advanced(GFLAGS_LIBRARY_DEBUG GFLAGS_LIBRARY_RELEASE
  85. GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR)
  86. else()
  87. message(FATAL_ERROR "gflags not found!")
  88. endif()