From 1ccac0bb18f4bea60b92fe961fa84d96d8a9b9be Mon Sep 17 00:00:00 2001 From: Liangliang Nan Date: Sat, 14 Dec 2024 17:11:09 +0100 Subject: [PATCH] compatible with both Qt5 and Qt6 --- code/CMakeLists.txt | 8 +++++--- code/cmake/UseQt.cmake | 7 +------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 82db0e9..7e3edf9 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12) if (APPLE) - set(CMAKE_OSX_DEPLOYMENT_TARGET "12.12" CACHE STRING "Minimum OS X deployment version" FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) message(STATUS "Minimum OS X deployment version: ${CMAKE_OSX_DEPLOYMENT_TARGET}") endif () @@ -19,7 +19,7 @@ endif() ################################################################################ -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) ################################################################################ @@ -40,7 +40,6 @@ set(POLYFIT_ROOT ${CMAKE_CURRENT_LIST_DIR}) set(POLYFIT_INCLUDE_DIR ${POLYFIT_ROOT} ${CMAKE_CURRENT_BINARY_DIR}) set(POLYFIT_SOURCE_DIR ${POLYFIT_ROOT}) - set(POLYFIT_glpk_DIR ${POLYFIT_ROOT}/3rd_glpk) set(POLYFIT_lpsolve_DIR ${POLYFIT_ROOT}/3rd_lpsolve) set(POLYFIT_qglviewer_DIR ${POLYFIT_ROOT}/3rd_QGLViewer) @@ -51,6 +50,9 @@ set(POLYFIT_glew_DIR ${POLYFIT_ROOT}/3rd_glew) ### conditionally compile certain modules depending on libraries found on the system list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) +if (POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif () find_package(Boost REQUIRED) ################################################################################ diff --git a/code/cmake/UseQt.cmake b/code/cmake/UseQt.cmake index 92aff91..79fe3d7 100644 --- a/code/cmake/UseQt.cmake +++ b/code/cmake/UseQt.cmake @@ -50,11 +50,6 @@ # and links to the qtmain.lib library on Windows. # ------------------------------------------------------------------------------ - -# Qt6 minimum compiler version -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. @@ -67,7 +62,7 @@ set(CMAKE_AUTORCC ON) # This will find the Qt files. find_package(Qt6 COMPONENTS Core Widgets OpenGL OpenGLWidgets Xml QUIET) if (Qt6_FOUND) - message(STATUS "Found Qt6 version: ${Qt5Core_VERSION}") + message(STATUS "Found Qt6 version: ${Qt6Core_VERSION}") set(QtLibs Qt::Core Qt::Widgets Qt::OpenGL Qt::OpenGLWidgets Qt::Xml) else() find_package(Qt5 COMPONENTS Core Widgets OpenGL Xml QUIET)