2020-05-10 04:19:12 +08:00
|
|
|
cmake_minimum_required(VERSION 3.7.0)
|
2019-10-11 21:30:11 +08:00
|
|
|
|
2020-05-10 04:19:12 +08:00
|
|
|
project(SingleApplication LANGUAGES CXX)
|
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
|
|
|
|
|
|
|
# Find dependencies
|
2020-05-10 04:19:12 +08:00
|
|
|
find_package(Qt5 COMPONENTS Network REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Network)
|
|
|
|
|
2019-10-11 21:30:11 +08:00
|
|
|
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
|
|
|
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
2020-05-10 04:19:12 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::Widgets)
|
2019-10-11 21:30:11 +08:00
|
|
|
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
|
|
|
find_package(Qt5 COMPONENTS Gui REQUIRED)
|
2020-05-10 04:19:12 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::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
|
|
|
find_package(Qt5 COMPONENTS Core REQUIRED)
|
2020-05-10 04:19:12 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::Core)
|
2019-10-11 21:30:11 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
|
|
|
|
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})
|