summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 4129bc911692c2af6ae93b3eb769a9cdc7391f51 (plain)
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
75
cmake_minimum_required(VERSION 3.10)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
    cmake_policy(VERSION 3.15)
endif()

## Add paths to check for cmake modules:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(FeatureSummary)
include(QbsBuildConfig)
include(QbsDocumentation)

file(STRINGS VERSION QBS_VERSION)
project(Qbs VERSION ${QBS_VERSION})

# Force C++ standard, do not fall back, do not use compiler extensions
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Set up Qt stuff:
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)

if(WITH_TESTS)
    enable_testing()
    set(QT_TEST_COMPONENT Test)
    set(IMPLICIT_DEPENDS Qt${QT_VERSION_MAJOR}::Test)
endif()

find_package(Qt${QT_VERSION_MAJOR}
    COMPONENTS Concurrent Core Gui Network Widgets Xml ${QT_TEST_COMPONENT}
    REQUIRED
    )

find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Script QUIET)

if (Qt6_FOUND)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED)
    if(NOT TARGET Qt6Core5Compat)
        set_property(TARGET Qt6::Core5Compat PROPERTY IMPORTED_GLOBAL TRUE) # hack for CMake < 1.18
        add_library(Qt6Core5Compat ALIAS Qt6::Core5Compat)
    endif()
else()
  if(NOT TARGET Qt6Core5Compat)
    add_library(Qt6Core5Compat INTERFACE)
  endif()
  if (NOT QBS_USE_BUNDLED_QT_SCRIPT AND Qt5Script_FOUND)
      add_library(qbsscriptengine INTERFACE)
      target_link_libraries(qbsscriptengine INTERFACE Qt5::Script)
  endif()
endif()

if (QBS_INSTALL_HTML_DOCS OR QBS_INSTALL_QCH_DOCS)
    find_package(Python3 COMPONENTS Interpreter)
    if (Qt6_FOUND)
        find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Tools REQUIRED)
    else()
        find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Help REQUIRED)
    endif()
endif()

add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(share)
if(WITH_TESTS)
    add_subdirectory(tests)
endif()