From fe9d3cbc63fbe10cb739df5a3d2710b8854d4130 Mon Sep 17 00:00:00 2001 From: Florian Meinicke Date: Fri, 11 Sep 2020 09:34:23 +0200 Subject: [PATCH] Add CMake project for example --- CMakeLists.txt | 4 ++++ README.md | 3 +++ example/CMakeLists.txt | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 example/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f757fb..4d9c27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,3 +144,7 @@ install(TARGETS QtZeroConf LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/QtZeroConf ) + +if(BUILD_EXAMPLE) + add_subdirectory(example) +endif() diff --git a/README.md b/README.md index 6847cd8..ce5285d 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ QZeroConf can be built directly into your project if your project is [LGPL3](htt Use `BUILD_SHARED_LIBS` to control whether QZeroConf should be built as static (`-DBUILD_SHARED_LIBS=OFF`) or as shared (`-DBUILD_SHARED_LIBS=ON`) library. The default is `OFF`. +You can also build the included example project by setting `BUILD_EXAMPLE` to `ON`. +The default for this is `OFF` + ### API #### Service Publishing diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..1216105 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,25 @@ +project(QtZeroConfExample) +cmake_minimum_required(VERSION 2.8.11) + +find_package(Qt5 COMPONENTS Gui Widgets REQUIRED) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +# Find QtZeroConf library if we're building standalone +if(NOT TARGET QtZeroConf) + find_package(QtZeroConf CONFIG REQUIRED) +endif() + +add_executable(QtZeroConfExample + window.h + window.cpp + main.cpp +) + +target_link_libraries(QtZeroConfExample + QtZeroConf + Qt5::Gui Qt5::Widgets +)