0029547: –°onfiguration, upgrade.dat - include deprecated enums into section [rename]
[occt.git] / adm / cmake / qt_macro.cmake
1 #qt
2
3 macro (FIND_QT_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
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})
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()
23     # Now we can apply standard CMake finder for Qt. We do this mostly
24     # to have qt4_wrap_cpp() function available
25     find_package(Qt4)
26
27     #message (STATUS "Qt4 cmake configuration")
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)
36   endif()
37 endmacro()
38
39
40 macro (FIND_AND_WRAP_MOC_FILES SOURCE_FILES)
41
42   SET(CMAKE_AUTOMOC ON)
43
44   foreach (FILE ${SOURCE_FILES})
45     set (src_files ${src_files} ${FILE})
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
54   endforeach (FILE)
55
56 endmacro()
57
58 macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
59   if(EXISTS "${RESOURCE_FILE_NAME}")
60     if (${Qt5_FOUND})
61       qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
62     else()
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()
68     endif()
69   endif()
70 endmacro()