2020-05-25 14:01:37 +03:00
|
|
|
cmake_minimum_required(VERSION 3.7.0)
|
2020-02-23 15:40:04 +03:00
|
|
|
|
2020-05-25 14:01:37 +03:00
|
|
|
project(SingleApplication LANGUAGES CXX)
|
2020-02-23 15:40:04 +03:00
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
|
|
|
add_library(${PROJECT_NAME} STATIC
|
|
|
|
singleapplication.cpp
|
|
|
|
singleapplication_p.cpp
|
2020-05-25 14:01:37 +03:00
|
|
|
)
|
|
|
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
2020-02-23 15:40:04 +03:00
|
|
|
|
2020-11-10 05:28:41 +03: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-02-23 15:40:04 +03:00
|
|
|
# Find dependencies
|
2020-11-10 05:28:41 +03:00
|
|
|
set(QT_COMPONENTS Core Network)
|
|
|
|
set(QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Network)
|
2020-05-25 14:01:37 +03:00
|
|
|
|
2020-02-23 15:40:04 +03:00
|
|
|
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
2020-11-10 05:28:41 +03:00
|
|
|
list(APPEND QT_COMPONENTS Widgets)
|
|
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets)
|
2020-02-23 15:40:04 +03:00
|
|
|
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
2020-11-10 05:28:41 +03:00
|
|
|
list(APPEND QT_COMPONENTS Gui)
|
|
|
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
2020-02-23 15:40:04 +03:00
|
|
|
else()
|
2020-05-25 14:01:37 +03:00
|
|
|
set(QAPPLICATION_CLASS QCoreApplication)
|
2020-02-23 15:40:04 +03:00
|
|
|
endif()
|
|
|
|
|
2020-11-10 05:28:41 +03:00
|
|
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
|
|
|
|
|
2020-02-23 15:40:04 +03:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
|
|
|
|
endif()
|
|
|
|
|
2020-05-25 14:01:37 +03:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
|
2020-02-23 15:40:04 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|