FindMariaDBClient.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # https://github.com/viaduck/cmake-modules/blob/master/FindMariaDBClient.cmake
  2. # MIT License
  3. #
  4. # Copyright (c) 2018 The ViaDuck Project
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in all
  14. # copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. # SOFTWARE.
  23. #
  24. # - Try to find MariaDB client library. This matches both the "old" client library and the new C connector.
  25. # Once found this will define
  26. # MariaDBClient_FOUND - System has MariaDB client library
  27. # MariaDBClient_INCLUDE_DIRS - The MariaDB client library include directories
  28. # MariaDBClient_LIBRARIES - The MariaDB client library
  29. # includes
  30. find_path(
  31. MariaDBClient_INCLUDE_DIR
  32. NAMES mysql.h
  33. PATH_SUFFIXES mariadb mysql
  34. )
  35. # library
  36. set(BAK_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  37. set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
  38. find_library(
  39. MariaDBClient_LIBRARY
  40. NAMES mariadb libmariadb mariadbclient libmariadbclient mysqlclient libmysqlclient
  41. PATH_SUFFIXES mariadb mysql
  42. )
  43. set(CMAKE_FIND_LIBRARY_SUFFIXES ${BAK_CMAKE_FIND_LIBRARY_SUFFIXES})
  44. include(FindPackageHandleStandardArgs)
  45. find_package_handle_standard_args(
  46. MariaDBClient DEFAULT_MSG MariaDBClient_LIBRARY MariaDBClient_INCLUDE_DIR
  47. )
  48. if(MariaDBClient_FOUND)
  49. if(NOT TARGET MariaDBClient::MariaDBClient)
  50. add_library(MariaDBClient::MariaDBClient UNKNOWN IMPORTED)
  51. set_target_properties(
  52. MariaDBClient::MariaDBClient
  53. PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MariaDBClient_INCLUDE_DIR}"
  54. IMPORTED_LOCATION "${MariaDBClient_LIBRARY}"
  55. )
  56. endif()
  57. endif()
  58. mark_as_advanced(MariaDBClient_INCLUDE_DIR MariaDBClient_LIBRARY)
  59. set(MariaDBClient_LIBRARIES ${MariaDBClient_LIBRARY})
  60. set(MariaDBClient_INCLUDE_DIRS ${MariaDBClient_INCLUDE_DIR})