11cmake_minimum_required (VERSION 3.8 )
22
3- cmake_policy (SET CMP0072 NEW )
4- cmake_policy (SET CMP0068 NEW )
3+ cmake_policy (SET CMP0072 NEW ) # new in 3.11. The NEW behavior for this policy is to set OpenGL_GL_PREFERENCE to GLVND.
4+ cmake_policy (SET CMP0068 NEW ) # new in 3.9. The NEW behavior of this policy is to ignore the RPATH settings for install_name on macOS.
5+
56
67project (QtNodesLibrary CXX )
78
@@ -37,41 +38,26 @@ if(QT_NODES_DEVELOPER_DEFAULTS)
3738endif ()
3839
3940if (BUILD_DEBUG_POSTFIX_D)
40- set (CMAKE_DEBUG_POSTFIX d)
41+ set (CMAKE_DEBUG_POSTFIX "d" )
42+ set (CMAKE_RELEASE_POSTFIX "" )
43+ set (CMAKE_RELWITHDEBINFO_POSTFIX "rd" )
44+ set (CMAKE_MINSIZEREL_POSTFIX "s" )
4145endif ()
4246
4347add_subdirectory (external )
4448
49+ find_package (QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets )
50+ find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui OpenGL )
51+ message (STATUS "QT_VERSION: ${QT_VERSION} , QT_DIR: ${QT_DIR} " )
4552
46- # Find the QtWidgets library
47- find_package (Qt6 QUIET
48- COMPONENTS
49- Core
50- Widgets
51- Gui
52- OpenGL
53- )
54-
55- if (NOT Qt6_FOUND)
56- find_package (Qt5 QUIET
57- COMPONENTS
58- Core
59- Widgets
60- Gui
61- OpenGL
62- )
53+ if (${QT_VERSION} VERSION_LESS 5.11.0)
54+ message (FATAL_ERROR "Requires qt version >= 5.11.0, Your current version is ${QT_VERSION} " )
6355endif ()
6456
65- if (NOT (Qt6_FOUND OR Qt5_FOUND))
66- message (FATAL_ERRROR "Qt libraries were not found." )
67- endif ()
68-
69- if (Qt6_FOUND)
57+ if (${QT_VERSION_MAJOR} EQUAL 6)
7058 qt_add_resources (RESOURCES ./resources/resources.qrc )
71- set (Qt Qt)
7259else ()
7360 qt5_add_resources (RESOURCES ./resources/resources.qrc )
74- set (Qt Qt5)
7561endif ()
7662
7763# Unfortunately, as we have a split include/src, AUTOMOC doesn't work.
@@ -165,10 +151,10 @@ target_include_directories(QtNodes
165151
166152target_link_libraries (QtNodes
167153 PUBLIC
168- ${Qt }::Core
169- ${Qt }::Widgets
170- ${Qt }::Gui
171- ${Qt }::OpenGL
154+ Qt${QT_VERSION_MAJOR }::Core
155+ Qt${QT_VERSION_MAJOR }::Widgets
156+ Qt${QT_VERSION_MAJOR }::Gui
157+ Qt${QT_VERSION_MAJOR }::OpenGL
172158)
173159
174160target_compile_definitions (QtNodes
@@ -180,9 +166,10 @@ target_compile_definitions(QtNodes
180166 QT_NO_KEYWORDS
181167)
182168
169+
183170target_compile_options (QtNodes
184171 PRIVATE
185- $<$<CXX_COMPILER_ID :MSVC >:/W4 /wd4127 /EHsc >
172+ $<$<CXX_COMPILER_ID :MSVC >:/W4 /wd4127 /EHsc / utf -8 >
186173 $<$<CXX_COMPILER_ID :GNU >:-Wall -Wextra >
187174 $<$<CXX_COMPILER_ID :AppleClang >:-Wall -Wextra -Werror >
188175)
@@ -213,7 +200,7 @@ set_target_properties(QtNodes
213200
214201file (GLOB_RECURSE HEADERS_TO_MOC include /QtNodes/internal/*.hpp )
215202
216- if (Qt6_FOUND )
203+ if (${QT_VERSION_MAJOR} EQUAL 6 )
217204 qt_wrap_cpp (nodes_moc
218205 ${HEADERS_TO_MOC}
219206 TARGET QtNodes
0 commit comments