fix: properly lookup winsock in imported project

This commit is contained in:
Gregor Jasny 2020-10-04 13:28:54 +02:00
parent 8e24345696
commit ba5f5968ea
3 changed files with 43 additions and 0 deletions

View File

@ -603,6 +603,9 @@ install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibDL.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibRt.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWinSock.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT civetweb-cmake-config
)

View File

@ -3,4 +3,24 @@ include(CMakeFindDependencyMacro)
set_and_check(civetweb_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
find_dependency(Threads)
set(CIVETWEB_SAVED_MODULE_PATH ${CMAKE_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
if(@LOOKUP_LIBDL@)
find_dependency(LibDl)
endif()
if(@LOOKUP_LIBRT@)
find_dependency(LibRt)
endif()
if(@LOOKUP_WINSOCK@)
find_dependency(WinSock)
endif()
set(CMAKE_MODULE_PATH ${CIVETWEB_SAVED_MODULE_PATH})
unset(CIVETWEB_SAVED_MODULE_PATH)
include("${CMAKE_CURRENT_LIST_DIR}/civetweb-targets.cmake")

View File

@ -322,3 +322,23 @@ if (CIVETWEB_ENABLE_CXX)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT civetweb-cpp)
endif()
# Configure lookup behavior in civetweb config
if(LIBDL_FOUND)
set(LOOKUP_LIBDL TRUE PARENT_SCOPE)
else()
set(LOOKUP_LIBDL FALSE PARENT_SCOPE)
endif()
if(LIBRT_FOUND)
set(LOOKUP_LIBRT TRUE PARENT_SCOPE)
else()
set(LOOKUP_LIBRT FALSE PARENT_SCOPE)
endif()
if(WINSOCK_FOUND)
set(LOOKUP_WINSOCK TRUE PARENT_SCOPE)
else()
set(LOOKUP_WINSOCK FALSE PARENT_SCOPE)
endif()