blob: 5e1b55036c96da112823bfbdc4df5061447e5e64 (
plain) (
tree)
|
|
################################################################################
# General
################################################################################
PROJECT(pvs2)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
SET(EXTRA_C_FLAGS "" CACHE STRING "Additional options to pass to C compiler")
SET(EXTRA_CXX_FLAGS "" CACHE STRING "Additional options to pass to C++ compiler")
# set compiler optimizations for debug and release
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wunused -Wunreachable-code -pedantic")
SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
# -Wshadow spams too much :/
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${EXTRA_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${EXTRA_CXX_FLAGS}")
# local cmake modules
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# this command finds libraries and sets all required variables
FIND_PACKAGE(Qt5 COMPONENTS Widgets Network X11Extras LinguistTools Svg REQUIRED)
FIND_PACKAGE(X11 REQUIRED)
FIND_PACKAGE(VNC REQUIRED)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
# some includes
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${X11_INCLUDE_DIR}
)
IF(X11_Xscreensaver_FOUND)
ADD_DEFINITIONS(-DX11_Xscreensaver_FOUND)
ENDIF()
IF(X11_dpms_FOUND)
ADD_DEFINITIONS(-DX11_dpms_FOUND)
ENDIF()
#IF(NOT X11_XTest_FOUND)
# MESSAGE(FATAL_ERROR "Could not find X11 extension XTest or its developer files.")
#ENDIF()
#IF(NOT X11_Xinput_FOUND)
# MESSAGE(FATAL_ERROR "Could not find X11 extension Xinput or its developer files.")
#ENDIF()
# TODO: Detect this somehow
#SET(SYSDEP_SUFFIX _X11)
################################################################################
# Variables
################################################################################
# pvsmgr
FILE(GLOB PVSMGR_SRCS
src/server/*.cpp
src/server/*/*.cpp
src/server/util/platform/*.cpp
src/shared/*.cpp
)
# pvsclient
FILE(GLOB PVSCLIENT_SRCS
src/client/*.cpp
src/client/*/*.cpp
src/client/util/platform/*.cpp
src/shared/*.cpp
)
################################################################################
# Qt
################################################################################
# .ui files
FILE(GLOB PVSMGR_UIS
gui/server_normal/*.ui
)
FILE(GLOB PVSCLIENT_UIS
gui/client/*.ui
)
# .qrc files
FILE(GLOB PVSMGR_RC_SRCS
pvsmgr.qrc
)
FILE(GLOB PVSCLIENT_RC_SRCS
pvsclient.qrc
)
# i18n
FILE(GLOB PVSMGR_TSS
i18n/server/*.ts
)
FILE(GLOB PVSCLIENT_TSS
i18n/client/*.ts
)
# this will run uic on .ui files
QT5_WRAP_UI(PVSMGR_UI_HDRS ${PVSMGR_UIS})
QT5_WRAP_UI(PVSCLIENT_UI_HDRS ${PVSCLIENT_UIS})
# this will run moc
#QT4_WRAP_CPP(PVSMGR_MOC_SRCS ${PVSMGR_MOC_HDRS})
#QT4_WRAP_CPP(PVSCLIENT_MOC_SRCS ${PVSCLIENT_MOC_HDRS})
option(UPDATE_TRANSLATIONS "Update .ts files (WARNING: make clean will delete the .ts files!)" OFF)
if(PVSMGR_TSS)
if (UPDATE_TRANSLATIONS)
set(FILES_TO_TRANSLATE ${PVSMGR_SRCS} ${PVSMGR_UIS})
QT5_CREATE_TRANSLATION(PVSMGR_QMS ${FILES_TO_TRANSLATE} ${PVSMGR_TSS} OPTIONS -noobsolete)
message(STATUS ".tr files have been updated")
else (UPDATE_TRANSLATIONS)
QT5_ADD_TRANSLATION(PVSMGR_QMS ${PVSMGR_TSS})
endif (UPDATE_TRANSLATIONS)
# # write a resource file for qm files
# set(resource_file_content "<RCC>\n <qresource prefix=\"/\">\n")
# foreach(file ${PVSMGR_QMS})
# get_filename_component(filename ${file} NAME)
# set(resource_file_content "${resource_file_content} <file>${filename}</file>\n")
# endforeach(file)
# set(resource_file_content "${resource_file_content} </qresource>\n</RCC>\n")
# file(WRITE "${CMAKE_BINARY_DIR}/ts_pvsmgr.qrc" "${resource_file_content}")
# set(PVSMGR_RESOURCES ${PVSMGR_RESOURCES} "${CMAKE_BINARY_DIR}/ts_pvsmgr.qrc")
endif(PVSMGR_TSS)
if(PVSCLIENT_TSS)
if (UPDATE_TRANSLATIONS)
set(FILES_TO_TRANSLATE ${PVSCLIENT_SRCS} ${PVSCLIENT_UIS})
QT5_CREATE_TRANSLATION(PVSCLIENT_QMS ${FILES_TO_TRANSLATE} ${PVSCLIENT_TSS} OPTIONS -noobsolete)
message(STATUS ".tr files have been updated")
else (UPDATE_TRANSLATIONS)
QT5_ADD_TRANSLATION(PVSCLIENT_QMS ${PVSCLIENT_TSS})
endif (UPDATE_TRANSLATIONS)
# # write a resource file for qm files
# set(resource_file_content "<RCC>\n <qresource prefix=\"/\">\n")
# foreach(file ${PVSCLIENT_QMS})
# get_filename_component(filename ${file} NAME)
# set(resource_file_content "${resource_file_content} <file>${filename}</file>\n")
# endforeach(file)
# set(resource_file_content "${resource_file_content} </qresource>\n</RCC>\n")
# file(WRITE "${CMAKE_BINARY_DIR}/ts_pvsclient.qrc" "${resource_file_content}")
# set(PVSCLIENT_RESOURCES ${PVSCLIENT_RESOURCES} "${CMAKE_BINARY_DIR}/ts_pvsclient.qrc")
endif(PVSCLIENT_TSS)
# this will run rcc on .qrc files
QT5_ADD_RESOURCES(PVSMGR_RCS ${PVSMGR_RC_SRCS})
QT5_ADD_RESOURCES(PVSCLIENT_RCS ${PVSCLIENT_RC_SRCS})
################################################################################
# Build
################################################################################
ADD_EXECUTABLE(pvsmgr
${PVSMGR_SRCS}
${PVSMGR_RCS}
# ${PVSMGR_MOC_SRCS}
${PVSMGR_UI_HDRS}
${PVSMGR_RC_SRCS}
${PVSMGR_QMS}
)
ADD_EXECUTABLE(pvsclient
${PVSCLIENT_SRCS}
${PVSCLIENT_RCS}
# ${PVSCLIENT_MOC_SRCS}
${PVSCLIENT_UI_HDRS}
${PVSCLIENT_RC_SRCS}
${PVSCLIENT_QMS}
)
# link
TARGET_LINK_LIBRARIES(pvsmgr
Qt5::Network
Qt5::Widgets
Qt5::Svg
Qt5::X11Extras
# ${VNC_LIBRARIES}
${X11_LIBRARIES}
${X11_Xscreensaver_LIB}
)
TARGET_LINK_LIBRARIES(pvsclient
Qt5::Network
Qt5::Widgets
${VNC_LIBRARIES}
${X11_LIBRARIES}
)
SET_PROPERTY(TARGET pvsmgr PROPERTY COMPILE_DEFINITIONS MAINWINDOW_USE_NORMALGUI)
# install
INSTALL(TARGETS pvsmgr pvsclient RUNTIME DESTINATION bin)
#INSTALL(PROGRAMS misc/pvs-vncsrv DESTINATION bin)
#INSTALL(FILES misc/pvsclient.conf misc/pvsmgr.conf DESTINATION /etc/openslx)
#INSTALL(FILES misc/pvsclient.desktop DESTINATION /etc/xdg/autostart)
# uninstall
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Uninstall.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/Uninstall.cmake"
IMMEDIATE @ONLY
)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/Uninstall.cmake"
)
# package
SET( CPACK_GENERATOR "DEB" )
SET( CPACK_SET_DESTDIR "ON" )
SET( CPACK_PACKAGE_NAME "pvs" )
SET( CPACK_PACKAGE_VERSION_MAJOR "3" )
SET( CPACK_PACKAGE_VERSION_MINOR "1" )
SET( CPACK_PACKAGE_VERSION_PATCH "2" )
SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pool Video Switch" )
SET( CPACK_PACKAGE_DESCRIPTION "")
SET( CPACK_PACKAGE_CONTACT "Johann Latocha <johann@latocha.de>" )
SET( CPACK_DEBIAN_PACKAGE_DEPENDS "libvncserver0 (>= 0.9.3.dfsg.1-2), libqtgui4 (>= 4:4.5.3-4), libqt4-dbus (>= 4:4.5.3-4), libqt4-network (>= 4:4.5.3-4)" )
SET( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386" )
SET( CPACK_DEBIAN_PACKAGE_SECTION "Network" )
SET( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
SET( CPACK_DEBIAN_PACKAGE_RECOMMENDS "x11vnc (>= 0.9.9-1)" )
INCLUDE( CPack )
|