diff --git a/CMakeLists.txt b/CMakeLists.txt index a202e10..c3d2d0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.11) project(qhttpengine) 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_NAME "QHttpEngine") @@ -13,7 +14,7 @@ set(PROJECT_VERSION_MINOR 1) set(PROJECT_VERSION_PATCH 0) set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -find_package(Qt5Network REQUIRED) +find_package(Qt5Network 5.1 REQUIRED) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) @@ -24,6 +25,10 @@ if(BUILD_DOC) add_subdirectory(doc) endif() +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + if(BUILD_TESTS) enable_testing() add_subdirectory(tests) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..7afee5d --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(Qt5Gui 5.1) + +set(EXAMPLES_INSTALL_DIR lib/qhttpengine/examples) + +if(Qt5Gui_FOUND) + add_subdirectory(fileserver) +endif() diff --git a/examples/fileserver/CMakeLists.txt b/examples/fileserver/CMakeLists.txt new file mode 100644 index 0000000..fe3f467 --- /dev/null +++ b/examples/fileserver/CMakeLists.txt @@ -0,0 +1,19 @@ +set(SRC + main.cpp +) + +add_executable(fileserver WIN32 ${SRC}) +qt5_use_modules(fileserver Widgets) +target_link_libraries(fileserver qhttpengine) + +set_target_properties(fileserver PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" +) + +install(TARGETS fileserver + RUNTIME DESTINATION ${EXAMPLES_INSTALL_DIR}/fileserver +) + +install(FILES ${SRC} + DESTINATION ${EXAMPLES_INSTALL_DIR}/fileserver +) diff --git a/examples/fileserver/main.cpp b/examples/fileserver/main.cpp new file mode 100644 index 0000000..e08563b --- /dev/null +++ b/examples/fileserver/main.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Nathan Osman + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include + +int main(int argc, char * argv[]) +{ + QApplication a(argc, argv); + + return a.exec(); +}