0029580: Regression: invalid result of BOP Fuse
[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
9 # Now set CMAKE_PREFIX_PATH to point to local Qt installation.
10 # Without this setting find_package() will not work
11 set(CMAKE_PREFIX_PATH ${3RDPARTY_QT_DIR})
4f4b8935 12
13 # Now we can apply standard CMake finder for Qt5. We do this mostly
14 # to have qt5_wrap_cpp() function available
15 find_package(Qt5 QUIET COMPONENTS Widgets PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH)
16 if (${Qt5_FOUND})
17 #message (STATUS "Qt5 cmake configuration")
18
19 set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
20 set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}")
21 set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}")
22 else()
14bbbdcb 23 # Now we can apply standard CMake finder for Qt. We do this mostly
4f4b8935 24 # to have qt4_wrap_cpp() function available
14bbbdcb 25 find_package(Qt4)
14bbbdcb 26
4f4b8935 27 #message (STATUS "Qt4 cmake configuration")
14bbbdcb 28 set(PROJECT_INCLUDES ${QT_INCLUDES})
29 if (WIN32)
30 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/QtCored4.lib;${3RDPARTY_QT_DIR}/lib/QtGuid4.lib")
31 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/QtCore4.lib;${3RDPARTY_QT_DIR}/lib/QtGui4.lib")
32 else()
33 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
34 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
35 endif(WIN32)
14bbbdcb 36 endif()
37endmacro()
38
39
410dd2c9 40macro (FIND_AND_WRAP_MOC_FILES HEADER_FILES GENERATED_MOC_FILES)
41 set (GENERATED_MOC_FILES "")
42 foreach (FILE ${HEADER_FILES})
43 # processing only files where Q_OBJECT exists
44 file(STRINGS "${FILE}" LINES REGEX "Q_OBJECT")
45 if(LINES)
46 unset (MOC_FILE)
47 if (${Qt5_FOUND})
48 qt5_wrap_cpp(MOC_FILE ${FILE})
49 else()
50 qt4_wrap_cpp(MOC_FILE ${FILE})
51 endif()
52 #message (STATUS "... Info: next MOC file ${MOC_FILE}")
53 list(APPEND ${GENERATED_MOC_FILES} ${MOC_FILE})
54 endif(LINES)
14bbbdcb 55 endforeach (FILE)
56
57endmacro()
58
59macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
60 if(EXISTS "${RESOURCE_FILE_NAME}")
4f4b8935 61 if (${Qt5_FOUND})
62 qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
63 else()
14bbbdcb 64 qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
65 # suppress some GCC warnings coming from source files generated from .qrc resources
66 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
67 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
68 endif()
14bbbdcb 69 endif()
70 endif()
71endmacro()