我正在尝试在CMake中为Visual Studio 2017配置一个项目,并给我一个错误:microhttpd NOT found
这是配置它时唯一的问题,我尝试将标志关闭并运行。我把这两行包括在内:
include_directories(${CMAKE_SOURCE_DIR}/lib)
include_directories(${CMAKE_SOURCE_DIR}/include)
我有包含的microhttpd.h和lib文件夹中的libmicrohttpd.lib。如何正确调整以下代码才能找到它(在CmakeLists.txt中查找此库的部分):
include_directories(${CMAKE_SOURCE_DIR}/lib)
include_directories(${CMAKE_SOURCE_DIR}/includes)
option(MICROHTTPD_REQUIRED "Enable or disable the requirement of microhttp (http deamon)" ON)
find_library(MHTD NAMES microhttpd)
if("${MHTD}" STREQUAL "MHTD-NOTFOUND")
if(MICROHTTPD_REQUIRED)
message(FATAL_ERROR "microhttpd NOT found: use `-DMICROHTTPD_REQUIRED=OFF` to build without http deamon support")
else()
message(STATUS "microhttpd NOT found: disable http server")
add_definitions("-DCONF_NO_HTTPD")
endif()
else()
set(LIBS ${LIBS} ${MHTD})
endif()
我是否需要使用include_directories以外的其他功能?
答案 0 :(得分:1)
应该是:
find_library(MHTD microhttpd "path/to/the/lib")
第二个参数是库文件名。第三个是图书馆所在的路径。