CMakeLists.txt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. cmake_minimum_required(VERSION 3.0)
  2. project(w2midi_qt)
  3. set(CMAKE_CXX_STANDARD 11)
  4. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  5. set(CMAKE_AUTOMOC ON)
  6. set(CMAKE_AUTORCC ON)
  7. set(CMAKE_AUTOUIC ON)
  8. if(CMAKE_VERSION VERSION_LESS "3.7.0")
  9. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  10. endif()
  11. set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra")
  12. set(CMAKE_CXX_FLAGS_RELEASE "-Wall -Wextra -Werror -O2")
  13. set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM TRUE)
  14. find_package(Qt5 COMPONENTS Widgets REQUIRED)
  15. set(TS_FILES
  16. ${CMAKE_SOURCE_DIR}/lang/ru_RU.ts
  17. )
  18. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lang) # create directory for lrelease output (it does not created autmatically by lrelease)
  19. find_package(Qt5 COMPONENTS ${REQUIRED_LIBS} LinguistTools REQUIRED) # finding LinguistTools
  20. #configure_file(icons.qrc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
  21. configure_file(translations.qrc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) # copy translations.qrc file to buld directory. It is needed because rcc searches resources in path relative to .qrc file
  22. qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) # this should regenerate .ts files automatically but currently will remove old one when asking for rebuild. Which is undesirable. See QTBUG-96549 and https://forum.qt.io/topic/130308
  23. set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "lang") # set qm files output directory
  24. qt5_add_translation(QM_FILES ${TS_FILES}) # generate qm files
  25. add_executable(w2midi_qt
  26. main.cpp
  27. cli.cpp
  28. app.cpp
  29. slider.cpp
  30. clickablelabel.cpp
  31. ${QM_FILES}
  32. ${TS_FILES}
  33. ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
  34. icons.qrc
  35. )
  36. target_link_libraries(w2midi_qt Qt5::Widgets)
  37. install(TARGETS w2midi_qt)
  38. install(DIRECTORY icons/hicolor DESTINATION /usr/share/icons/)
  39. install(FILES w2midi_qt.desktop DESTINATION /usr/share/applications/)