1 # Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 IF (QT_VERSION VERSION_LESS "5.0")
21 INCLUDE(${QT_USE_FILE})
24 # This MACRO uses the following vars
25 # - QT_LRELEASE_EXECUTABLE : (given by default by FindQT.cmake)
27 # tsfiles containing all ts files to be compiled.
28 # installdir contains directory (relative to install_prefix) where to install files after compilation of ts files too qm.
29 MACRO(QT_INSTALL_TS_RESOURCES tsfiles installdir)
30 FOREACH(_input ${tsfiles})
31 GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
32 SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_name}.qm)
33 SET(_cmd_${_name} ${QT_LRELEASE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} -qm ${_output})
34 ADD_CUSTOM_TARGET(QT_INSTALL_TS_RESOURCES_${_name} ALL COMMAND ${_cmd_${_name}} DEPENDS ${_input})
35 INSTALL(FILES ${_output} DESTINATION ${installdir})
37 ENDMACRO(QT_INSTALL_TS_RESOURCES)
40 IF (QT_VERSION VERSION_LESS "5.0")
44 # Workaround to avoid problem with bug in moc preprocessor:
45 # The problem is reproduced on Linux in case if native system Qt is installed
46 # and "-I/usr/include" parameter is presented in the moc command line before
47 # custom Qt includes. This bug takes place in Qt-5.6.0 and newer. To avoid this
48 # bug move "-I/usr/include" parameter in the "moc parameters" file to the end
49 # of the "include section".
52 GET_FILENAME_COMPONENT(IT ${IT} ABSOLUTE)
53 GET_FILENAME_COMPONENT(PFILE ${IT} NAME_WE)
54 SET(OUTFILE ${CMAKE_CURRENT_BINARY_DIR}/moc_${PFILE}.cpp_parameters)
57 SET(IS_INCLUDE_SECTION TRUE)
58 SET(HAS_SYSTEM_INC FALSE)
59 FILE(READ ${OUTFILE} CONTENT)
60 STRING(REGEX REPLACE "\n" ";" CONTENT "${CONTENT}")
61 list(REMOVE_DUPLICATES CONTENT)
63 IF("${S}" MATCHES "^-I")
64 IF("${S}" STREQUAL "-I/usr/include")
65 SET(HAS_SYSTEM_INC TRUE)
67 SET(NEW_CONTENT ${NEW_CONTENT} "${S}\n")
70 SET(IS_INCLUDE_SECTION FALSE)
72 IF(NOT IS_INCLUDE_SECTION)
74 SET(NEW_CONTENT ${NEW_CONTENT} "-I/usr/include\n")
75 SET(HAS_SYSTEM_INC FALSE)
77 SET(NEW_CONTENT ${NEW_CONTENT} "${S}\n")
80 FILE(WRITE ${OUTFILE} ${NEW_CONTENT})
88 IF (QT_VERSION VERSION_LESS "5.0")
95 MACRO(QT_ADD_RESOURCES)
96 IF (QT_VERSION VERSION_LESS "5.0")
97 QT4_ADD_RESOURCES(${ARGN})
99 QT5_ADD_RESOURCES(${ARGN})
101 ENDMACRO(QT_ADD_RESOURCES)