Update build scripts.

This commit is contained in:
Nathan Osman
2017-07-07 21:22:19 -07:00
parent 4866f85380
commit 6fea4fbd61
8 changed files with 54 additions and 49 deletions

View File

@@ -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()

View File

@@ -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}"

View File

@@ -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}"

View File

@@ -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}"

View File

@@ -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,13 +39,9 @@ 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
set_target_properties(qhttpengine PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
DEFINE_SYMBOL QT_NO_SIGNALS_SLOTS_KEYWORDS
@@ -40,37 +51,38 @@ set_target_properties(QHttpEngine PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_include_directories(QHttpEngine PUBLIC
target_include_directories(qhttpengine PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>"
)
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"
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"
)

View File

@@ -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}
)

View File

@@ -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)