From 7006652c1009742b505bb865e2d799b2ad3d74b2 Mon Sep 17 00:00:00 2001 From: Matthias Gabriel Date: Mon, 6 Mar 2017 09:24:12 +0100 Subject: Allow external uriparser to be used --- CMakeLists.txt | 27 ++++++++++++++++++--------- contrib/cmake/Finduriparser.cmake | 13 +++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 contrib/cmake/Finduriparser.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index bd14bda..8a5bbbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,16 +304,23 @@ if (UNIX) list (APPEND USCXML_CORE_LIBS "pthread") endif() + # uriparser -include("${CMAKE_MODULE_PATH}/BuildURIParser.cmake") -message(STATUS "Did not look for UriParser") -message(STATUS "--> will download and compile") -if (URIPARSER_BUILT) - include_directories(${URIPARSER_INCLUDE_DIR}) - list (APPEND USCXML_CORE_LIBS ${URIPARSER_LIBRARY}) - list (APPEND USCXML_PREREQS uriparser) +find_package(uriparser) +if(URIPARSER_FOUND) + include_directories(${URIPARSER_INCLUDE_DIRS}) + list (APPEND USCXML_CORE_LIBS ${URIPARSER_LIBRARIES}) else() - message(FATAL_ERROR "Could not build uriparser") + message(STATUS "Did not find UriParser") + message(STATUS "--> will download and compile") + include("${CMAKE_MODULE_PATH}/BuildURIParser.cmake") + if (URIPARSER_BUILT) + include_directories(${URIPARSER_INCLUDE_DIR}) + list (APPEND USCXML_CORE_LIBS ${URIPARSER_LIBRARY}) + list (APPEND USCXML_PREREQS uriparser) + else() + message(FATAL_ERROR "Could not find or build uriparser") + endif() endif() @@ -437,7 +444,9 @@ endif() set_property(TARGET uscxml PROPERTY CXX_STANDARD 11) set_property(TARGET uscxml PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET uscxml PROPERTY SOVERSION ${USCXML_VERSION}) -add_dependencies(uscxml ${USCXML_PREREQS}) +if (USCXML_PREREQS) + add_dependencies(uscxml ${USCXML_PREREQS}) +endif() install_library(TARGETS uscxml) diff --git a/contrib/cmake/Finduriparser.cmake b/contrib/cmake/Finduriparser.cmake new file mode 100644 index 0000000..5c0668f --- /dev/null +++ b/contrib/cmake/Finduriparser.cmake @@ -0,0 +1,13 @@ +find_path(URIPARSER_INCLUDE_DIR NAMES uriparser/UriBase.h) +find_library(URIPARSER_LIBRARY NAMES uriparser) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(URIPARSER DEFAULT_MSG URIPARSER_LIBRARY URIPARSER_INCLUDE_DIR) + +if (URIPARSER_FOUND) + set(URIPARSER_LIBRARIES ${URIPARSER_LIBRARY}) + set(URIPARSER_INCLUDE_DIRS ${URIPARSER_INCLUDE_DIR}) +endif() + +mark_as_advanced(URIPARSER_INCLUDE_DIR) +mark_as_advanced(URIPARSER_LIBRARY) -- cgit v0.12