forked from jbagg/QtZeroConf
150
CMakeLists.txt
Normal file
150
CMakeLists.txt
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
project(QtZeroConf)
|
||||||
|
cmake_minimum_required(VERSION 2.8.11)
|
||||||
|
|
||||||
|
find_package(Qt5 COMPONENTS Core Network)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
set(PUBLIC_HEADERS
|
||||||
|
qzeroconfservice.h
|
||||||
|
qzeroconfglobal.h
|
||||||
|
qzeroconf.h
|
||||||
|
)
|
||||||
|
add_library(QtZeroConf
|
||||||
|
${PUBLIC_HEADERS}
|
||||||
|
qzeroconfservice.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(QtZeroConf PRIVATE QT_BUILD_ZEROCONF_LIB)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(QtZeroConf PUBLIC QZEROCONF_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
|
target_sources(QtZeroConf PRIVATE
|
||||||
|
avahi-qt/qt-watch_p.h
|
||||||
|
avahi-qt/qt-watch.cpp
|
||||||
|
avahiclient.cpp
|
||||||
|
)
|
||||||
|
list(APPEND ${PUBLIC_HEADERS}
|
||||||
|
avahi-qt/qt-watch.h
|
||||||
|
)
|
||||||
|
target_link_libraries(QtZeroConf PRIVATE avahi-client)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
target_sources(QtZeroConf PRIVATE
|
||||||
|
bonjour_p.h
|
||||||
|
bonjour.cpp
|
||||||
|
)
|
||||||
|
find_library(CoreServices CoreServices)
|
||||||
|
target_link_libraries(QtZeroConf PUBLIC ${CoreServices})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(QtZeroConf PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
target_link_libraries(QtZeroConf PUBLIC Qt5::Core Qt5::Network)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_sources(QtZeroConf PRIVATE
|
||||||
|
bonjour_p.h
|
||||||
|
bonjour.cpp
|
||||||
|
bonjour-sdk/dnssd_clientlib.c
|
||||||
|
bonjour-sdk/dnssd_clientstub.c
|
||||||
|
bonjour-sdk/dnssd_ipc.c
|
||||||
|
)
|
||||||
|
target_link_libraries(QtZeroConf PUBLIC ws2_32)
|
||||||
|
if(MSVC)
|
||||||
|
target_link_libraries(QtZeroConf PUBLIC "legacy_stdio_definitions.lib")
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(QtZeroConf PRIVATE
|
||||||
|
-DWIN32
|
||||||
|
-D_USRDLL
|
||||||
|
-DMDNS_DEBUGMSGS=0
|
||||||
|
-DWIN32_LEAN_AND_MEAN
|
||||||
|
-DUSE_TCP_LOOPBACK
|
||||||
|
-D_NO_CRT_STDIO_INLINE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE
|
||||||
|
-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1
|
||||||
|
-DNOT_HAVE_SA_LEN)
|
||||||
|
target_include_directories(QtZeroConf PRIVATE "${CMAKE_CURRENT_LIST_DIR}/bonjour-sdk")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
set(ACM "${CMAKE_CURRENT_LIST_DIR}/avahi-common")
|
||||||
|
set(ACR "${CMAKE_CURRENT_LIST_DIR}/avahi-core")
|
||||||
|
target_sources(QtZeroConf PRIVATE
|
||||||
|
qzeroconf.h
|
||||||
|
avahi-qt/qt-watch.h
|
||||||
|
avahi-qt/qt-watch_p.h
|
||||||
|
avahicore.cpp
|
||||||
|
avahi-qt/qt-watch.cpp
|
||||||
|
${ACM}/address.c
|
||||||
|
${ACM}/alternative.c
|
||||||
|
${ACM}/domain.c
|
||||||
|
${ACM}/error.c
|
||||||
|
${ACM}/i18n.c
|
||||||
|
${ACM}/malloc.c
|
||||||
|
${ACM}/rlist.c
|
||||||
|
${ACM}/simple-watch.c
|
||||||
|
${ACM}/strlst.c
|
||||||
|
${ACM}/thread-watch.c
|
||||||
|
${ACM}/timeval.c
|
||||||
|
${ACM}/utf8.c
|
||||||
|
${ACR}/addr-util.c
|
||||||
|
${ACR}/announce.c
|
||||||
|
${ACR}/browse.c
|
||||||
|
${ACR}/browse-dns-server.c
|
||||||
|
${ACR}/browse-domain.c
|
||||||
|
${ACR}/browse-service.c
|
||||||
|
${ACR}/browse-service-type.c
|
||||||
|
${ACR}/cache.c
|
||||||
|
${ACR}/dns.c
|
||||||
|
${ACR}/domain-util.c
|
||||||
|
${ACR}/entry.c
|
||||||
|
${ACR}/fdutil.c
|
||||||
|
${ACR}/hashmap.c
|
||||||
|
${ACR}/iface.c
|
||||||
|
${ACR}/iface-linux.c
|
||||||
|
${ACR}/log.c
|
||||||
|
${ACR}/multicast-lookup.c
|
||||||
|
${ACR}/netlink.c
|
||||||
|
${ACR}/prioq.c
|
||||||
|
${ACR}/probe-sched.c
|
||||||
|
${ACR}/querier.c
|
||||||
|
${ACR}/query-sched.c
|
||||||
|
${ACR}/resolve-address.c
|
||||||
|
${ACR}/resolve-host-name.c
|
||||||
|
${ACR}/resolve-service.c
|
||||||
|
${ACR}/response-sched.c
|
||||||
|
${ACR}/rr.c
|
||||||
|
${ACR}/rrlist.c
|
||||||
|
${ACR}/server.c
|
||||||
|
${ACR}/socket.c
|
||||||
|
${ACR}/timeeventq.c
|
||||||
|
${ACR}/util.c
|
||||||
|
${ACR}/wide-area.c
|
||||||
|
)
|
||||||
|
list(APPEND ${PUBLIC_HEADERS}
|
||||||
|
avahi-qt/qt-watch.h
|
||||||
|
)
|
||||||
|
target_compile_definitions(QtZeroConf PRIVATE HAVE_STRLCPY GETTEXT_PACKAGE HAVE_NETLINK)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install
|
||||||
|
set_target_properties(QtZeroConf PROPERTIES PUBLIC_HEADER
|
||||||
|
"${PUBLIC_HEADERS}"
|
||||||
|
)
|
||||||
|
install(TARGETS QtZeroConf
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
PUBLIC_HEADER DESTINATION include/QtZeroConf
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_EXAMPLE)
|
||||||
|
add_subdirectory(example)
|
||||||
|
endif()
|
@ -30,6 +30,13 @@ QZeroConf can be built directly into your project if your project is [LGPL3](htt
|
|||||||
1. Clone or download QZeroConf. If you download, unzip.
|
1. Clone or download QZeroConf. If you download, unzip.
|
||||||
2. Enter the qtzeroconf directory, run qmake and then make.
|
2. Enter the qtzeroconf directory, run qmake and then make.
|
||||||
|
|
||||||
|
#### Building with CMake
|
||||||
|
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
|
### API
|
||||||
|
|
||||||
#### Service Publishing
|
#### Service Publishing
|
||||||
|
25
example/CMakeLists.txt
Normal file
25
example/CMakeLists.txt
Normal file
@ -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
|
||||||
|
)
|
Reference in New Issue
Block a user