diff --git a/CMakeLists.txt b/CMakeLists.txt index db8f7cf..2536535 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,5 @@ cmake_minimum_required(VERSION 3.2.0) -project(QHttpEngine) - -if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3)) - cmake_policy(SET CMP0043 OLD) -endif() +project(qmdnsengine) set(PROJECT_NAME "QHttpEngine") set(PROJECT_DESCRIPTION "Simple and secure HTTP server for Qt applications") @@ -13,37 +9,35 @@ set(PROJECT_URL "https://github.com/nitroshare/qhttpengine") set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MINOR 0) set(PROJECT_VERSION_PATCH 0) -set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") - -option(BUILD_STATIC "Build a static library" OFF) - -option(BUILD_DOC "Build Doxygen documentation" OFF) -option(BUILD_EXAMPLES "Build the example applications" OFF) -option(BUILD_TESTS "Build the test suite" OFF) +set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) set(BIN_INSTALL_DIR bin CACHE STRING "Binary runtime installation directory relative to the install prefix") set(LIB_INSTALL_DIR lib CACHE STRING "Library installation directory relative to the install prefix") set(INCLUDE_INSTALL_DIR include CACHE STRING "Header installation directory relative to the install prefix") -set(CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}" CACHE STRING "CMake configuration installation directory") -set(DOC_INSTALL_DIR share/doc/${PROJECT_NAME} CACHE STRING "Documentation installation directory relative to the install prefix") -set(EXAMPLES_INSTALL_DIR "${LIB_INSTALL_DIR}/${PROJECT_NAME}/examples" CACHE STRING "Examples installation directory relative to the install prefix") + +set(DOC_INSTALL_DIR share/doc/qhttpengine CACHE STRING "Documentation installation directory relative to the install prefix") +set(EXAMPLES_INSTALL_DIR "${LIB_INSTALL_DIR}/qhttpengine/examples" CACHE STRING "Examples installation directory relative to the install prefix") find_package(Qt5Network 5.4 REQUIRED) -set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) add_subdirectory(src) +option(BUILD_DOC "Build Doxygen documentation" OFF) if(BUILD_DOC) + find_package(Doxygen REQUIRED) add_subdirectory(doc) endif() +option(BUILD_EXAMPLES "Build the example applications" OFF) if(BUILD_EXAMPLES) add_subdirectory(examples) endif() +option(BUILD_TESTS "Build the test suite" OFF) if(BUILD_TESTS) + find_package(Qt5Test 5.4 REQUIRED) enable_testing() add_subdirectory(tests) endif() diff --git a/examples/auth/CMakeLists.txt b/examples/auth/CMakeLists.txt index 47d1b8e..61563b1 100644 --- a/examples/auth/CMakeLists.txt +++ b/examples/auth/CMakeLists.txt @@ -1,6 +1,6 @@ # Client add_executable(authclient client.cpp) -target_link_libraries(authclient QHttpEngine) +target_link_libraries(authclient qhttpengine) target_compile_features(authclient PRIVATE cxx_lambdas) install(TARGETS authclient RUNTIME DESTINATION "${EXAMPLE_DIR}" diff --git a/examples/chatserver/CMakeLists.txt b/examples/chatserver/CMakeLists.txt index 5fdc805..3c7b270 100644 --- a/examples/chatserver/CMakeLists.txt +++ b/examples/chatserver/CMakeLists.txt @@ -6,7 +6,7 @@ set(SRC qt5_add_resources(QRC resources.qrc) add_executable(chatserver ${SRC} ${QRC}) -target_link_libraries(chatserver QHttpEngine) +target_link_libraries(chatserver qhttpengine) install(TARGETS chatserver RUNTIME DESTINATION "${EXAMPLE_DIR}" diff --git a/examples/fileserver/CMakeLists.txt b/examples/fileserver/CMakeLists.txt index f95a336..ed93afd 100644 --- a/examples/fileserver/CMakeLists.txt +++ b/examples/fileserver/CMakeLists.txt @@ -3,7 +3,7 @@ set(SRC ) add_executable(fileserver ${SRC}) -target_link_libraries(fileserver QHttpEngine) +target_link_libraries(fileserver qhttpengine) install(TARGETS fileserver RUNTIME DESTINATION "${EXAMPLE_DIR}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06873ff..362e6e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,22 @@ configure_file(qhttpengine_global.h.in "${CMAKE_CURRENT_BINARY_DIR}/qhttpengine_global.h") -file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/qhttpengine/*") -set(HEADERS "${HEADERS}" "${CMAKE_CURRENT_BINARY_DIR}/qhttpengine_global.h") +set(HEADERS + include/qhttpengine/basicauthmiddleware.h + include/qhttpengine/filesystemhandler.h + include/qhttpengine/handler.h + include/qhttpengine/ibytearray.h + include/qhttpengine/localauthmiddleware.h + include/qhttpengine/localfile.h + include/qhttpengine/middleware.h + include/qhttpengine/parser.h + include/qhttpengine/proxyhandler.h + include/qhttpengine/qiodevicecopier.h + include/qhttpengine/qobjecthandler.h + include/qhttpengine/range.h + include/qhttpengine/server.h + include/qhttpengine/socket.h + "${CMAKE_CURRENT_BINARY_DIR}/qhttpengine_global.h" +) set(SRC src/filesystemhandler.cpp @@ -24,53 +39,50 @@ if(WIN32) set(SRC ${SRC} "${CMAKE_CURRENT_BINARY_DIR}/resource.rc") endif() -if(BUILD_STATIC) - add_library(QHttpEngine STATIC ${HEADERS} ${SRC}) -else() - add_library(QHttpEngine SHARED ${HEADERS} ${SRC}) -endif() +add_library(qhttpengine SHARED ${HEADERS} ${SRC}) -set_target_properties(QHttpEngine PROPERTIES - CXX_STANDARD 11 +set_target_properties(qhttpengine PROPERTIES + CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON - DEFINE_SYMBOL QT_NO_SIGNALS_SLOTS_KEYWORDS - DEFINE_SYMBOL QHTTPENGINE_LIBRARY - PUBLIC_HEADER "${HEADERS}" - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} + DEFINE_SYMBOL QT_NO_SIGNALS_SLOTS_KEYWORDS + DEFINE_SYMBOL QHTTPENGINE_LIBRARY + PUBLIC_HEADER "${HEADERS}" + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} ) -target_include_directories(QHttpEngine PUBLIC +target_include_directories(qhttpengine PUBLIC "$" "$" "$" ) -target_link_libraries(QHttpEngine Qt5::Network) +target_link_libraries(qhttpengine Qt5::Network) -install(TARGETS QHttpEngine EXPORT QHttpEngine-export +install(TARGETS qhttpengine EXPORT qhttpengine-export RUNTIME DESTINATION "${BIN_INSTALL_DIR}" LIBRARY DESTINATION "${LIB_INSTALL_DIR}" ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" - PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}" + PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}/qhttpengine" ) -install(EXPORT QHttpEngine-export DESTINATION "${CMAKECONFIG_INSTALL_DIR}" - FILE ${PROJECT_NAME}Config.cmake +install(EXPORT qhttpengine-export + FILE qhttpengineConfig.cmake + DESTINATION "${LIB_INSTALL_DIR}/cmake/qmdnsengine" ) include(CMakePackageConfigHelpers) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - VERSION ${PROJECT_VERSION} +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/qhttpengineConfigVersion.cmake" + VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION "${CMAKECONFIG_INSTALL_DIR}" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qhttpengineConfigVersion.cmake" + DESTINATION "${LIB_INSTALL_DIR}/cmake/qmdnsengine" ) -configure_file(${PROJECT_NAME}.pc.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" +configure_file(qhttpengine.pc.in "${CMAKE_CURRENT_BINARY_DIR}/qhttpengine.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qhttpengine.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig" ) diff --git a/src/QHttpEngine.pc.in b/src/qhttpengine.pc.in similarity index 100% rename from src/QHttpEngine.pc.in rename to src/qhttpengine.pc.in diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7d3ad53..d209f9d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(Qt5Test 5.1 REQUIRED) - add_subdirectory(common) set(TESTS @@ -27,7 +25,8 @@ foreach(TEST ${TESTS}) CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON ) - target_link_libraries(${TEST} Qt5::Test QHttpEngine common) + target_include_directories(${TEST} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") + target_link_libraries(${TEST} Qt5::Test qhttpengine common) add_test(NAME ${TEST} COMMAND ${TEST} ) diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt index 0790596..1af0b65 100644 --- a/tests/common/CMakeLists.txt +++ b/tests/common/CMakeLists.txt @@ -8,4 +8,4 @@ set_target_properties(common PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON ) -target_link_libraries(common Qt5::Network QHttpEngine) +target_link_libraries(common Qt5::Network qhttpengine)