FindLevelDB.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2017 Google
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. set(binary_dir ${FIREBASE_BINARY_DIR}/src/leveldb)
  15. find_path(
  16. LEVELDB_INCLUDE_DIR leveldb/db.h
  17. HINTS
  18. $ENV{LEVELDB_ROOT}/include
  19. ${LEVELDB_ROOT}/include
  20. ${binary_dir}/include
  21. PATH_SUFFIXES leveldb
  22. )
  23. find_library(
  24. LEVELDB_LIBRARY
  25. NAMES leveldb
  26. HINTS
  27. $ENV{LEVELDB_ROOT}/lib
  28. ${LEVELDB_ROOT}/lib
  29. ${binary_dir}/out-static
  30. )
  31. include(FindPackageHandleStandardArgs)
  32. find_package_handle_standard_args(
  33. LevelDB
  34. DEFAULT_MSG
  35. LEVELDB_INCLUDE_DIR
  36. LEVELDB_LIBRARY
  37. )
  38. if(LEVELDB_FOUND)
  39. set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR})
  40. set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY})
  41. if (NOT TARGET LevelDB::LevelDB)
  42. add_library(LevelDB::LevelDB UNKNOWN IMPORTED)
  43. set_target_properties(
  44. LevelDB::LevelDB PROPERTIES
  45. INTERFACE_INCLUDE_DIRECTORIES ${LEVELDB_INCLUDE_DIR}
  46. IMPORTED_LOCATION ${LEVELDB_LIBRARY}
  47. )
  48. endif()
  49. endif(LEVELDB_FOUND)