CMakeLists.txt 9.04 KB
Newer Older
1 2
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

3
project(umbrello)
4

5 6 7 8
if(POLICY CMP0028)
    cmake_policy(SET CMP0028 OLD)
endif()

9 10 11 12
if(POLICY CMP0057)
    cmake_policy(SET CMP0057 NEW)
endif()

13
# KDE Application Version, managed by release script
14
set (RELEASE_SERVICE_VERSION_MAJOR "20")
15 16
set (RELEASE_SERVICE_VERSION_MINOR "04")
set (RELEASE_SERVICE_VERSION_MICRO "0")
Andi Fischer's avatar
Andi Fischer committed
17

Ralf Habacker's avatar
Ralf Habacker committed
18
set(UMBRELLO_VERSION_MAJOR "2")
Ralf Habacker's avatar
Ralf Habacker committed
19
set(UMBRELLO_VERSION_MINOR "30")
20
if (RELEASE_SERVICE_VERSION_MICRO GREATER_EQUAL 70)
21
    math(EXPR UMBRELLO_VERSION_MINOR "${UMBRELLO_VERSION_MINOR}-0")
22 23
endif()

24
set(UMBRELLO_VERSION_PATCH ${RELEASE_SERVICE_VERSION_MICRO})
25

26 27
option(BUILD_APIDOC "Create api documentation" ON)

28 29 30 31 32 33
option(BUILD_ICONS "Create icons from svg source" OFF)

option(BUILD_CURSOR_ICONS "Create cursor icons from svg source" OFF)

option(BUILD_ICONS_INTO_SIZE_RELATED_DIRS "place icons into separate directories (for debugging purpose)" OFF)

34
option(BUILD_KF5 "Build for KDE Frameworks 5" ON)
35

36 37
option(BUILD_PHP_IMPORT "Build with php import support" ON)

38 39 40 41
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
include(Macros)

42 43
set(CMAKE_AUTORCC ON)

44 45
if(CMAKE_COMPILER_IS_GNUCXX)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -fno-delete-null-pointer-checks")
Ralf Habacker's avatar
Ralf Habacker committed
46 47
    # TODO: after removing kdelibs4support this could also be removed
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
48
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
49 50
endif()

51
if(NOT BUILD_KF5)
52 53
    set(APP_SUFFIX)
    set(LIB_PREFIX Qt4::Qt)
54 55
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
56 57
    include(ECMKDE4Macros)
    set(QT_MIN_VERSION "4.8.0")
58
    set(KDEV_MIN_VERSION 1.7.3)
59 60
    set(KDEV_SOURCE_DIR lib/kdev4-php)
    set(KDEV_COMPONENTS)
61
else()
Ralf Habacker's avatar
Ralf Habacker committed
62 63
    set(APP_SUFFIX 5)
    set(LIB_PREFIX Qt5::)
64 65
    # we need some parts of the ECM CMake helpers
    find_package(ECM 1.1.0 REQUIRED NO_MODULE)
66
    list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
67 68

    include(KDEInstallDirs)
69
    include(KDECompilerSettings NO_POLICY_SCOPE)
70 71 72 73 74
    include(KDECMakeSettings)
    include(FeatureSummary)
    include(ECMInstallIcons)
    include(ECMSetupVersion)
    include(ECMOptionalAddSubdirectory)
Ralf Habacker's avatar
Ralf Habacker committed
75
    include(ECMAddAppIcon)
76 77
    include(ECMAddTests)
    set(QT_MIN_VERSION "5.2.0")
78 79
    set(KDEV_MIN_VERSION 5.1.2)
    set(KDEV_SOURCE_DIR lib/kdev5-php)
80
    set(KDEV_COMPONENTS KDev::Interfaces KDev::Language KDev::Shell)
81 82 83 84 85 86 87 88 89 90 91 92 93
endif()

# search packages used by Qt
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS
    Core
    Gui
    PrintSupport
    Svg
    Test
    Widgets
    Xml
    WebKitWidgets
)
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
# search packages used by KDE
find_package(KF5 REQUIRED COMPONENTS
    Archive
    Completion
    Config
    CoreAddons
    Crash
    DocTools
    I18n
    IconThemes
    KDELibs4Support
    KIO
    TextEditor
    WidgetsAddons
    WindowSystem
    XmlGui
)
112

113 114 115 116
if(CMAKE_COMPILER_IS_GNUCXX)
    string(REPLACE "-Wsuggest-override" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif()

117
if(BUILD_PHP_IMPORT)
118 119 120 121
    find_package(KDevelop-PG-Qt)
    find_package(KDevPlatform ${KDEV_MIN_VERSION} COMPONENTS ${KDEV_COMPONENTS})
endif()
if(KDEVPGQT_FOUND AND KDEVPLATFORM_FOUND)
Ralf Habacker's avatar
Ralf Habacker committed
122
    message(STATUS "requirements available - enable building php code import")
123 124 125 126 127
    include_directories(
        ${KDEVPGQT_INCLUDE_DIR}
        ${KDEVPLATFORM_INCLUDE_DIR}
        ${CMAKE_SOURCE_DIR}/${KDEV_SOURCE_DIR}/parser
        ${CMAKE_BINARY_DIR}/${KDEV_SOURCE_DIR}/parser
128
    )
129 130 131 132 133 134
    set(NO_INSTALL 1)
    set(BUILD_PARSER_ONLY 1)
    set(BUILD_PHP_IMPORT 1)
    add_definitions(
        -DKDEVPHPPARSER_EXPORT=
        -DENABLE_PHP_IMPORT
135
    )
136
    add_subdirectory(lib/kdevplatform)
137
    add_subdirectory(${KDEV_SOURCE_DIR})
138 139
else()
    set(BUILD_PHP_IMPORT 0)
140
endif()
141

142
set(UMBRELLO_DATA_INSTALL_DIR ${DATA_INSTALL_DIR}/umbrello${APP_SUFFIX})
143

144 145 146 147
if(NOT BUILD_KF5)
    macro_display_feature_log()
    KDE4_NO_ENABLE_FINAL(umbrello)
else()
148
    set(BUILD_UNITTESTS 1)
149 150 151

    ki18n_install(po)
    kdoctools_install(po)
152 153
endif()

154 155 156
if(POLICY CMP0071)
  cmake_policy(SET CMP0071 OLD)
endif()
157 158 159 160 161 162 163

# use some compile flags
add_definitions(
    -DQT_NO_SIGNAL_SLOTS_KEYWORDS
    -DQT_NO_URL_CAST_FROM_STRING
)

164
# set default umbrello version
Ralf Habacker's avatar
Ralf Habacker committed
165
# umbrello version could be overridden by cmake command line using -DUMBRELLO_VERSION_STRING=major.minor.patch
166
if(NOT UMBRELLO_VERSION_STRING)
167
    set(UMBRELLO_VERSION_STRING "${UMBRELLO_VERSION_MAJOR}.${UMBRELLO_VERSION_MINOR}.${UMBRELLO_VERSION_PATCH}")
168 169 170
    if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
        execute_process(
            COMMAND git rev-parse --short HEAD
171
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
172 173
            OUTPUT_VARIABLE _hash
        )
Ralf Habacker's avatar
Ralf Habacker committed
174
        if(_hash)
175 176 177
           string(REPLACE "\n" "" hash ${_hash})
           set(UMBRELLO_VERSION_STRING "${UMBRELLO_VERSION_STRING}-${hash}")
        endif()
178
    endif()
179 180
endif()

181 182 183
message(STATUS "Using umbrello version ${UMBRELLO_VERSION_STRING}")
add_definitions(-DUMBRELLO_VERSION_STRING="${UMBRELLO_VERSION_STRING}")

184 185
message(STATUS "Using automoc4 version ${AUTOMOC4_VERSION}")
message(STATUS "Using cmake version ${CMAKE_VERSION}")
186
message(STATUS "Using Qt version ${QTVERSION}")
187

188 189 190 191 192
find_package(LibXslt)
set_package_properties(LibXslt PROPERTIES
    DESCRIPTION "A library to transform XMLfiles into other XML files."
    URL "http://xmlsoft.org/XSLT"
    TYPE REQUIRED)
193

194 195 196 197 198
find_package(LibXml2)
set_package_properties(LibXml2 PROPERTIES
    DESCRIPTION "Libraries used to develop XML applications."
    URL "http://xmlsoft.org"
    TYPE REQUIRED)
199 200

include_directories(
201
    ${CMAKE_BINARY_DIR}
202 203
)

204
#
205
# Unstable features should not be enabled in stable branches
206 207
# This macro limits unstable feature to development branches
# by only adding -DENABLE_<name> to the compile command when
208 209 210
# the patch level is >= 70 which includes releases from master
# beta and rc releases. On cmake configure time a related status
# note is displayed.
211 212 213 214 215 216 217 218 219 220
#
# syntax:  add_unstable_feature(<name>)
#
# In code wrap feature related code with
#
#  #ifdef ENABLE_<name>
#    <feature code>
#  #endif
#
macro(add_unstable_feature name)
221
    if(UMBRELLO_VERSION_PATCH GREATER 69)
222
        add_definitions(-DENABLE_${name})
223
        set(ENABLE_${name} 1)
224 225
        message(STATUS "Enable unstable feature ${name} - use '#ifdef ENABLE_${name}' in related code")
    else()
226
        set(ENABLE_${name} 0)
227 228 229 230 231 232
        message(STATUS "Disable unstable feature ${name}")
    endif()
endmacro(add_unstable_feature)

add_unstable_feature(WIDGET_SHOW_DOC) # show documentation in classes ticket xxx
add_unstable_feature(NEW_CODE_GENERATORS) # new c++ code generator
233
add_unstable_feature(UML_OBJECTS_WINDOW) # objects dock window
234
add_unstable_feature(XMIRESOLUTION) # see https://bugs.kde.org/show_bug.cgi?id=90103
235
add_unstable_feature(COMBINED_STATE_DIRECT_EDIT) # experimental feature
236

237 238 239 240
# Current object diagram implementation does not follow UML 1.4 standard
# because of using umbrello specific XMI tag (UML:InstanceAttribute).
add_unstable_feature(OBJECT_DIAGRAM) # see https://bugs.kde.org/show_bug.cgi?id=123633

241 242
# requires cmake >= 3.9.6
find_package(Doxygen OPTIONAL_COMPONENTS dot)
243
if(DOXYGEN_FOUND AND BUILD_APIDOC)
244
    message(STATUS "found doxygen package")
245
    find_program(QHELPGENERATOR_EXECUTABLE NAMES qhelpgenerator qhelpgenerator-qt5)
246
    message(STATUS "found qhelpgenerator ${QHELPGENERATOR_EXECUTABLE}")
247 248 249 250 251 252 253 254
    set(DOXYGEN_ABBREVIATE_BRIEF "The $name class" "The $name widget")
    set(DOXYGEN_CALL_GRAPH YES)
    set(DOXYGEN_EXCLUDE_PATTERNS */lib/*)
    set(DOXYGEN_EXTRACT_ALL YES)
    set(DOXYGEN_EXTRACT_PACKAGE YES)
    set(DOXYGEN_EXTRACT_PRIVATE YES)
    set(DOXYGEN_EXTRACT_STATIC YES)
    set(DOXYGEN_GENERATE_HTMLHELP YES)
255
    set(DOXYGEN_HAVE_DOT ${DOXYGEN_HAVE_DOT})
256 257 258 259 260 261 262 263 264 265
    set(DOXYGEN_MARKDOWN_SUPPORT NO)
    set(DOXYGEN_MAX_DOT_GRAPH_DEPTH 1000)
    set(DOXYGEN_PROJECT_BRIEF "Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology")
    set(DOXYGEN_PROJECT_NUMBER ${UMBRELLO_VERSION_STRING})
    #set(DOXYGEN_PROJECT_LOGO ${CMAKE_SOURCE_DIR}/umbrello/pics/global/hi32-apps-umbrello.png)
    set(DOXYGEN_SOURCE_BROWSER NO)
    set(DOXYGEN_UML_LOOK YES)
    set(DOXYGEN_USE_PDFLATEX NO)
    set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/apidoc)

266 267 268 269 270 271 272 273 274
    if(QHELPGENERATOR_EXECUTABLE)
        set(DOXYGEN_GENERATE_QHP YES)
        set(DOXYGEN_QCH_FILE ${CMAKE_BINARY_DIR}/umbrello.qch)
        set(DOXYGEN_QHP_NAMESPACE org.kde.umbrello)
        set(DOXYGEN_QHG_LOCATION ${QHELPGENERATOR_EXECUTABLE})
        set(DOXYGEN_QHP_VIRTUAL_FOLDER doc)
        install(FILES ${DOXYGEN_QCH_FILE} DESTINATION ${QT_DOC_DIR}/qch COMPONENT Devel)
    endif()

275
    doxygen_add_docs(apidoc
276
        ALL
277 278
        ${CMAKE_SOURCE_DIR}
        COMMENT "generating api doc"
279
    )
280 281

    install(DIRECTORY ${CMAKE_BINARY_DIR}/apidoc DESTINATION ${UMBRELLO_DATA_INSTALL_DIR})
282 283
endif()

284
if(LIBXSLT_FOUND AND LIBXML2_FOUND)
285 286 287
    add_subdirectory(umbrello)
    add_subdirectory(doc)
    add_subdirectory(tools)
288
endif(LIBXSLT_FOUND AND LIBXML2_FOUND)
289

290 291
add_subdirectory(maintainer)

292 293 294 295 296 297
# for automatic unit tests
if(BUILD_UNITTESTS)
    ecm_optional_add_subdirectory(unittests)
endif()

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)