CMake: find_package(asio) if available
This commit is contained in:
parent
84170850f3
commit
b6783d40be
1 changed files with 13 additions and 3 deletions
|
|
@ -24,10 +24,20 @@ target_link_libraries(simple-web-server INTERFACE Threads::Threads)
|
||||||
|
|
||||||
if(USE_STANDALONE_ASIO)
|
if(USE_STANDALONE_ASIO)
|
||||||
target_compile_definitions(simple-web-server INTERFACE ASIO_STANDALONE)
|
target_compile_definitions(simple-web-server INTERFACE ASIO_STANDALONE)
|
||||||
find_path(ASIO_PATH asio.hpp)
|
# There is no canonical way to use Asio from CMake.
|
||||||
if(NOT ASIO_PATH)
|
# In particular, Asio does not support CMake natively.
|
||||||
message(FATAL_ERROR "Standalone Asio not found")
|
# However, Conan and Vcpkg do provide CMake support on their own.
|
||||||
|
# Prefer the CMake target and fall back to finding asio.hpp.
|
||||||
|
if(NOT TARGET asio::asio)
|
||||||
|
find_package(asio)
|
||||||
|
endif()
|
||||||
|
if(TARGET asio::asio)
|
||||||
|
target_link_libraries(simple-web-server INTERFACE asio::asio)
|
||||||
else()
|
else()
|
||||||
|
find_path(ASIO_PATH asio.hpp)
|
||||||
|
if(NOT ASIO_PATH)
|
||||||
|
message(FATAL_ERROR "Standalone Asio not found")
|
||||||
|
endif()
|
||||||
target_include_directories(simple-web-server SYSTEM INTERFACE ${ASIO_PATH})
|
target_include_directories(simple-web-server SYSTEM INTERFACE ${ASIO_PATH})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue