0029547: –°onfiguration, upgrade.dat - include deprecated enums into section [rename]
[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
40macro (FIND_AND_WRAP_MOC_FILES SOURCE_FILES)
4f4b8935 41
14bbbdcb 42 SET(CMAKE_AUTOMOC ON)
43
44 foreach (FILE ${SOURCE_FILES})
45 set (src_files ${src_files} ${FILE})
46 unset (MOC_FILE)
4f4b8935 47 if (${Qt5_FOUND})
14bbbdcb 48 qt5_wrap_cpp(MOC_FILE ${FILE})
4f4b8935 49 else()
50 qt4_wrap_cpp(MOC_FILE ${FILE})
14bbbdcb 51 endif()
52 #message (STATUS "... Info: next MOC file ${MOC_FILE}")
53
54 endforeach (FILE)
55
56endmacro()
57
58macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
59 if(EXISTS "${RESOURCE_FILE_NAME}")
4f4b8935 60 if (${Qt5_FOUND})
61 qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
62 else()
14bbbdcb 63 qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
64 # suppress some GCC warnings coming from source files generated from .qrc resources
65 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
66 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
67 endif()
14bbbdcb 68 endif()
69 endif()
70endmacro()