From 9c925e855d4516a61325c56aaa01b35a7ad03293 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 6 Aug 2019 17:35:12 +0200 Subject: [PATCH] Added fallback for incomplete Poco distributions. --- src/cli/CMakeLists.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 540d4fa..ab5543c 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -13,7 +13,27 @@ target_include_directories(${PROJECT_NAME}-cli PRIVATE "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(${PROJECT_NAME}-cli - PRIVATE ${PROJECT_NAME} Poco::Util) + PRIVATE ${PROJECT_NAME}) + +# If no Poco*Config.cmake recipes are found, look for headers in standard dirs. +if(PocoUtil_FOUND) + target_link_libraries(${PROJECT_NAME}-cli + PRIVATE Poco::Util) +else() + find_file(Poco_h NAMES "Poco/Poco.h" + PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") + + if("${Poco_h}" STREQUAL "Poco_h-NOTFOUND") + message(FATAL_ERROR "Could not find POCO.") + else() + message(WARNING + "Your distribution of POCO doesn't contain the *Config.cmake recipes, " + "but the files seem to be in the standard directories. " + "Let's hope this works.") + target_link_libraries(${PROJECT_NAME}-cli + PRIVATE PocoUtil) + endif() +endif() install(TARGETS ${PROJECT_NAME}-cli DESTINATION ${CMAKE_INSTALL_BINDIR})