Strip newlines from 'reason' fields in settings
[quassel.git] / cmake / modules / QuasselMacros.cmake
index 8e453e2..f0791ec 100644 (file)
@@ -1,31 +1,52 @@
-# 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)
+
+  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 ${CMAKE_SOURCE_DIR}/po/${basename}.po)
+  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 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
@@ -41,7 +62,8 @@ macro(generate_qm outvar basename)
   set(output ${CMAKE_BINARY_DIR}/po/${basename}.qm)
   add_custom_command(OUTPUT ${output}
           COMMAND ${QT_LRELEASE_EXECUTABLE}
-          ARGS ${input}
+          ARGS -silent
+               ${input}
           DEPENDS ${basename}.ts)
   set(${outvar} ${output})
 endmacro(generate_qm outvar basename)