mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2024-11-15 12:15:43 +08:00
67 lines
2.1 KiB
CMake
67 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.12.0)
|
|
|
|
project(SingleApplication LANGUAGES CXX DESCRIPTION "Replacement for QtSingleApplication")
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
add_library(${PROJECT_NAME} STATIC
|
|
singleapplication.cpp
|
|
singleapplication_p.cpp
|
|
)
|
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
|
|
|
if(NOT QT_DEFAULT_MAJOR_VERSION)
|
|
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
|
|
endif()
|
|
|
|
# Find dependencies
|
|
set(QT_COMPONENTS Core Network)
|
|
set(QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Network)
|
|
|
|
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
|
list(APPEND QT_COMPONENTS Widgets)
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets)
|
|
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
|
list(APPEND QT_COMPONENTS Gui)
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
|
else()
|
|
set(QAPPLICATION_CLASS QCoreApplication)
|
|
endif()
|
|
|
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
|
find_package(Doxygen)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
|
|
|
|
if(WIN32)
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
|
|
endif()
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
|
QT_NO_CAST_TO_ASCII
|
|
QT_NO_CAST_FROM_ASCII
|
|
QT_NO_URL_CAST_FROM_STRING
|
|
QT_NO_CAST_FROM_BYTEARRAY
|
|
QT_USE_QSTRINGBUILDER
|
|
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
|
|
QT_NO_KEYWORDS
|
|
QT_NO_FOREACH
|
|
)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
|
|
set(DOXYGEN_GENERATE_TREEVIEW YES)
|
|
set(DOXYGEN_HTML_HEADER doxygen/header.html)
|
|
set(DOXYGEN_HTML_EXTRA_FILES doxygen/doxygen-awesome-fragment-copy-button.js doxygen/doxygen-awesome-paragraph-link.js)
|
|
set(DOXYGEN_HTML_EXTRA_STYLESHEET doxygen/doxygen-awesome.css)
|
|
|
|
doxygen_add_docs(${PROJECT_NAME}Documentation
|
|
singleapplication.h
|
|
CHANGELOG.md
|
|
Windows.md
|
|
README.md
|
|
)
|
|
endif()
|