X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=CMakeLists.txt;h=02440377289be6293c424c71bc4515473a65022a;hb=HEAD;hp=81102ba70591b9b74aee77ebcc2741458750318b;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 81102ba..0244037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,334 +1,174 @@ -project( vym ) -cmake_minimum_required( VERSION 2.6 ) - -if( NOT CMAKE_BUILD_TYPE ) - set( CMAKE_BUILD_TYPE Debug ) -endif( NOT CMAKE_BUILD_TYPE ) - -if( CMAKE_COMPILER_IS_GNUCXX ) - add_definitions ( -Wall ) -endif( CMAKE_COMPILER_IS_GNUCXX ) - -if( UNIX AND NOT APPLE ) - set( NO_DBUS_DEFAULT OFF ) -else( UNIX AND NOT APPLE ) - set( NO_DBUS_DEFAULT ON ) -endif( UNIX AND NOT APPLE ) - -option( NO_DBUS "Build vym without dbus support" ${NO_DBUS_DEFAULT} ) - -find_package ( Qt4 REQUIRED ) -include ( ${QT_USE_FILE} ) -add_definitions( ${QT_DEFINITIONS} ) - -if( WIN32 ) - add_definitions( -DUNICODE -D_USE_MATH_DEFINES ) - if( MSVC ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-" ) - endif( MSVC ) -endif( WIN32 ) - -find_package( cppcheck ) -if(CPPCHECK_FOUND) - set(_cppcheck_args) - list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${CMAKE_SOURCE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTCORE_INCLUDE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTDBUS_INCLUDE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTGUI_INCLUDE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTNETWORK_INCLUDE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTXML_INCLUDE_DIR}) -# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTSVG_INCLUDE_DIR}) - - list(APPEND _cppcheck_args "enable" "all") - - add_custom_target( - cppcheck - COMMAND - "${CPPCHECK_EXECUTABLE}" - ${CPPCHECK_TEMPLATE_ARG} - ${CPPCHECK_QUIET_ARG} - "--force" -# "--std=c++11" - ${_cppcheck_args} - ${CMAKE_SOURCE_DIR} - ) - - message(STATUS "cppcheck target added.") -endif(CPPCHECK_FOUND) - -include_directories ( - ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR} - ) - -if(NOT NO_DBUS ) - include_directories( ${QT_QTDBUS_INCLUDE_DIR} ) -endif(NOT NO_DBUS ) - -set ( vym_HDRS - aboutdialog.h - taskfiltermodel.h - animpoint.h - attribute.h - attributeitem.h - # attributedelegate.h - # attributedialog.h - # attributewidget.h - branchitem.h - branchobj.h - branchpropeditor.h - bugagent.h - command.h - dockeditor.h - downloadagent.h - editxlinkdialog.h - exportoofiledialog.h - exporthtmldialog.h - exports.h - extrainfodialog.h - file.h - findwidget.h - findresultwidget.h - findresultitem.h - findresultmodel.h - flag.h - flagobj.h - flagrowobj.h - flagrow.h - floatimageobj.h - floatobj.h - frameobj.h - geometry.h - headingeditor.h - headingobj.h - highlighter.h - historywindow.h - imageitem.h - imageobj.h - imports.h - lineeditdialog.h - linkablemapobj.h - macros.h - mainwindow.h - mapeditor.h - mapitem.h - mapobj.h - misc.h - mysortfilterproxymodel.h - noteeditor.h - noteobj.h - options.h - ornamentedobj.h - parser.h - process.h - scripteditor.h - settings.h - shortcuts.h - showtextdialog.h - slidecontrolwidget.h - slideeditor.h - slideitem.h - slidemodel.h - task.h - taskeditor.h - taskmodel.h - treedelegate.h - treeeditor.h - treeitem.h - treemodel.h - texteditor.h - version.h - vymmodel.h - vymview.h - winter.h - warningdialog.h - xlink.h - xlinkitem.h - xlinkobj.h - xml-base.h - xml-vym.h - xml-freemind.h - xmlobj.h - xsltproc.h - ) - -set ( vym_SRCS - aboutdialog.cpp - taskfiltermodel.cpp - animpoint.cpp - attribute.cpp - attributeitem.cpp - # attributedelegate.cpp - # attributedialog.cpp - # attributewidget.cpp - branchitem.cpp - branchobj.cpp - branchpropeditor.cpp - bugagent.cpp - command.cpp - dockeditor.cpp - downloadagent.cpp - editxlinkdialog.cpp - exportoofiledialog.cpp - exports.cpp - exporthtmldialog.cpp - extrainfodialog.cpp - file.cpp - findwidget.cpp - findresultwidget.cpp - findresultitem.cpp - findresultmodel.cpp - flag.cpp - flagobj.cpp - flagrow.cpp - flagrowobj.cpp - floatimageobj.cpp - floatobj.cpp - frameobj.cpp - geometry.cpp - headingeditor.cpp - headingobj.cpp - highlighter.cpp - historywindow.cpp - imageitem.cpp - imageobj.cpp - imports.cpp - lineeditdialog.cpp - linkablemapobj.cpp - macros.cpp - main.cpp - mainwindow.cpp - mapeditor.cpp - mapitem.cpp - mapobj.cpp - misc.cpp - mysortfilterproxymodel.cpp - noteeditor.cpp - noteobj.cpp - options.cpp - ornamentedobj.cpp - parser.cpp - process.cpp - scripteditor.cpp - settings.cpp - shortcuts.cpp - showtextdialog.cpp - slidecontrolwidget.cpp - slideeditor.cpp - slideitem.cpp - slidemodel.cpp - task.cpp - taskeditor.cpp - taskmodel.cpp - texteditor.cpp - treedelegate.cpp - treeeditor.cpp - treeitem.cpp - treemodel.cpp - version.cpp - vymmodel.cpp - vymview.cpp - winter.cpp - warningdialog.cpp - xlink.cpp - xlinkitem.cpp - xlinkobj.cpp - xml-base.cpp - xml-vym.cpp - xml-freemind.cpp - xmlobj.cpp - xsltproc.cpp - ) - -set ( vym_UIS - attributewidget.ui - branchpropeditor.ui - exporthtmldialog.ui - extrainfodialog.ui - editxlinkdialog.ui - historywindow.ui - lineeditdialog.ui - scripteditor.ui - showtextdialog.ui - warningdialog.ui - ) -QT4_WRAP_UI(UIS ${vym_UIS}) - -set ( vym_TRS - lang/vym_de_DE.ts - lang/vym_en.ts - lang/vym_es.ts - lang/vym_fr.ts - lang/vym_it.ts - lang/vym_pt_BR.ts - lang/vym_ru.ts - lang/vym_sv.ts - lang/vym_zh_CN.ts - lang/vym_zh_TW.ts - lang/vym_cs_CZ.ts - ) -QT4_ADD_TRANSLATION(TRS ${vym_TRS}) - -set ( vym_MOCS - aboutdialog.h - branchpropeditor.h - bugagent.h - dockeditor.h - downloadagent.h - editxlinkdialog.h - exportoofiledialog.h - exporthtmldialog.h - extrainfodialog.h - findwidget.h - findresultwidget.h - findresultmodel.h - headingeditor.h - highlighter.h - historywindow.h - lineeditdialog.h - mainwindow.h - mapeditor.h - mysortfilterproxymodel.h - noteeditor.h - process.h - scripteditor.h - showtextdialog.h - slidecontrolwidget.h - slideeditor.h - slidemodel.h - taskeditor.h - taskmodel.h - treedelegate.h - treeeditor.h - treemodel.h - texteditor.h - vymmodel.h - vymview.h - winter.h - warningdialog.h - ) -if( NOT NO_DBUS ) - add_definitions(-DVYM_DBUS) - list(APPEND vym_HDRS adaptormodel.h adaptorvym.h) - list(APPEND vym_SRCS adaptormodel.cpp adaptorvym.cpp) - list(APPEND vym_MOCS adaptormodel.h adaptorvym.h) -endif( NOT NO_DBUS ) -QT4_WRAP_CPP(MOCS ${vym_MOCS}) - - - -if( WIN32 ) - set( vym_SRCS ${vym_SRCS} mkdtemp.cpp vym.rc ) -endif( WIN32 ) - -add_executable ( vym WIN32 ${vym_SRCS} ${UIS} ${RSCS} ${TRS} ${MOCS} ) -target_link_libraries ( vym ${QT_QTMAIN_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ) -if( NOT NO_DBUS ) - target_link_libraries( vym ${QT_QTDBUS_LIBRARY} ) -endif( NOT NO_DBUS ) - -install( TARGETS vym RUNTIME DESTINATION bin ) - -set( _installfolders demos exports flags icons macros scripts styles ) -install( DIRECTORY ${_installfolders} DESTINATION share/vym ) -install( FILES ${TRS} DESTINATION share/vym/lang ) +cmake_minimum_required(VERSION 3.12) + +project(ViewYourMind-release) + +find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED) + +set(QtComponents + LinguistTools + Network + PrintSupport + Script + Svg + Widgets + Xml +) + +set(QtLibraries + Qt5::Network + Qt5::PrintSupport + Qt5::Script + Qt5::Svg + Qt5::Widgets + Qt5::Xml +) + +# Switch on Debug mode with one of below: +# cmake -DCMAKE_BUILD_TYPE=Debug . +# set(CMAKE_BUILD_TYPE Debug) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +# On Linux DBUS is used for IPC with vym +# On openSUSE install it using: zypper install dbus-1-devel + +if (UNIX) + find_package(DBus1) + + if(DBus1_FOUND) + LIST(APPEND QtComponents DBus) + LIST(APPEND QtLibraries Qt5::DBus) + endif() +endif() + +if(WIN32) + set(OPENSSL_ROOT_DIR "C:/OpenSSL-Win64") + find_package(OpenSSL) + + if( OPENSSL_FOUND ) + include_directories(${OPENSSL_INCLUDE_DIRS}) + link_directories(${OPENSSL_LIBRARIES}) + message(STATUS "Using OpenSSL version: ${OPENSSL_VERSION}") + else() + message(STATUS "No openSSL found?!") + # Error; with REQUIRED, pkg_search_module() will throw an error by it's own + endif() + + #target_link_libraries(${YOUR_TARGET_HERE} ${OPENSSL_LIBRARIES}) + #target_link_libraries(project_name /path/of/libssl.so /path/of/libcrypto.so) + + set(CMAKE_INSTALL_DATAROOTDIR ".") + endif() + +include(GNUInstallDirs) + +find_package(Qt5 COMPONENTS ${QtComponents} REQUIRED) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/forms") + +get_target_property(QtLibraryType Qt5::Widgets TYPE) + +if(QtLibraryType STREQUAL STATIC_LIBRARY) + message(STATUS "Static Qt linkage") + list(APPEND QtLibraries Qt5::QSvgPlugin) +endif() + +include_directories( + ${CMAKE_SOURCE_DIR} +) + +# Source files +file(GLOB VymSources RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp") + +if(WIN32) + list(APPEND VymSources + src/mkdtemp.cpp + vym.rc + ) + ADD_COMPILE_DEFINITIONS(_USE_MATH_DEFINES) +endif() + + +# Add DBUS interfaces, if DBUS is available on platform +if(DBus1_FOUND) + list(APPEND VymSources src/dbus/adaptormodel.cpp src/dbus/adaptorvym.cpp) + include_directories(${CMAKE_SOURCE_DIR}/src/dbus ${CMAKE_SOURCE_DIR}/src) + ADD_COMPILE_DEFINITIONS(VYM_DBUS) +endif() + +# Translations (release) + + # To update the translation files based on source code changes + # first call manually + # lupdate-qt5 src/ -ts lang/*.ts + # + # Qt6 will have a dedicated macro: + # https://doc.qt.io/qt-6/qtlinguist-cmake-qt-add-lrelease.html + +#file(GLOB ts_files ABSOLUTE ${CMAKE_BINARY_DIR} "lang/*.ts") +file(GLOB ts_files RELATIVE ${CMAKE_SOURCE_DIR} "lang/*.ts") +message(STATUS "Creating ${CMAKE_BINARY_DIR}/translations") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/translations") +set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/translations) +#set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION ${CMAKE_SOURCE_DIR}/translations) + +#QT5_create_translation(qm_files ${CMAKE_SOURCE_DIR} ${ts_files}) +#QT5_create_translation(qm_files ${CMAKE_BINARY_DIR} ${ts_files}) +#QT5_create_translation(qm_files ${CMAKE_SOURCE_DIR}/src) + +QT5_add_translation(qm_files ${ts_files}) +add_compile_definitions(CMAKE_SOURCE_DIR) + +message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") +message(STATUS "ts_files: ${ts_files}") +message(STATUS "qm_files: ${qm_files}") + +ADD_COMPILE_DEFINITIONS(VYMBASEDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") + +add_executable(vym ${VymSources} vym.qrc ${qm_files}) +target_link_libraries(vym ${QtLibraries}) + +if(WIN32) + set_target_properties(vym PROPERTIES WIN32_EXECUTABLE TRUE) + install(TARGETS vym DESTINATION "${CMAKE_INSTALL_PREFIX}") +else() + install(TARGETS vym DESTINATION bin) +endif() + +if(APPLE) + message(STATUS "Detected APPLE") + set_target_properties(vym PROPERTIES MACOSX_BUNDLE TRUE ) + + # Add property to Info.plist + set(MACOSX_BUNDLE_ICON_FILE vym.icns) + + # tell CMake where to find and install the file itself + set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/icons/vym.icns) + set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") + +#FIXME-0 add_executable(vym MACOSX_BUNDLE main.cpp ${APP_ICON_MACOSX}) +target_sources(vym PUBLIC ${APP_ICON_MACOSX}) +endif() + +add_custom_target(make-translations-directory ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/translations) +add_dependencies(vym make-translations-directory) + +install(DIRECTORY demos DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}) +install(DIRECTORY doc DESTINATION ${CMAKE_INSTALL_DOCDIR} FILES_MATCHING PATTERN "*.pdf") +install(FILES doc/vym.1.gz DESTINATION ${CMAKE_INSTALL_MANDIR}) +install(FILES README.md LICENSE.txt DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(DIRECTORY exports flags icons macros ${CMAKE_BINARY_DIR}/translations scripts styles DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}) + +if(UNIX) + install(FILES icons/vym.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps) + file(CREATE_LINK ../apps/vym.png application-x-vym.png SYMBOLIC) + install(FILES ${CMAKE_BINARY_DIR}/application-x-vym.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/mimetypes) + install(FILES config/vym.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mime/packages) + install(FILES config/vym.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) +endif()