0027398: Integrate Qt Browser Widget to Open CASCADE Technology
[occt.git] / adm / cmake / qt5_macro.cmake
CommitLineData
14bbbdcb 1#qt
2
3macro (FIND_QT5_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 if (USE_QT4)
13 # Now we can apply standard CMake finder for Qt. We do this mostly
14 # to have qt5_wrap_cpp() function available
15 find_package(Qt4)
16 #message (STATUS "Qt cmake configuration at directory ${Qt4DIR}")
17
18 set(PROJECT_INCLUDES ${QT_INCLUDES})
19 if (WIN32)
20 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/QtCored4.lib;${3RDPARTY_QT_DIR}/lib/QtGuid4.lib")
21 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/QtCore4.lib;${3RDPARTY_QT_DIR}/lib/QtGui4.lib")
22 else()
23 set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
24 set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
25 endif(WIN32)
26 else()
27 # Now we can apply standard CMake finder for Qt4. We do this mostly
28 # to have qt5_wrap_cpp() function available
29 find_package(Qt5 REQUIRED COMPONENTS Widgets)
30 #message (STATUS "Qt cmake configuration at directory ${Qt5DIR}")
31
32 set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
33 set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}")
34 set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}")
35 endif()
36endmacro()
37
38
39macro (FIND_AND_WRAP_MOC_FILES SOURCE_FILES)
40 SET(CMAKE_AUTOMOC ON)
41
42 foreach (FILE ${SOURCE_FILES})
43 set (src_files ${src_files} ${FILE})
44 unset (MOC_FILE)
45 if (USE_QT4)
46 qt4_wrap_cpp(MOC_FILE ${FILE})
47 else()
48 qt5_wrap_cpp(MOC_FILE ${FILE})
49 endif()
50 #message (STATUS "... Info: next MOC file ${MOC_FILE}")
51
52 endforeach (FILE)
53
54endmacro()
55
56macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
57 if(EXISTS "${RESOURCE_FILE_NAME}")
58 if (USE_QT4)
59 qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
60 # suppress some GCC warnings coming from source files generated from .qrc resources
61 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
62 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
63 endif()
64 else()
65 qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
66 endif()
67 endif()
68endmacro()