Mercurial > trustbridge
view ui/CMakeLists.txt @ 1203:b4185dd3810f
(issue68) Added license information in new README.
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Tue, 23 Sep 2014 14:51:53 +0200 |
parents | 3ee529f42974 |
children | 60927efa48cc |
line wrap: on
line source
# Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik # Software engineering by Intevation GmbH # # This file is Free Software under the GNU GPL (v>=2) # and comes with ABSOLUTELY NO WARRANTY! # See LICENSE.txt for details. include_directories(${Qt5Widgets_INCLUDE_DIRS}) include_directories(${POLARSSL_INCLUDE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/common) include_directories(${CMAKE_BINARY_DIR}/common) add_definitions(${Qt5Widgets_DEFINITIONS}) message(STATUS "Using ${DOWNLOAD_SERVER} as download server for updates.") add_definitions(-DSERVER_URL="${DOWNLOAD_SERVER}") find_package(Qt5LinguistTools) find_package(CURL) include_directories(${CURL_INCLUDE_DIRS}) # Common code is used in either the client or the administrator # application or in unit tests. set(UICOMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/certificatelist.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/downloader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sslconnection_bare.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sslconnection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sslhelp.cpp ) if (${CURL_FOUND} AND ${USE_CURL}) set(UICOMMON_SOURCES ${UICOMMON_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/sslconnection_curl.cpp) add_definitions(-DUSE_CURL -DCURL_STATICLIB) elseif (${USE_CURL}) MESSAGE(FATAL_ERROR "libcurl not found but usage of curl is requested.") endif() # Cmake does not correctly identify gcc windres when cross compiling # making this line neccessary to set the correct flags for it. # See: http://public.kitware.com/Bug/view.php?id=11773 SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -Ocoff <SOURCE> <OBJECT>") set(TRUSTBRIDGE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificatelistwidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificateitemwidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/separatoritemdelegate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/installwrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_win.cpp ${CMAKE_CURRENT_SOURCE_DIR}/processhelp_linux.cpp ${CMAKE_CURRENT_SOURCE_DIR}/processwaitdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/textoverlaybutton.cpp ${CMAKE_CURRENT_SOURCE_DIR}/taskscheduler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/trayicon.cpp ${CMAKE_CURRENT_SOURCE_DIR}/proxysettingsdlg.cpp ${CERTIFICATELIST_SOURCES} ${DOWNLOADER_SOURCES} ) set(ADMINISTRATOR_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/administratorwindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificatetablemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificatetabledelegate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/createinstallerdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/aboutdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/createcertlistdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificatediffdialog.cpp ${CERTIFICATELIST_SOURCES} ) # Seperated to make it easier to include the sources in tests set(TRUSTBRIDGE_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc ${CMAKE_CURRENT_SOURCE_DIR}/certs.qrc ${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc ) set(ADMINISTRATOR_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc ${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc ) if(UNIX) # See: https://bugreports.qt-project.org/browse/QTBUG-35918 # XCB_EXTRA_LIBS should be gotten automatically. # The following list is taken from the .pri file get_target_property(_loc Qt5::Widgets LOCATION) get_filename_component(_qtpath ${_loc} PATH) set(XCB_EXTRA_LIBS -L${_qtpath} -lQt5DBus -lQt5Gui -lQt5Core -lQt5PlatformSupport -lX11 -lX11-xcb -lxcb -lxcb-static -lXrender -lSM -lICE -ldbus-1 -lm -ldl -lrt -lpthread ) set(EXTRA_STATIC_LIBS -lpthread -ldl Qt5::QXcbIntegrationPlugin ${XCB_EXTRA_LIBS}) elseif(WIN32) get_target_property(_loc Qt5::Widgets LOCATION) get_filename_component(_qtpath ${_loc} PATH) set(WINDOWS_EXTRA_LIBS -L${_qtpath} -lwinspool -lshlwapi -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lQt5Core -lole32 -lmstask -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lpcre16) set(EXTRA_STATIC_LIBS Qt5::QWindowsIntegrationPlugin ${WINDOWS_EXTRA_LIBS} -lwinhttp -lcrypt32) add_definitions(-DUNICODE) endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") generate_cppcheck(SOURCES ${CINST_SOURCES} ${TRUSTBRIDGE_SOURCES} TARGET_NAME custom_cppcheck) add_dependencies(static_check custom_cppcheck) # Adding resources here in an extra variable to enable reuse of # TRUSTBRIDGE_SOURCES in the test subdirectory. set(TRUSTBRIDGE_MAIN_WITH_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/img/icon.rc) qt5_add_resources(TRUSTBRIDGE_MAIN_WITH_RESOURCES ${TRUSTBRIDGE_RESOURCES}) set(ADMINISTRATOR_MAIN_WITH_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/administrator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/img/icon.rc) qt5_add_resources(ADMINISTRATOR_MAIN_WITH_RESOURCES ${ADMINISTRATOR_RESOURCES}) if(WIN32) # This option causes cmake to use the appropiate liker flags to hide # the console Window on Windows set (_add_executable_params WIN32) # Add the event messages if (MINGW) STRING(REGEX REPLACE "windres" "windmc" MC_COMPILER ${CMAKE_RC_COMPILER}) else() # untested set(MC_COMPILER "mc.exe") endif() add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/common/events.h ${CMAKE_BINARY_DIR}/common/events.rc ${CMAKE_BINARY_DIR}/common/MSG00407.bin ${CMAKE_BINARY_DIR}/common/MSG00409.bin COMMAND ${MC_COMPILER} ${CMAKE_SOURCE_DIR}/common/events.mc -r ${CMAKE_BINARY_DIR}/common -h ${CMAKE_BINARY_DIR}/common DEPENDS ${CMAKE_SOURCE_DIR}/common/events.mc) set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/img/icon.rc APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/common/events.rc) endif() if(Qt5LinguistTools_FOUND) # Include translation as a resource # This works in the source directory to enable the rcc dependencies to be found # and it also updates the currently available localization. # This would probably be better placed in a macro configure_file(l10n/administrator.qrc.in administrator.qrc) qt5_add_resources(ADMINISTRATOR_L10N ${CMAKE_CURRENT_BINARY_DIR}/administrator.qrc) qt5_create_translation(ADMINISTRATOR_TRANSLATION ${ADMINISTRATOR_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/l10n/administrator_de_DE.ts) add_executable(trustbridge-admin ${_add_executable_params} ${ADMINISTRATOR_MAIN_WITH_RESOURCES} ${ADMINISTRATOR_L10N} ${ADMINISTRATOR_TRANSLATION} ) configure_file(l10n/trustbridge.qrc.in trustbridge.qrc) qt5_add_resources(TRUSTBRIDGE_L10N ${CMAKE_CURRENT_BINARY_DIR}/trustbridge.qrc) qt5_create_translation(TRUSTBRIDGE_TRANSLATION ${TRUSTBRIDGE_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/l10n/trustbridge_de_DE.ts) add_executable(trustbridge ${_add_executable_params} ${TRUSTBRIDGE_MAIN_WITH_RESOURCES} ${TRUSTBRIDGE_L10N} ${TRUSTBRIDGE_TRANSLATION} ) else() message (STATUS "WARNING: Could not find qt linguist tools. Translation will not be included.") add_executable(trustbridge-admin ${_add_executable_params} ${ADMINISTRATOR_MAIN_WITH_RESOURCES}) add_executable(trustbridge ${_add_executable_params} ${TRUSTBRIDGE_MAIN_WITH_RESOURCES}) endif() add_library(ui_common STATIC ${UICOMMON_SOURCES}) add_library(tbadminlib STATIC ${ADMINISTRATOR_SOURCES}) add_library(tblib STATIC ${TRUSTBRIDGE_SOURCES}) target_link_libraries(trustbridge-admin tbadminlib Qt5::Widgets ui_common trustbridge_common ${POLARSSL_LIBRARIES} ${EXTRA_STATIC_LIBS} ${PROFILING_LIBS}) target_link_libraries(trustbridge tblib Qt5::Widgets ui_common trustbridge_common ${CURL_LIBRARIES} ${POLARSSL_LIBRARIES} ${EXTRA_STATIC_LIBS} ${PROFILING_LIBS}) # Tests add_subdirectory(tests) install(TARGETS trustbridge DESTINATION bin) install(TARGETS trustbridge-admin DESTINATION bin) if(UNIX) configure_file(trustbridge-tray-starter.sh trustbridge-tray-starter.sh COPYONLY) install(FILES trustbridge-tray-starter.sh DESTINATION bin) endif() # Strip the binaries if (WIN32) add_custom_command( TARGET trustbridge POST_BUILD COMMAND ${CMAKE_STRIP} trustbridge.exe ) add_custom_command( TARGET trustbridge-admin POST_BUILD COMMAND ${CMAKE_STRIP} trustbridge-admin.exe ) if (NOT RELEASE_BUILD) add_custom_command( TARGET trustbridge POST_BUILD COMMAND ${OSSLSIGNCODE_EXECUTABLE} sign -certs ${CMAKE_SOURCE_DIR}/ui/tests/data/codesign/codesigning.pem -key ${CMAKE_SOURCE_DIR}/ui/tests/data/codesign/codesigning.key -h sha256 -in ${CMAKE_CURRENT_BINARY_DIR}/trustbridge.exe -out ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-signed.exe && mv ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-signed.exe ${CMAKE_CURRENT_BINARY_DIR}/trustbridge.exe ) add_custom_command( TARGET trustbridge-admin POST_BUILD COMMAND ${OSSLSIGNCODE_EXECUTABLE} sign -certs ${CMAKE_SOURCE_DIR}/ui/tests/data/codesign/codesigning.pem -key ${CMAKE_SOURCE_DIR}/ui/tests/data/codesign/codesigning.key -h sha256 -in ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-admin.exe -out ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-admin-signed.exe && mv ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-admin-signed.exe ${CMAKE_CURRENT_BINARY_DIR}/trustbridge-admin.exe ) endif() else() add_custom_command( TARGET trustbridge POST_BUILD COMMAND strip trustbridge ) add_custom_command( TARGET trustbridge-admin POST_BUILD COMMAND strip trustbridge-admin ) endif()