FindMHD.cmake.save 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # Find microhttpd
  2. #
  3. # Find the microhttpd includes and library
  4. #
  5. # if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
  6. #
  7. # This module defines
  8. # MHD_INCLUDE_DIRS, where to find header, etc.
  9. # MHD_LIBRARIES, the libraries needed to use jsoncpp.
  10. # MHD_FOUND, If false, do not try to use jsoncpp.
  11. find_path(
  12. MHD_INCLUDE_DIR
  13. NAMES microhttpd.h
  14. DOC "microhttpd include dir"
  15. )
  16. find_library(
  17. MHD_LIBRARY
  18. NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
  19. DOC "microhttpd library"
  20. )
  21. set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
  22. set(MHD_LIBRARIES ${MHD_LIBRARY})
  23. # debug library on windows
  24. # same naming convention as in QT (appending debug library with d)
  25. # boost is using the same "hack" as us with "optimized" and "debug"
  26. # official MHD project actually uses _d suffix
  27. if (MSVC)
  28. find_library(
  29. MHD_LIBRARY_DEBUG
  30. NAMES microhttpd_d microhttpd-10_d libmicrohttpd_d libmicrohttpd-dll_d
  31. DOC "mhd debug library"
  32. )
  33. set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG})
  34. # prepare dlls
  35. string(REPLACE ".lib" ".dll" MHD_DLL "${MHD_LIBRARY}")
  36. string(REPLACE "/lib/" "/bin/" MHD_DLL "${MHD_DLL}")
  37. string(REPLACE ".lib" ".dll" MHD_DLL_DEBUG "${MHD_LIBRARY_DEBUG}")
  38. string(REPLACE "/lib/" "/bin/" MHD_DLL_DEBUG "${MHD_DLL_DEBUG}")
  39. set(MHD_DLLS optimized ${MHD_DLL} debug "${MHD_DLL_DEBUG}")
  40. endif()
  41. include(FindPackageHandleStandardArgs)
  42. find_package_handle_standard_args(mhd DEFAULT_MSG
  43. MHD_LIBRARY MHD_INCLUDE_DIR)
  44. mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)
  45. # Find microhttpd
  46. #
  47. # Find the microhttpd includes and library
  48. #
  49. # if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
  50. #
  51. # This module defines
  52. # MHD_INCLUDE_DIRS, where to find header, etc.
  53. # MHD_LIBRARIES, the libraries needed to use jsoncpp.
  54. # MHD_FOUND, If false, do not try to use jsoncpp.
  55. find_path(
  56. MHD_INCLUDE_DIR
  57. NAMES microhttpd.h
  58. DOC "microhttpd include dir"
  59. )
  60. find_library(
  61. MHD_LIBRARY
  62. NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
  63. DOC "microhttpd library"
  64. )
  65. set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
  66. set(MHD_LIBRARIES ${MHD_LIBRARY})
  67. include(FindPackageHandleStandardArgs)
  68. find_package_handle_standard_args(mhd DEFAULT_MSG
  69. MHD_LIBRARY MHD_INCLUDE_DIR)
  70. #mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)
  71. message(STATUS "FindMicrohttpd check")
  72. #include(FindPkgConfig)
  73. #if ( PKG_CONFIG_FOUND )
  74. # pkg_check_modules (PC_MICROHTTPD microhttpd)
  75. # set(MICROHTTPD_DEFINITIONS ${PC_MICROHTTPD_CFLAGS_OTHER})
  76. ## message(STATUS "micrhttpd checked:" ${MICROHTTPD_DEFINITIONS})
  77. #endif(PKG_CONFIG_FOUND)
  78. # this does nothing
  79. # set defaults
  80. SET(_microhttpd_HOME "/usr/local")
  81. SET(_microhttpd_INCLUDE_SEARCH_DIRS
  82. ${CMAKE_INCLUDE_PATH}
  83. /usr/local/include
  84. /usr/include
  85. )
  86. SET(_microhttpd_LIBRARIES_SEARCH_DIRS
  87. ${CMAKE_LIBRARY_PATH}
  88. /usr/local/lib
  89. /usr/lib
  90. )
  91. ##
  92. if( "${MICROHTTPD_HOME}" STREQUAL "")
  93. if("" MATCHES "$ENV{MICROHTTPD_HOME}")
  94. message(STATUS "MICROHTTPD_HOME env is not set, setting it to /usr/local")
  95. set (MICROHTTPD_HOME ${_microhttpd_HOME})
  96. else("" MATCHES "$ENV{MICROHTTPD_HOME}")
  97. set (MICROHTTPD_HOME "$ENV{MICROHTTPD_HOME}")
  98. endif("" MATCHES "$ENV{MICROHTTPD_HOME}")
  99. else( "${MICROHTTPD_HOME}" STREQUAL "")
  100. message(STATUS "MICROHTTPD_HOME is not empty: \"${MICROHTTPD_HOME}\"")
  101. endif( "${MICROHTTPD_HOME}" STREQUAL "")
  102. ##
  103. message(STATUS "Looking for microhttpd in ${MICROHTTPD_HOME}")
  104. IF( NOT ${MICROHTTPD_HOME} STREQUAL "" )
  105. SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
  106. SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
  107. SET(_microhttpd_HOME ${MICROHTTPD_HOME})
  108. message(STATUS "setting search dirs")
  109. ENDIF( NOT ${MICROHTTPD_HOME} STREQUAL "" )
  110. IF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )
  111. SET(_microhttpd_INCLUDE_SEARCH_DIRS $ENV{MICROHTTPD_INCLUDEDIR} ${_microhttpd_INCLUDE_SEARCH_DIRS})
  112. ENDIF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )
  113. IF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )
  114. SET(_microhttpd_LIBRARIES_SEARCH_DIRS $ENV{MICROHTTPD_LIBRARYDIR} ${_microhttpd_LIBRARIES_SEARCH_DIRS})
  115. ENDIF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )
  116. IF( MICROHTTPD_HOME )
  117. SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
  118. SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
  119. SET(_microhttpd_HOME ${MICROHTTPD_HOME})
  120. message(STATUS "microhttpdhome")
  121. ENDIF( MICROHTTPD_HOME )
  122. # find the include files
  123. FIND_PATH(MICROHTTPD_INCLUDE_DIR microhttpd.h
  124. HINTS
  125. ${_microhttpd_INCLUDE_SEARCH_DIRS}
  126. ${PC_MICROHTTPD_INCLUDEDIR}
  127. ${PC_MICROHTTPD_INCLUDE_DIRS}
  128. ${CMAKE_INCLUDE_PATH}
  129. )
  130. IF( NOT $ENV{MICROHTTPD_INCLUDE_DIR} STREQUAL "" )
  131. message(STATUS, "are we here?")
  132. ENDIF( NOT $ENV{MICROHTTPD_INCLUDE_DIR} STREQUAL "" )
  133. # locate the library
  134. SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.a)
  135. SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.so)
  136. FIND_LIBRARY(MICROHTTPD_LIBRARY NAMES ${MICROHTTPD_LIBRARY_NAMES}
  137. HINTS
  138. ${_microhttpd_LIBRARIES_SEARCH_DIRS}
  139. ${PC_MICROHTTPD_LIBDIR}
  140. ${PC_MICROHTTPD_LIBRARY_DIRS}
  141. )
  142. # if the include and the program are found then we have it
  143. IF(MICROHTTPD_INCLUDE_DIR AND MICROHTTPD_LIBRARY)
  144. SET(MICROHTTPD_FOUND "YES")
  145. message(STATUS "microhttpdhome found")
  146. ENDIF(MICROHTTPD_INCLUDE_DIR AND MICROHTTPD_LIBRARY)
  147. # list(APPEND MICROHTTPD_LIBRARY " -lrt")
  148. # ????
  149. message(STATUS "microhttpdhome library" ${MICROHTTPD_LIBRARY})
  150. MARK_AS_ADVANCED(
  151. MICROHTTPD_FOUND
  152. MICROHTTPD_LIBRARY
  153. MICROHTTPD_INCLUDE_DIR
  154. )
  155. #add_library(jsonrpc::mhd STATIC IMPORTED)
  156. #set_property(TARGET jsonrpc::mhd PROPERTY IMPORTED_LOCATION ${MICROHTTPD_LIBRARY})
  157. link_libraries(${MICROHTTPD_LIBRARIES})