FindGlog.cmake 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Glog
  47. #
  48. # The following variables are optionally searched for defaults
  49. # GLOG_ROOT_DIR: Base directory where all GLOG components are found
  50. #
  51. # The following are set after configuration is done:
  52. # GLOG_FOUND
  53. # GLOG_INCLUDE_DIRS
  54. # GLOG_LIBRARIES
  55. # GLOG_LIBRARYRARY_DIRS
  56. include(FindPackageHandleStandardArgs)
  57. set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")
  58. if(WIN32)
  59. find_path(GLOG_INCLUDE_DIR glog/logging.h
  60. PATHS ${GLOG_ROOT_DIR}/src/windows)
  61. else()
  62. find_path(GLOG_INCLUDE_DIR glog/logging.h
  63. PATHS ${GLOG_ROOT_DIR})
  64. endif()
  65. if(MSVC)
  66. find_library(GLOG_LIBRARY_RELEASE libglog_static
  67. PATHS ${GLOG_ROOT_DIR}
  68. PATH_SUFFIXES Release)
  69. find_library(GLOG_LIBRARY_DEBUG libglog_static
  70. PATHS ${GLOG_ROOT_DIR}
  71. PATH_SUFFIXES Debug)
  72. set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG})
  73. else()
  74. find_library(GLOG_LIBRARY glog
  75. PATHS ${GLOG_ROOT_DIR}
  76. PATH_SUFFIXES lib lib64)
  77. endif()
  78. find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY)
  79. if(GLOG_FOUND)
  80. set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
  81. set(GLOG_LIBRARIES ${GLOG_LIBRARY})
  82. message(STATUS "Found glog (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})")
  83. mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG
  84. GLOG_LIBRARY GLOG_INCLUDE_DIR)
  85. endif()