summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: c58fa4b8fd251af04ba5946edfafc8aa2064a8af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

# project name
project(vmchooser)

SET(EXTRA_CXX_FLAGS "" CACHE STRING "Additional options to pass to C++ compiler")

set(CMAKE_BUILD_TYPE Debug)
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 -Wno-multichar")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wno-multichar")

set(CMAKE_CXX_STANDARD 11)
# Some cmake versions can't understand the CMAKE_CXX_STANDARD option above?
SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -std=c++11 ${EXTRA_CXX_FLAGS}" )

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

file(GLOB_RECURSE VMCHOOSER_SOURCES src/*.cpp)
file(GLOB_RECURSE VMCHOOSER_UIS src/ui/*.ui)
file(GLOB_RECURSE VMCHOOSER_RESOURCES src/*.qrc)
file(GLOB_RECURSE VMCHOOSER_TSS src/i18n/*.ts)

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

#
# Qt5
#
find_package(Qt5 COMPONENTS Widgets Svg LinguistTools Network Xml REQUIRED)

QT5_WRAP_UI(VMCHOOSER_UI_HEADERS ${VMCHOOSER_UIS})

#include(${QT_USE_FILE})

option(UPDATE_TRANSLATIONS "Update .ts files (WARNING: make clean will delete the .ts files!)" OFF)
if(VMCHOOSER_TSS)
  if (UPDATE_TRANSLATIONS)
    set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${VMCHOOSER_SOURCES} ${VMCHOOSER_UIS})
    QT5_CREATE_TRANSLATION(VMCHOOSER_QMS ${FILES_TO_TRANSLATE} ${VMCHOOSER_TSS} OPTIONS -noobsolete)
    message(STATUS ".tr files have been updated")
  else (UPDATE_TRANSLATIONS)
    QT5_ADD_TRANSLATION(VMCHOOSER_QMS ${VMCHOOSER_TSS})
  endif (UPDATE_TRANSLATIONS)

  # write a resource file for qm files
  set(resource_file_content "<RCC>\n    <qresource prefix=\"/\">\n")
  foreach(file ${VMCHOOSER_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}/translation.qrc" "${resource_file_content}")
  set(VMCHOOSER_RESOURCES ${VMCHOOSER_RESOURCES} "${CMAKE_BINARY_DIR}/translation.qrc")

  #add_custom_target(translations_target DEPENDS ${VMCHOOSER_QMS})
endif(VMCHOOSER_TSS)

QT5_ADD_RESOURCES(VMCHOOSER_RC_SOURCES ${VMCHOOSER_RESOURCES})

#
# build vmchooser
#
add_executable(vmchooser
  ${VMCHOOSER_SOURCES}
  ${VMCHOOSER_UI_HEADERS}
  ${VMCHOOSER_RC_SOURCES}
  ${VMCHOOSER_QMS}
)

target_link_libraries(vmchooser
  Qt5::Widgets
  Qt5::Svg
  Qt5::Network
  Qt5::Xml
)

install(TARGETS vmchooser RUNTIME DESTINATION bin)
install(FILES default.desktop DESTINATION /usr/share/xsessions)
install(DIRECTORY themes DESTINATION /usr/local/share/vmchooser)