forked from ihor-drachuk/utils-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
74 lines (57 loc) · 2.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cmake_minimum_required(VERSION 3.16)
PROJECT(utils-qt)
option(UTILS_QT_ENABLE_TESTS "utils-qt: Enable tests" OFF)
option(UTILS_QT_ENABLE_BENCHMARK "utils-qt: Enable benchmark" OFF)
option(UTILS_QT_NO_GUI_TESTS "utils-qt: Disable GUI tests" OFF)
set(UTILS_QT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (NOT TARGET utils-cpp)
add_subdirectory(3rd-party/utils-cpp)
endif()
find_package(Qt6 COMPONENTS Core Quick QUIET)
if (NOT Qt6_FOUND)
find_package(Qt5 5.15 REQUIRED COMPONENTS Core Quick)
endif()
FILE(GLOB_RECURSE SOURCES src/*.cpp src/*.qrc src/*.h headers/*.h)
list(APPEND QML_IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/qml/")
list(REMOVE_DUPLICATES QML_IMPORT_PATH)
set(QML_IMPORT_PATH "${QML_IMPORT_PATH}" CACHE STRING "Qt Creator extra qml import paths" FORCE)
add_library(utils-qt STATIC ${SOURCES})
target_compile_features(utils-qt PUBLIC cxx_std_17)
set_property(TARGET utils-qt PROPERTY AUTOMOC ON)
set_property(TARGET utils-qt PROPERTY AUTORCC ON)
if(MSVC)
target_link_options(utils-qt PRIVATE "/ignore:4221")
set_target_properties(utils-qt PROPERTIES STATIC_LIBRARY_OPTIONS "/ignore:4221")
endif()
# --- System detection ---
if (WIN32)
set(UTILS_QT_OS_WIN TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_OS_WIN=1)
endif()
if(UNIX AND NOT APPLE)
set(UTILS_QT_OS_LINUX TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_OS_LINUX=1)
endif()
if(APPLE)
set(UTILS_QT_OS_MACOS TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_OS_MACOS=1)
endif()
if (MSVC)
set(UTILS_QT_COMPILER_MSVC TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_COMPILER_MSVC=1)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(UTILS_QT_COMPILER_GCC TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_COMPILER_GCC=1)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(UTILS_QT_COMPILER_CLANG TRUE)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_COMPILER_CLANG=1)
endif()
# --- ---
target_link_libraries(utils-qt PUBLIC Qt::Core Qt::Quick utils-cpp)
target_include_directories(utils-qt PUBLIC headers)
if (UTILS_QT_NO_GUI_TESTS)
target_compile_definitions(utils-qt PUBLIC UTILS_QT_NO_GUI_TESTS)
endif()
add_subdirectory(tests)