Revert "0029369: ShapeFix_Face algorithm does not heal properly the face lying on...
[occt.git] / adm / cmake / qt_macro.cmake
CommitLineData
14bbbdcb 1#qt
2
4f4b8935 3macro (FIND_QT_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
14bbbdcb 4
5 if ("${3RDPARTY_QT_DIR}" STREQUAL "")
6 message (FATAL_ERROR "Empty Qt dir")
7 endif()
8
4f4b8935 9 if (${Qt5_FOUND})
10 #message (STATUS "Qt5 cmake configuration")
11
1fa16152 12 set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}" "${Qt5Quick_INCLUDE_DIRS}")
13 set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}")
14 set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}")
15
16 # processing *.ts files to generate *.qm
17 find_package(Qt5LinguistTools)
18 get_target_property(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION)
19 mark_as_advanced(QT_LRELEASE_EXECUTABLE)
20
21 GET_FILENAME_COMPONENT(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY)
22 MARK_AS_ADVANCED(QT_BINARY_DIR)
4f4b8935 23 else()
4f4b8935 24 #message (STATUS "Qt4 cmake configuration")
14bbbdcb 25 set(PROJECT_INCLUDES ${QT_INCLUDES})
26 if (WIN32)
27 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/QtCored4.lib;${3RDPARTY_QT_DIR}/lib/QtGuid4.lib")
28 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/QtCore4.lib;${3RDPARTY_QT_DIR}/lib/QtGui4.lib")
29 else()
30 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
31 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
32 endif(WIN32)
1fa16152 33 find_program(QT_LRELEASE_EXECUTABLE lrelease)
14bbbdcb 34 endif()
35endmacro()
36
37
410dd2c9 38macro (FIND_AND_WRAP_MOC_FILES HEADER_FILES GENERATED_MOC_FILES)
39 set (GENERATED_MOC_FILES "")
40 foreach (FILE ${HEADER_FILES})
41 # processing only files where Q_OBJECT exists
42 file(STRINGS "${FILE}" LINES REGEX "Q_OBJECT")
43 if(LINES)
44 unset (MOC_FILE)
45 if (${Qt5_FOUND})
46 qt5_wrap_cpp(MOC_FILE ${FILE})
47 else()
48 qt4_wrap_cpp(MOC_FILE ${FILE})
49 endif()
50 #message (STATUS "... Info: next MOC file ${MOC_FILE}")
51 list(APPEND ${GENERATED_MOC_FILES} ${MOC_FILE})
52 endif(LINES)
14bbbdcb 53 endforeach (FILE)
54
55endmacro()
56
57macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
58 if(EXISTS "${RESOURCE_FILE_NAME}")
4f4b8935 59 if (${Qt5_FOUND})
60 qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
61 else()
14bbbdcb 62 qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
63 # suppress some GCC warnings coming from source files generated from .qrc resources
64 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
65 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
66 endif()
14bbbdcb 67 endif()
68 endif()
69endmacro()
1fa16152 70
71macro (FIND_AND_INSTALL_TS_FILE RESOURCE_FILE_NAME TARGET_FOLDER QM_FILES)
72 if(EXISTS "${RESOURCE_FILE_NAME}")
73 GET_FILENAME_COMPONENT(_name ${RESOURCE_FILE_NAME} NAME_WE)
74 SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_name}.qm)
75 SET(_cmd_${_name} ${QT_LRELEASE_EXECUTABLE} ${RESOURCE_FILE_NAME} -qm ${_output})
76
77 set(TARGET_NAME ${_name}_resources)
78
79 if (NOT TARGET "${TARGET_NAME}")
80 add_custom_target(${TARGET_NAME} ALL COMMAND ${_cmd_${_name}} DEPENDS ${RESOURCE_FILE_NAME})
81 set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "${TARGET_FOLDER}")
82
83 list (APPEND ${QM_FILES} "${_output}")
84 endif()
85 endif()
86endmacro()
87
88macro (FIND_AND_INSTALL_QT_RESOURCES OCCT_PACKAGE RESOURCE_FILES)
89 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" TS_FILES REGEX ".+[.]ts")
90 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" QRC_FILES REGEX ".+[.]qrc")
91
92 string (FIND "${OCCT_PACKAGE}" "/" _index)
93 if (_index GREATER -1)
94 math (EXPR _index "${_index}")
95 string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME)
96 else()
97 set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}")
98 endif(_index GREATER -1)
99
100 #message("QRC files are: ${QRC_FILES} in ${OCCT_PACKAGE}")
101 foreach (QRC_FILE ${QRC_FILES})
102 set (QRC_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${QRC_FILE}")
103 if (EXISTS ${QRC_FILE_RELATIVE})
104 FIND_AND_WRAP_RESOURCE_FILE(${QRC_FILE_RELATIVE} RCC_FILES)
105 list (APPEND ${RESOURCE_FILES} "${RCC_FILES}")
106 endif()
107 endforeach()
108
109 #message("TS files are: ${TS_FILES} in ${OCCT_PACKAGE}")
110 foreach (TS_FILE ${TS_FILES})
111 set (TS_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${TS_FILE}")
112 FIND_AND_INSTALL_TS_FILE(${TS_FILE_RELATIVE} "${TARGET_FOLDER}/${CURRENT_MODULE}" QM_FILES)
113 if (EXISTS ${TS_FILE_RELATIVE})
114 list (APPEND ${RESOURCE_FILES} "${TS_FILE_RELATIVE}")
115 endif()
116 endforeach()
117
118 foreach (QM_FILE ${QM_FILES})
119 INSTALL(FILES ${QM_FILE} DESTINATION "${INSTALL_DIR_RESOURCE}/samples")
120 #message("install *.qm files (${QM_FILE}) to: ${INSTALL_DIR_RESOURCE}/samples")
121 endforeach (QM_FILE ${QM_FILES})
122endmacro()
123