SgMHD.cmake 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #.rst:
  2. # SgMHD
  3. # -----
  4. #
  5. # Build libmicrohttpd.
  6. #
  7. # Build libmicrohttpd from Sagui building.
  8. #
  9. # ::
  10. #
  11. # MHD_INCLUDE_DIR - Directory of includes.
  12. # MHD_ARCHIVE_LIB - AR archive library.
  13. # _
  14. # ___ __ _ __ _ _ _(_)
  15. # / __|/ _` |/ _` | | | | |
  16. # \__ \ (_| | (_| | |_| | |
  17. # |___/\__,_|\__, |\__,_|_|
  18. # |___/
  19. #
  20. # Cross-platform library which helps to develop web servers or frameworks.
  21. #
  22. # Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
  23. #
  24. # Sagui library is free software; you can redistribute it and/or
  25. # modify it under the terms of the GNU Lesser General Public
  26. # License as published by the Free Software Foundation; either
  27. # version 2.1 of the License, or (at your option) any later version.
  28. #
  29. # Sagui library is distributed in the hope that it will be useful,
  30. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  32. # Lesser General Public License for more details.
  33. #
  34. # You should have received a copy of the GNU Lesser General Public
  35. # License along with Sagui library; if not, write to the Free Software
  36. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  37. #
  38. if(__SG_MHD_INCLUDED)
  39. return()
  40. endif()
  41. set(__SG_MHD_INCLUDED ON)
  42. if(CMAKE_VERSION VERSION_GREATER "3.23")
  43. cmake_policy(SET CMP0135 NEW)
  44. endif()
  45. set(MHD_NAME "libmicrohttpd")
  46. set(MHD_VER "1.0.1")
  47. set(MHD_FULL_NAME "${MHD_NAME}-${MHD_VER}")
  48. set(MHD_URL "https://ftp.gnu.org/gnu/libmicrohttpd/${MHD_FULL_NAME}.tar.gz")
  49. set(MHD_URL_MIRROR "https://ftp.gnu.org/gnu/libmicrohttpd/${MHD_FULL_NAME}.tar.gz")
  50. set(MHD_SHA256 "a89e09fc9b4de34dde19f4fcb4faaa1ce10299b9908db1132bbfa1de47882b94")
  51. set(_libdir ${CMAKE_BINARY_DIR}/${MHD_FULL_NAME}/lib)
  52. if(${CMAKE_VERSION} VERSION_LESS "3.7")
  53. unset(MHD_URL_MIRROR)
  54. endif()
  55. if(SG_HTTPS_SUPPORT AND GNUTLS_FOUND)
  56. set(_enable_https "yes")
  57. else()
  58. set(_enable_https "no")
  59. endif()
  60. set(MHD_OPTIONS
  61. --libdir=${_libdir}
  62. --enable-static=yes
  63. --enable-shared=no
  64. --enable-messages=yes
  65. --enable-https=${_enable_https}
  66. --enable-asserts=no
  67. --enable-coverage=no
  68. --disable-httpupgrade
  69. --disable-dauth
  70. --disable-doc
  71. --disable-examples
  72. --disable-curl)
  73. unset(_enable_https)
  74. if(MINGW)
  75. set(MHD_OPTIONS ${MHD_OPTIONS} --quiet)
  76. set(_manifest_tool MANIFEST_TOOL=:)
  77. set(_log_configure OFF)
  78. elseif(UNIX)
  79. #if (CMAKE_POSITION_INDEPENDENT_CODE)
  80. set(MHD_OPTIONS ${MHD_OPTIONS} --with-pic)
  81. #endif ()
  82. set(_log_configure ON)
  83. else()
  84. set(_log_configure ON)
  85. endif()
  86. ExternalProject_Add(
  87. ${MHD_FULL_NAME}
  88. URL ${MHD_URL} ${MHD_URL_MIRROR}
  89. URL_HASH SHA256=${MHD_SHA256}
  90. TIMEOUT 15
  91. DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/lib
  92. PREFIX ${CMAKE_BINARY_DIR}/${MHD_FULL_NAME}
  93. SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/${MHD_FULL_NAME}
  94. CONFIGURE_COMMAND
  95. <SOURCE_DIR>/configure ${CC} ${_manifest_tool} --host=${CMAKE_C_MACHINE}
  96. --prefix=<INSTALL_DIR> ${MHD_OPTIONS}
  97. BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
  98. INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
  99. LOG_DOWNLOAD ON
  100. LOG_CONFIGURE ${_log_configure}
  101. LOG_BUILD ON
  102. LOG_INSTALL ON)
  103. ExternalProject_Get_Property(${MHD_FULL_NAME} INSTALL_DIR)
  104. set(MHD_INCLUDE_DIR ${INSTALL_DIR}/include)
  105. set(MHD_ARCHIVE_LIB ${INSTALL_DIR}/lib/${MHD_NAME}.a)
  106. unset(_libdir)
  107. unset(INSTALL_DIR)