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 Release) 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 -Wno-multichar -Wno-error=deprecated-declarations ${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 "\n \n") foreach(file ${VMCHOOSER_QMS}) get_filename_component(filename ${file} NAME) set(resource_file_content "${resource_file_content} ${filename}\n") endforeach(file) set(resource_file_content "${resource_file_content} \n\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)