diff --git a/CMakeLists.txt b/CMakeLists.txt index 54b7f6993..691f33920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,263 +1,264 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) find_package(ECM 1.8.0 REQUIRED NOMODULE) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(SetKexiCMakePolicies NO_POLICY_SCOPE) include(SetKexiVersionInfo) project(Kexi VERSION ${PROJECT_VERSION}) # ECM include(ECMAddAppIcon) include(ECMAddTests) include(ECMGenerateHeaders) include(ECMInstallIcons) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) include(ECMPoQmTools) include(ECMSetupVersion) include(KDEInstallDirs) include(KDECMakeSettings NO_POLICY_SCOPE) include(KDECompilerSettings NO_POLICY_SCOPE) # Own include(KexiMacros) include(KexiAddIconsRccFile) +include(KexiGenerateDependencyGraph) ensure_out_of_source_build("Please refer to the build instruction https://community.kde.org/Kexi/Building") get_git_revision_and_branch() detect_release_build() ####################### ######################## ## Productset setting ## ######################## ####################### # For predefined productsets see the definitions in KexiProducts.cmake and # in the files in the folder cmake/productsets. # Finding out the products & features to build is done in 5 steps: # 1. have the user define the products/features wanted, by giving a productset # 2. estimate all additional required products/features # 3. estimate which of the products/features can be build by external deps # 4. find which products/features have been temporarily disabled due to problems # 5. estimate which of the products/features can be build by internal deps # get the special macros include(CalligraProductSetMacros) set(PRODUCTSET_DEFAULT "DESKTOP") if(NOT PRODUCTSET OR PRODUCTSET STREQUAL "ALL") # Force the default set also when it is "ALL" because we can't build both desktop and mobile set(PRODUCTSET ${PRODUCTSET_DEFAULT} CACHE STRING "Set of products/features to build" FORCE) endif() # get the definitions of products, features and product sets include(KexiProducts.cmake) if (RELEASE_BUILD) set(KEXI_SHOULD_BUILD_STAGING FALSE) else () set(KEXI_SHOULD_BUILD_STAGING TRUE) endif () # finally choose products/features to build calligra_set_productset(${PRODUCTSET}) ########################## ########################### ## Look for Qt, KF5 ## ########################### ########################## set(REQUIRED_KF5_VERSION 5.16.0) set(REQUIRED_KF5_COMPONENTS Archive Codecs Config ConfigWidgets CoreAddons GuiAddons I18n IconThemes ItemViews WidgetsAddons TextWidgets XmlGui ) if(SHOULD_BUILD_KEXI_DESKTOP_APP) list(APPEND REQUIRED_KF5_COMPONENTS Completion KIO TextEditor TextWidgets ) endif() find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED COMPONENTS ${REQUIRED_KF5_COMPONENTS}) find_package(KF5 ${REQUIRED_KF5_VERSION} QUIET OPTIONAL_COMPONENTS Crash) macro_bool_to_01(KF5Crash_FOUND HAVE_KCRASH) macro_log_feature(${KF5Crash_FOUND} "KCrash" "KDE's Crash Handler" "https://api.kde.org/frameworks/kcrash/html" FALSE "" "Optionally used to provide crash reporting on Linux") set(REQUIRED_QT_VERSION 5.4.0) find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport Test) find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS UiTools WebKit WebKitWidgets) # use sane compile flags add_definitions( -DQT_NO_CAST_TO_ASCII -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_QSTRINGBUILDER ) # only with COMPILING_TESTS definition will all the FOO_TEST_EXPORT macros do something # TODO: check if this can be moved to only those places which make use of it, # to reduce global compiler definitions that would trigger a recompile of # everything on a change (like adding/removing tests to/from the build) macro_bool_to_01(BUILD_TESTING COMPILING_TESTS) # overcome some platform incompatibilities if(WIN32) find_package(KDEWin REQUIRED) endif() # set custom Kexi plugin installdir set(KEXI_PLUGIN_INSTALL_DIR ${PLUGIN_INSTALL_DIR}/${KEXI_BASE_PATH}) # TEMPORARY: for initial Qt5/KF5 build porting phase deprecation warnings are only annoying noise # remove once code porting phase starts, perhaps first locally in product subdirs #if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) # add_definitions(-Wno-deprecated -Wno-deprecated-declarations) #endif () ########################### ############################ ## Required dependencies ## ############################ ########################### set(KEXI_LIBS_MIN_VERSION 3.0.90) ## ## Test for KDb ## option(KEXI_DEBUG_GUI "Debugging GUI for Kexi (requires KDB_DEBUG_GUI to be set too)" OFF) if(KEXI_DEBUG_GUI) set(KDB_REQUIRED_COMPONENTS DEBUG_GUI) endif() find_package(KDb ${KEXI_LIBS_MIN_VERSION} REQUIRED COMPONENTS ${KDB_REQUIRED_COMPONENTS}) macro_log_feature(KDb_FOUND "KDb" "A database connectivity and creation framework" "http://community.kde.org/KDb" FALSE "" "Required by Kexi for data handling") ## ## Test for KReport ## find_package(KReport ${KEXI_LIBS_MIN_VERSION} REQUIRED) if (KReport_FOUND) if(NOT KREPORT_SCRIPTING) message(FATAL_ERROR "Kexi requires KReport package with scripting support enabled (KREPORT_SCRIPTING)") endif() endif() ## ## Test for KPropertyWidgets ## if(SHOULD_BUILD_KEXI_DESKTOP_APP) find_package(KPropertyWidgets ${KEXI_LIBS_MIN_VERSION} REQUIRED COMPONENTS KF) macro_log_feature(KPropertyWidgets_FOUND "KPropertyWidgets" "A property editing framework with editor widget" "http://community.kde.org/KProperty" FALSE "" "Required by Kexi Desktop") else() # only KPropertyCore find_package(KPropertyCore ${KEXI_LIBS_MIN_VERSION} REQUIRED COMPONENTS KF) macro_log_feature(KPropertyCore_FOUND "KPropertyCore" "A property editing framework with editor widget" "http://community.kde.org/KProperty" FALSE "" "Required by Kexi Mobile") endif() include(CheckIfQtGuiCanBeExecuted) if(SHOULD_BUILD_KEXI_DESKTOP_APP) include(CheckGlobalBreezeIcons) endif() ########################### ############################ ## Optional dependencies ## ############################ ########################### ## ## Test for marble ## set(MARBLE_MIN_VERSION "0.19.2") find_package(KexiMarble) if(NOT MARBLE_FOUND) set(MARBLE_INCLUDE_DIR "") else() set(HAVE_MARBLE TRUE) endif() macro_log_feature(MARBLE_FOUND "Marble" "KDE World Globe Widget library" "https://marble.kde.org/" FALSE "${MARBLE_MIN_VERSION}" "Required by Kexi form map widget") ## ## Test for Qt WebKitWidgets ## #TODO switch to Qt WebEngine macro_bool_to_01(Qt5WebKitWidgets_FOUND HAVE_QTWEBKITWIDGETS) macro_log_feature(Qt5WebKitWidgets_FOUND "Qt WebkitWidgets" "QWidgets module for Webkit, the HTML engine." "http://qt.io" FALSE "" "Required by Kexi web form widget") ################## ################### ## Helper macros ## ################### ################## include(MacroKexiAddBenchmark) include(MacroKexiAddTest) ############################################# #### Temporarily broken products #### ############################################# # If a product does not build due to some temporary brokeness disable it here, # by calling calligra_disable_product with the product id and the reason, # e.g.: # calligra_disable_product(APP_KEXI "isn't buildable at the moment") ############################################# #### Calculate buildable products #### ############################################# calligra_drop_unbuildable_products() ############################################# #### Setup product-depending vars #### ############################################# ################### #################### ## Subdirectories ## #################### ################### add_subdirectory(src) if(SHOULD_BUILD_DOC) find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS DocTools) add_subdirectory(doc) endif() # non-app directories are moved here because they can depend on SHOULD_BUILD_{appname} variables set above add_subdirectory(cmake) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() macro_display_feature_log() calligra_product_deps_report("product_deps") calligra_log_should_build() diff --git a/cmake/modules/CMakeGraphVizOptions.cmake.in b/cmake/modules/CMakeGraphVizOptions.cmake.in new file mode 100644 index 000000000..281a977ce --- /dev/null +++ b/cmake/modules/CMakeGraphVizOptions.cmake.in @@ -0,0 +1,20 @@ +# Variables specific to the graphviz support +# see https://cmake.org/cmake/help/v3.8/module/CMakeGraphVizOptions.html +# +# Do not edit this file, it is generated from ${CMAKE_CURRENT_LIST_DIR}/CMakeGraphVizOptions.cmake.in. +# Instead change ${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH* cmake variables. + +set(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_ALL_LIBS ${${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_ALL_LIBS}) +set(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_KEXI_FRAMEWORKS ${${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_KEXI_FRAMEWORKS}) + +if(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_ALL_LIBS) + set(GRAPHVIZ_EXTERNAL_LIBS TRUE) + unset(GRAPHVIZ_IGNORE_TARGETS) +else() + if(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_KEXI_FRAMEWORKS) + set(GRAPHVIZ_EXTERNAL_LIBS TRUE) + set(GRAPHVIZ_IGNORE_TARGETS Qt5::.* KF5::.* /usr.*) + else() + set(GRAPHVIZ_EXTERNAL_LIBS FALSE) + endif() +endif() diff --git a/cmake/modules/KexiGenerateDependencyGraph.cmake b/cmake/modules/KexiGenerateDependencyGraph.cmake new file mode 100644 index 000000000..7f0b88d36 --- /dev/null +++ b/cmake/modules/KexiGenerateDependencyGraph.cmake @@ -0,0 +1,63 @@ +# Generates dependency graphs for current project +# +# Copyright (C) 2017 Jarosław Staniek +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if(TARGET generate_dependency_graph) + return() +endif() + +find_package(Doxygen) + +if(NOT DOXYGEN_DOT_EXECUTABLE) + message(STATUS "Graphviz dot tool not found, won't generate dependency graphs") + return() +endif() + +set(_graph_dir ${CMAKE_BINARY_DIR}/dependencies) +set(_dot_file ${_graph_dir}/graph.dot) +set(_image_file "dependency-graph-${CMAKE_PROJECT_NAME}.png") + +simple_option(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_KEXI_FRAMEWORKS "Include Kexi frameworks in the dependency graph" ON) +simple_option(${PROJECT_NAME_UPPER}_DEPENDENCY_GRAPH_INCLUDE_ALL_LIBS "Include all libs in the dependency graph" OFF) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeGraphVizOptions.cmake.in + ${CMAKE_BINARY_DIR}/CMakeGraphVizOptions.cmake) + +add_custom_target(generate_dependency_graph) + +add_custom_command( + TARGET generate_dependency_graph POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${_graph_dir} + COMMAND cmake --graphviz=${_dot_file} . + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating dependency graph ${_graph_dir}/${_dot_file} for " + "${CMAKE_PROJECT_NAME} project" +) +add_custom_command( + TARGET generate_dependency_graph POST_BUILD + COMMAND ${DOXYGEN_DOT_EXECUTABLE} ${_dot_file} -T png > "${_graph_dir}/${_image_file}" + WORKING_DIRECTORY ${_graph_dir} + COMMENT "Generating dependency graph image ${_graph_dir}/${_image_file} for " + "${CMAKE_PROJECT_NAME} project" +) + +add_custom_target(show_dependency_graph) +if(WIN32) + set(_open_command start) +else() + set(_open_command xdg-open) +endif() +add_custom_command( + TARGET show_dependency_graph POST_BUILD + COMMAND ${_open_command} "${_graph_dir}/${_image_file}" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Show dependency graph image for ${CMAKE_PROJECT_NAME} project" +) + +unset(_dot_file) +unset(_image_file) +unset(_graph_dir) +unset(_open_command)