2022-04-04 02:06:37 +08:00
|
|
|
cmake_minimum_required(VERSION 3.12.0)
|
2019-10-11 21:30:11 +08:00
|
|
|
|
2022-04-06 20:06:12 +08:00
|
|
|
project(SingleApplication LANGUAGES CXX DESCRIPTION "Replacement for QtSingleApplication")
|
2019-10-11 21:30:11 +08:00
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
|
|
|
add_library(${PROJECT_NAME} STATIC
|
|
|
|
singleapplication.cpp
|
|
|
|
singleapplication_p.cpp
|
2020-05-10 04:19:12 +08:00
|
|
|
)
|
2020-05-24 22:46:31 +08:00
|
|
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
2019-10-11 21:30:11 +08:00
|
|
|
|
2020-10-22 01:48:51 +08:00
|
|
|
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()
|
2020-10-18 06:48:31 +08:00
|
|
|
|
2019-10-11 21:30:11 +08:00
|
|
|
# Find dependencies
|
2020-10-18 06:48:31 +08:00
|
|
|
set(QT_COMPONENTS Core Network)
|
2020-10-22 01:48:51 +08:00
|
|
|
set(QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Network)
|
2020-05-10 04:19:12 +08:00
|
|
|
|
2019-10-11 21:30:11 +08:00
|
|
|
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
2020-10-18 06:48:31 +08:00
|
|
|
list(APPEND QT_COMPONENTS Widgets)
|
2020-10-22 01:48:51 +08:00
|
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets)
|
2019-10-11 21:30:11 +08:00
|
|
|
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
2020-10-18 06:48:31 +08:00
|
|
|
list(APPEND QT_COMPONENTS Gui)
|
2020-10-22 01:48:51 +08:00
|
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
2019-10-11 21:30:11 +08:00
|
|
|
else()
|
2020-05-10 04:19:12 +08:00
|
|
|
set(QAPPLICATION_CLASS QCoreApplication)
|
2019-10-11 21:30:11 +08:00
|
|
|
endif()
|
|
|
|
|
2020-10-22 01:48:51 +08:00
|
|
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
2022-06-10 04:36:46 +08:00
|
|
|
|
2022-06-10 05:00:31 +08:00
|
|
|
option(SINGLEAPPLICATION_DOCUMENTATION "Generate Doxygen documentation" OFF)
|
2022-06-10 04:36:46 +08:00
|
|
|
if(SINGLEAPPLICATION_DOCUMENTATION)
|
|
|
|
find_package(Doxygen)
|
|
|
|
endif()
|
2020-10-18 06:48:31 +08:00
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
|
|
|
|
|
2019-10-11 21:30:11 +08:00
|
|
|
if(WIN32)
|
2024-02-04 19:04:38 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
|
2019-10-11 21:30:11 +08:00
|
|
|
endif()
|
|
|
|
|
2020-05-10 04:19:12 +08:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
|
2019-10-11 21:30:11 +08:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
2022-04-04 02:07:16 +08:00
|
|
|
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
|
|
|
|
)
|
2022-04-06 05:04:31 +08:00
|
|
|
|
|
|
|
if(DOXYGEN_FOUND)
|
2022-04-06 20:26:00 +08:00
|
|
|
# Doxygen theme
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(DoxygenAwesome
|
|
|
|
GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css
|
|
|
|
GIT_TAG 4cd62308d825fe0396d2f66ffbab45d0e247724c # 2.0.3
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(DoxygenAwesome)
|
|
|
|
FetchContent_GetProperties(DoxygenAwesome SOURCE_DIR DoxygenAwesome_SOURCE_DIR)
|
|
|
|
|
2022-04-06 05:04:31 +08:00
|
|
|
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
|
2022-04-06 18:28:38 +08:00
|
|
|
set(DOXYGEN_GENERATE_TREEVIEW YES)
|
2022-04-06 20:26:00 +08:00
|
|
|
set(DOXYGEN_HTML_HEADER ${DoxygenAwesome_SOURCE_DIR}/doxygen-custom/header.html)
|
|
|
|
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${DoxygenAwesome_SOURCE_DIR}/doxygen-awesome.css)
|
|
|
|
set(DOXYGEN_HTML_EXTRA_FILES
|
|
|
|
${DoxygenAwesome_SOURCE_DIR}/doxygen-awesome-fragment-copy-button.js
|
|
|
|
${DoxygenAwesome_SOURCE_DIR}/doxygen-awesome-paragraph-link.js
|
|
|
|
${DoxygenAwesome_SOURCE_DIR}/doxygen-awesome-darkmode-toggle.js
|
|
|
|
)
|
2022-04-06 05:04:31 +08:00
|
|
|
|
|
|
|
doxygen_add_docs(${PROJECT_NAME}Documentation
|
|
|
|
singleapplication.h
|
|
|
|
CHANGELOG.md
|
|
|
|
Windows.md
|
|
|
|
README.md
|
|
|
|
)
|
|
|
|
endif()
|