X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=cmake%2Fmodules%2FQuasselMacros.cmake;h=f0791ec6366eb6b233f04b85421ed3ba9232fcf6;hp=5657c8a18cee0973cb388d300e55532ef5c7e3ae;hb=ff81aaec156b8dc2e12f49286fd69e55f215af29;hpb=ad79428b72613730f61b0b3fdb18afa21eee3cc7 diff --git a/cmake/modules/QuasselMacros.cmake b/cmake/modules/QuasselMacros.cmake index 5657c8a1..f0791ec6 100644 --- a/cmake/modules/QuasselMacros.cmake +++ b/cmake/modules/QuasselMacros.cmake @@ -1,31 +1,69 @@ -# This macro sets variables for additional Qt modules. -# We need this because targets need different Qt4 modules, i.e. different libs -# and defines. We can't simply include UseQt4 several times, since definitions add up. -# We workaround this by using our own macro to figure out what to add. +# This macro sets variables for the Qt modules we need. -macro(setup_qt4_variables) +macro(setup_qt_variables) set(QUASSEL_QT_LIBRARIES ) + set(QUASSEL_QT_INCLUDES ${QT_INCLUDE_DIR}) # Qt4 + set(QUASSEL_QT_DEFINITIONS ${QT_DEFINITIONS}) # Qt4 + IF(WIN32) - set(MAIN MAIN) + set(MAIN Main) ENDIF(WIN32) - foreach(qtmod CORE ${ARGV} ${MAIN}) - set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY}) - if(STATIC) - set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_${qtmod}_LIB_DEPENDENCIES}) - endif(STATIC) - endforeach(qtmod ${ARGV}) - set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES}) -endmacro(setup_qt4_variables) + foreach(qtmod Core ${ARGV} ${MAIN}) + if(WITH_QT5) + find_package(Qt5${qtmod} ${QT_MIN_VERSION} REQUIRED) + list(APPEND QUASSEL_QT_LIBRARIES ${Qt5${qtmod}_LIBRARIES}) + list(APPEND QUASSEL_QT_INCLUDES ${Qt5${qtmod}_INCLUDE_DIRS}) + list(APPEND QUASSEL_QT_DEFINITIONS ${Qt5${qtmod}_DEFINITIONS} ${Qt5${qtmod}_EXECUTABLE_COMPILE_FLAGS}) + else(WITH_QT5) + string(TOUPPER ${qtmod} QTMOD) + list(APPEND QUASSEL_QT_LIBRARIES ${QT_QT${QTMOD}_LIBRARY}) + if(STATIC) + list(APPEND QUASSEL_QT_LIBRARIES ${QT_QT${QTMOD}_LIB_DEPENDENCIES}) + endif(STATIC) + list(APPEND QUASSEL_QT_INCLUDES ${QT_QT${QTMOD}_INCLUDE_DIR}) + list(APPEND QUASSEL_QT_DEFINITIONS -DQT_QT${QTMOD}_LIB) + endif(WITH_QT5) + endforeach(qtmod) -# This generates a .qm from a .po file -macro(generate_qm outvar basename) - set(input ${CMAKE_SOURCE_DIR}/i18n/${basename}.po) - set(output ${CMAKE_BINARY_DIR}/i18n/${basename}.qm) + list(REMOVE_DUPLICATES QUASSEL_QT_LIBRARIES) + list(REMOVE_DUPLICATES QUASSEL_QT_INCLUDES) + list(REMOVE_DUPLICATES QUASSEL_QT_DEFINITIONS) + + # The COMPILE_FLAGS property expects a string, not a list... + set(QUASSEL_QT_COMPILEFLAGS ) + foreach(flag ${QUASSEL_QT_DEFINITIONS}) + set(QUASSEL_QT_COMPILEFLAGS "${QUASSEL_QT_COMPILEFLAGS} ${flag}") + endforeach(flag) + +endmacro(setup_qt_variables) + +# This generates a .ts from a .po file +macro(generate_ts outvar basename) + set(input ${basename}.po) + set(output ${CMAKE_BINARY_DIR}/po/${basename}.ts) add_custom_command(OUTPUT ${output} COMMAND ${QT_LCONVERT_EXECUTABLE} ARGS -i ${input} - -of qm + -of ts -o ${output} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po +# This is a workaround to add (duplicate) strings that lconvert missed to the .ts + COMMAND ${QT_LUPDATE_EXECUTABLE} + ARGS -silent + ${CMAKE_SOURCE_DIR}/src/ + -ts ${output} DEPENDS ${basename}.po) set(${outvar} ${output}) +endmacro(generate_ts outvar basename) + +# This generates a .qm from a .ts file +macro(generate_qm outvar basename) + set(input ${CMAKE_BINARY_DIR}/po/${basename}.ts) + set(output ${CMAKE_BINARY_DIR}/po/${basename}.qm) + add_custom_command(OUTPUT ${output} + COMMAND ${QT_LRELEASE_EXECUTABLE} + ARGS -silent + ${input} + DEPENDS ${basename}.ts) + set(${outvar} ${output}) endmacro(generate_qm outvar basename)