From 7a4e20e7f74554924147c749aa02930e127578a0 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 20:26:32 -0600 Subject: [PATCH 01/16] CMake: Add policy CMP0175 --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71356ec69e..e4361f8fb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,16 @@ -# As of January 2023 we require CMake 3.16.3 -# see https://forum.freecad.org/viewtopic.php?f=10&t=72173 -# for further info why -cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR) +# As of February 2025 we require CMake 3.22.0 +cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR) # Suppress 'FindBoost module is removed' warning. Will use BoostConfig.cmake instead if(POLICY CMP0167) cmake_policy(SET CMP0167 NEW) endif() +# As of cMake 3.31 add_custom_command() rejects invalid arguments +if(POLICY CMP0175) + cmake_policy(SET CMP0175 NEW) +endif() + # policy CMP0072 was introduced with CMake 3.11 # relates to FindOpenGL module # and cache variables OPENGL_gl_LIBRARY, OPENGL_glu_LIBRARY From 16ac5f0a5025ed97cf1ffee0a23accd43a390dd7 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 20:27:03 -0600 Subject: [PATCH 02/16] CMake: Remove old policy 0072 --- CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4361f8fb2..12cffbd4b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,13 +11,6 @@ if(POLICY CMP0175) cmake_policy(SET CMP0175 NEW) endif() -# policy CMP0072 was introduced with CMake 3.11 -# relates to FindOpenGL module -# and cache variables OPENGL_gl_LIBRARY, OPENGL_glu_LIBRARY -if (POLICY CMP0072) - set(OpenGL_GL_PREFERENCE LEGACY) -endif(POLICY CMP0072) - # FindPythonInterp and FindPythonLibs modules are deprecated. # Currently, they are still used by shiboken's CMake files if (POLICY CMP0148) From 87ce62f8ace455495f1894911f8fabe962d35317 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 20:32:55 -0600 Subject: [PATCH 03/16] CMake: Update compiler and standard mins --- .../CompilerChecksAndSetups.cmake | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake index 75dec9bf1f..4de75d8dea 100644 --- a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake +++ b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake @@ -28,26 +28,24 @@ macro(CompilerChecksAndSetups) OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION) endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) - # Enabled C++17 for Freecad 0.20 and later - set(BUILD_ENABLE_CXX_STD "C++17" CACHE STRING "Enable C++ standard") + # Enabled C++20 for Freecad 1.1 and later + set(BUILD_ENABLE_CXX_STD "C++20" CACHE STRING "Enable C++ standard") set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS - "C++17" "C++20" + "C++23" ) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3) - message(FATAL_ERROR "FreeCAD 0.20 and later requires C++17. G++ must be 7.3 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}") - elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) - message(FATAL_ERROR "FreeCAD 0.20 and later requires C++17. Clang must be 6.0 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}") - endif() + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.2) + message(FATAL_ERROR "FreeCAD 1.1 and later requires C++20. G++ must be 11.2 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}") + elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0) + message(FATAL_ERROR "FreeCAD 1.1 and later requires C++20. Clang must be 14.0 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}") + endif() # Escape the two plus chars as otherwise cmake complains about invalid regex if(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+23") set(CMAKE_CXX_STANDARD 23) - elseif(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+20") + else() set(CMAKE_CXX_STANDARD 20) - else()#Enabled C++17 - set(CMAKE_CXX_STANDARD 17) endif() # Log the compiler and version From d127610ccf860ac1cad818f908e67fb17ccc1be2 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 20:41:29 -0600 Subject: [PATCH 04/16] CMake: Add details about why CMP0148 is needed --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12cffbd4b2..0224a70061 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,9 @@ if(POLICY CMP0175) cmake_policy(SET CMP0175 NEW) endif() -# FindPythonInterp and FindPythonLibs modules are deprecated. -# Currently, they are still used by shiboken's CMake files +# FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by +# all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer +# supported if (POLICY CMP0148) cmake_policy(SET CMP0148 OLD) endif() From 84b3f39785195b9012aca90748a5b766136c0c82 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 21:07:36 -0600 Subject: [PATCH 05/16] CMake: Set CMP0153 to NEW --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0224a70061..8b707c323a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,16 @@ endif() # FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by # all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer # supported -if (POLICY CMP0148) +if(POLICY CMP0148) cmake_policy(SET CMP0148 OLD) endif() +# The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake +# 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW) +if(POLICY CMP0153) + cmake_policy(SET CMP0153 NEW) +endif() + option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON) if(FREECAD_USE_CCACHE) From 699e1bd46369db787070fd8ddff046d3b53acd96 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 21:24:26 -0600 Subject: [PATCH 06/16] Gui: Change variable name import->importCommand import is a reserved word in c++latest --- src/Gui/Macro.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Gui/Macro.cpp b/src/Gui/Macro.cpp index 7428cccbc3..e7f20e1ee7 100644 --- a/src/Gui/Macro.cpp +++ b/src/Gui/Macro.cpp @@ -83,15 +83,16 @@ bool MacroFile::commit() #if QT_VERSION < QT_VERSION_CHECK(6,0,0) str.setCodec("UTF-8"); #endif - QStringList import; - import << QStringLiteral("import FreeCAD"); + QStringList importCommand; + importCommand << QStringLiteral("import FreeCAD"); QStringList body; for (const auto& it : std::as_const(this->macroInProgress)) { if (it.startsWith(QLatin1String("import ")) || it.startsWith(QLatin1String("#import "))) { - if (import.indexOf(it) == -1) - import.push_back(it); + if (importCommand.indexOf(it) == -1) { + importCommand.push_back(it); + } } else { body.push_back(it); @@ -110,7 +111,7 @@ bool MacroFile::commit() // write the data to the text file str << header; - for (const auto& it : std::as_const(import)) { + for (const auto& it : std::as_const(importCommand)) { str << it << QLatin1Char('\n'); } str << QLatin1Char('\n'); From e25efd4fb95e5da6d4c530a53da2440bd2ab1864 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 21:39:06 -0600 Subject: [PATCH 07/16] CMake: Expand note about BOOST_PP_VARIADICS=1 --- .../FreeCAD_Helpers/CompilerChecksAndSetups.cmake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake index 4de75d8dea..ed2b9cac69 100644 --- a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake +++ b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake @@ -29,11 +29,11 @@ macro(CompilerChecksAndSetups) endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) # Enabled C++20 for Freecad 1.1 and later - set(BUILD_ENABLE_CXX_STD "C++20" CACHE STRING "Enable C++ standard") - set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS - "C++20" - "C++23" - ) + set(BUILD_ENABLE_CXX_STD "C++20" CACHE STRING "Enable C++ standard") + set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS + "C++20" + "C++23" + ) if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.2) message(FATAL_ERROR "FreeCAD 1.1 and later requires C++20. G++ must be 11.2 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}") @@ -105,7 +105,9 @@ macro(CompilerChecksAndSetups) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") endif() - # older boost.preprocessor turn off variadics for clang + # boost.preprocessor 1.74 and earlier turns off variadics for clang regardless of version, even though they + # work in all versions of clang that we support. Manually force variadic macro support until our oldest + # supported version of boost is 1.75 or higher. add_definitions(-DBOOST_PP_VARIADICS=1) message(STATUS "Force BOOST_PP_VARIADICS=1 for clang") endif() From ac77cd779ed183d9987f75c35af4a9a9b36e5916 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 18 Feb 2025 23:13:05 -0600 Subject: [PATCH 08/16] CMake: PySide cleanup --- cMake/FindPySide6.cmake | 22 +++++++++++-------- .../SetupShibokenAndPyside.cmake | 19 +++++++++------- cMake/FreeCadMacros.cmake | 15 ++++++++----- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/cMake/FindPySide6.cmake b/cMake/FindPySide6.cmake index 2b0a58069e..a1f1746755 100644 --- a/cMake/FindPySide6.cmake +++ b/cMake/FindPySide6.cmake @@ -5,18 +5,22 @@ find_package(PySide6 CONFIG QUIET) if(NOT PySide6_FOUND) - if(NOT PySide6_INCLUDE_DIR AND TARGET PySide6::pyside6) - get_property(PySide6_INCLUDE_DIR TARGET PySide6::pyside6 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + if(NOT PySide6_INCLUDE_DIRS AND TARGET PySide6::pyside6) + get_property(PySide6_INCLUDE_DIRS TARGET PySide6::pyside6 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) endif() - if(NOT PySide6_INCLUDE_DIR) + if(NOT PySide6_INCLUDE_DIRS) find_pip_package(PySide6) - if (PySide6_FOUND) - set(PYSIDE_INCLUDE_DIR ${PySide6_INCLUDE_DIRS} CACHE INTERNAL "") - set(PYSIDE_LIBRARY ${PySide6_LIBRARIES} CACHE INTERNAL "") - set(PYSIDE_FOUND TRUE CACHE BOOL OFF) - set(PYSIDE_MAJOR_VERSION 6 CACHE INTERNAL 6) - endif() + else() + set(PySide6_FOUND ON CACHE BOOL OFF) endif() endif() + +# Also provide the old-style variables so we don't have to update everything yet +if (PySide6_FOUND) + set(PYSIDE_INCLUDE_DIR ${PySide6_INCLUDE_DIRS} CACHE INTERNAL "") + set(PYSIDE_LIBRARY ${PySide6_LIBRARIES} CACHE INTERNAL "") + set(PYSIDE_FOUND TRUE CACHE BOOL "(Backwards compatibility PySide6->PySide2) Whether PySide was found") + set(PYSIDE_MAJOR_VERSION 6 CACHE INTERNAL 6) +endif() diff --git a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake index 9b8c35ec1d..45c10fc2f4 100644 --- a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake +++ b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake @@ -59,15 +59,18 @@ macro(SetupShibokenAndPyside) find_package(PySide${PYSIDE_MAJOR_VERSION} QUIET) - if(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION}) - get_property(PYSIDE_INCLUDE_DIR TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) - endif(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION}) + if(${PYSIDE_MAJOR_VERSION} EQUAL 5) + # Our internal FindPySide6.cmake file already provides these for PySide6 + if(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION}) + get_property(PYSIDE_INCLUDE_DIR TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + endif(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION}) - if(NOT PYSIDE_INCLUDE_DIR) - find_pip_package(PySide${PYSIDE_MAJOR_VERSION}) - if (PySide${PYSIDE_MAJOR_VERSION}_FOUND) - set(PYSIDE_INCLUDE_DIR ${PySide${PYSIDE_MAJOR_VERSION}_INCLUDE_DIRS}) - set(PYSIDE_LIBRARY ${PySide${PYSIDE_MAJOR_VERSION}_LIBRARIES}) + if(NOT PYSIDE_INCLUDE_DIR) + find_pip_package(PySide${PYSIDE_MAJOR_VERSION}) + if (PySide${PYSIDE_MAJOR_VERSION}_FOUND) + set(PYSIDE_INCLUDE_DIR ${PySide${PYSIDE_MAJOR_VERSION}_INCLUDE_DIRS}) + set(PYSIDE_LIBRARY ${PySide${PYSIDE_MAJOR_VERSION}_LIBRARIES}) + endif() endif() endif() diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index e30437af12..c650625ed9 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -266,6 +266,8 @@ ENDMACRO(SET_PYTHON_PREFIX_SUFFIX) # Locate the include directory for a pip-installed package -- uses pip show to find the base pip # install directory, and then appends the package name and "/include" to the end macro(find_pip_package PACKAGE) + unset(${PACKAGE}_FOUND) # Remove from local scope + unset(${PACKAGE}_FOUND CACHE) # Remove from CMake cache (if it exists) execute_process( COMMAND ${Python3_EXECUTABLE} -m pip show ${PACKAGE} RESULT_VARIABLE FAILURE @@ -300,15 +302,18 @@ macro(find_pip_package PACKAGE) file(GLOB OPT_LIBRARIES "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/*${PIP_LIB_NAME}*.so.*") endif() if (OPT_LIBRARIES AND DEBUG_LIBRARIES) - set(${PACKAGE}_LIBRARIES optimized ${OPT_LIBRARIES} debug ${DEBUG_LIBRARIES} CACHE PATH "") + set(${PACKAGE}_LIBRARIES optimized ${OPT_LIBRARIES} debug ${DEBUG_LIBRARIES} CACHE PATH "Location of the ${PACKAGE} libraries") elseif(OPT_LIBRARIES) - set(${PACKAGE}_LIBRARIES ${OPT_LIBRARIES} CACHE PATH "") + set(${PACKAGE}_LIBRARIES ${OPT_LIBRARIES} CACHE PATH "Location of the ${PACKAGE} optimized libraries") elseif(DEBUG_LIBRARIES) - set(${PACKAGE}_LIBRARIES ${DEBUG_LIBRARIES} CACHE PATH "") + set(${PACKAGE}_LIBRARIES ${DEBUG_LIBRARIES} CACHE PATH "Location of the ${PACKAGE} debug libraries") endif() - set(${PACKAGE}_INCLUDE_DIRS ${INCLUDE_DIR} CACHE PATH "") - set(${PACKAGE}_FOUND ON CACHE BOOL OFF) + set(${PACKAGE}_INCLUDE_DIRS ${INCLUDE_DIR} CACHE PATH "Location of the ${PACKAGE} includes") + set(${PACKAGE}_FOUND ON CACHE BOOL "${PACKAGE} detection status") message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") + if(${PACKAGE}_INCLUDE_DIRS) + message(STATUS " --> with includes in ${${PACKAGE}_INCLUDE_DIRS}") + endif() endif() endmacro() From b46aa342e43911970b12fe682b9033d10efeca5e Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 19 Feb 2025 10:20:50 -0600 Subject: [PATCH 09/16] CMake: Correct use of CACHE --- cMake/FindPySide6.cmake | 10 +++++----- cMake/FindShiboken6.cmake | 14 +++++++------- cMake/FreeCAD_Helpers/PrintFinalReport.cmake | 2 +- cMake/FreeCadMacros.cmake | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cMake/FindPySide6.cmake b/cMake/FindPySide6.cmake index a1f1746755..8f97f0ec4c 100644 --- a/cMake/FindPySide6.cmake +++ b/cMake/FindPySide6.cmake @@ -12,15 +12,15 @@ if(NOT PySide6_FOUND) if(NOT PySide6_INCLUDE_DIRS) find_pip_package(PySide6) else() - set(PySide6_FOUND ON CACHE BOOL OFF) + set(PySide6_FOUND ON) endif() endif() # Also provide the old-style variables so we don't have to update everything yet if (PySide6_FOUND) - set(PYSIDE_INCLUDE_DIR ${PySide6_INCLUDE_DIRS} CACHE INTERNAL "") - set(PYSIDE_LIBRARY ${PySide6_LIBRARIES} CACHE INTERNAL "") - set(PYSIDE_FOUND TRUE CACHE BOOL "(Backwards compatibility PySide6->PySide2) Whether PySide was found") - set(PYSIDE_MAJOR_VERSION 6 CACHE INTERNAL 6) + set(PYSIDE_INCLUDE_DIR ${PySide6_INCLUDE_DIRS}) + set(PYSIDE_LIBRARY ${PySide6_LIBRARIES}) + set(PYSIDE_FOUND TRUE) + set(PYSIDE_MAJOR_VERSION 6) endif() diff --git a/cMake/FindShiboken6.cmake b/cMake/FindShiboken6.cmake index 5288d88ea1..c32b55901e 100644 --- a/cMake/FindShiboken6.cmake +++ b/cMake/FindShiboken6.cmake @@ -11,18 +11,18 @@ if(NOT Shiboken6_FOUND) if(NOT Shiboken6_INCLUDE_DIR) find_pip_package(Shiboken6) if (Shiboken6_FOUND) - set(SHIBOKEN_LIBRARY ${Shiboken6_LIBRARIES} CACHE INTERNAL "") - set(SHIBOKEN_MAJOR_VERSION 6 CACHE INTERNAL 6) - set(SHIBOKEN_FOUND ON CACHE BOOL OFF) + set(SHIBOKEN_LIBRARY ${Shiboken6_LIBRARIES}) + set(SHIBOKEN_MAJOR_VERSION 6) + set(SHIBOKEN_FOUND ON) endif() # The include directory we actually want is part of shiboken6-generator find_pip_package(shiboken6_generator) if (shiboken6_generator_FOUND) - set(SHIBOKEN_INCLUDE_DIR ${shiboken6_generator_INCLUDE_DIRS} CACHE PATH "") + set(SHIBOKEN_INCLUDE_DIR ${shiboken6_generator_INCLUDE_DIRS}) endif() endif() else() - set(SHIBOKEN_INCLUDE_DIR ${Shiboken6_INCLUDE_DIRS} CACHE PATH "") - set(SHIBOKEN_LIBRARY ${Shiboken6_LIBRARIES} CACHE INTERNAL "") - set(SHIBOKEN_FOUND ON CACHE BOOL OFF) + set(SHIBOKEN_INCLUDE_DIR ${Shiboken6_INCLUDE_DIRS}) + set(SHIBOKEN_LIBRARY ${Shiboken6_LIBRARIES}) + set(SHIBOKEN_FOUND ON) endif() diff --git a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake index 1ff155437a..1f1cbe86b3 100644 --- a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake +++ b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake @@ -14,7 +14,7 @@ macro(PrintFinalReport) # just a value macro(value) - unset(val) + unset(val) set(name ${ARGV0}) if(${name}) set(val ${${name}}) # name has a value diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index c650625ed9..3b92f6d73b 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -309,7 +309,7 @@ macro(find_pip_package PACKAGE) set(${PACKAGE}_LIBRARIES ${DEBUG_LIBRARIES} CACHE PATH "Location of the ${PACKAGE} debug libraries") endif() set(${PACKAGE}_INCLUDE_DIRS ${INCLUDE_DIR} CACHE PATH "Location of the ${PACKAGE} includes") - set(${PACKAGE}_FOUND ON CACHE BOOL "${PACKAGE} detection status") + set(${PACKAGE}_FOUND ON) message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") if(${PACKAGE}_INCLUDE_DIRS) message(STATUS " --> with includes in ${${PACKAGE}_INCLUDE_DIRS}") From 20e4d25d701737c06099420ed47e9f015cc6793c Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 19 Feb 2025 10:33:57 -0600 Subject: [PATCH 10/16] CMake: Adopt policy CMP0144 All-uppercase find_package() --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b707c323a..5ed3af58e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,12 @@ if(POLICY CMP0148) cmake_policy(SET CMP0148 OLD) endif() +# As of cMake 3.27, find_package() will look for both case-sensitive and all-uppercase versions +# of the package. This seems to affect FLANN as included by Pixi +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif() + # The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake # 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW) if(POLICY CMP0153) From 3b5f5609755784b74e6d3850203ca44cea2f3bb9 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 19 Feb 2025 17:24:37 -0600 Subject: [PATCH 11/16] CI: Update LibPack version in action Also requires deleting the cached copy. --- .github/workflows/actions/windows/getLibpack/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/windows/getLibpack/action.yml b/.github/workflows/actions/windows/getLibpack/action.yml index f9bf9726c4..bed52624a7 100644 --- a/.github/workflows/actions/windows/getLibpack/action.yml +++ b/.github/workflows/actions/windows/getLibpack/action.yml @@ -41,11 +41,11 @@ inputs: libpackdownloadurl: description: "URL where to download libpack" required: false - default: https://github.com/FreeCAD/FreeCAD-LibPack/releases/download/3.0.0RC4/LibPack-1.0.0-v3.0.0RC4-Release.7z + default: https://github.com/FreeCAD/FreeCAD-LibPack/releases/download/3.1.0/LibPack-1.1.0-v3.1.0-Release.7z libpackname: description: "Libpack name (once downloaded)" required: false - default: LibPack-1.0.0-v3.0.0RC4-Release + default: LibPack-1.1.0-v3.1.0-Release runs: using: "composite" From 0d46a7239634f592a0281fad816420cfe7a21bd2 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 19 Feb 2025 19:17:56 -0600 Subject: [PATCH 12/16] CMake: Add policy 0177 to normalize install paths Also sort policies by number. --- CMakeLists.txt | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ed3af58e9..abced4aca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,26 @@ # As of February 2025 we require CMake 3.22.0 cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR) + +# As of cMake 3.27, find_package() will look for both case-sensitive and all-uppercase versions +# of the package. This seems to affect FLANN as included by Pixi +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif() + +# FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by +# all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer +# supported +if(POLICY CMP0148) + cmake_policy(SET CMP0148 OLD) +endif() + +# The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake +# 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW) +if(POLICY CMP0153) + cmake_policy(SET CMP0153 NEW) +endif() + # Suppress 'FindBoost module is removed' warning. Will use BoostConfig.cmake instead if(POLICY CMP0167) cmake_policy(SET CMP0167 NEW) @@ -11,24 +31,11 @@ if(POLICY CMP0175) cmake_policy(SET CMP0175 NEW) endif() -# FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by -# all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer -# supported -if(POLICY CMP0148) - cmake_policy(SET CMP0148 OLD) +# Added in cMake 3.31, enforce normalization of all DESTINATION paths given to install() +if(POLICY CMP0177) + cmake_policy(SET CMP0177 NEW) endif() -# As of cMake 3.27, find_package() will look for both case-sensitive and all-uppercase versions -# of the package. This seems to affect FLANN as included by Pixi -if(POLICY CMP0144) - cmake_policy(SET CMP0144 NEW) -endif() - -# The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake -# 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW) -if(POLICY CMP0153) - cmake_policy(SET CMP0153 NEW) -endif() option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON) From 20647031541c4a73539ea62fdb4817f6457ac928 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 19 Feb 2025 19:32:49 -0600 Subject: [PATCH 13/16] CMake: Remove support for old CMake versions --- cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake index ed2b9cac69..1d3c233df1 100644 --- a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake +++ b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake @@ -9,14 +9,6 @@ macro(CompilerChecksAndSetups) # ================================================================================ - # Needed for boost1.69 - # Avoid that Python (pyerrors.h) defines snprintf and vsnprintf - if (MSVC AND NOT MSVC_VERSION VERSION_LESS 1900) - add_definitions(-DHAVE_SNPRINTF) - elseif (MINGW) - add_definitions(-DHAVE_SNPRINTF) - endif() - # Allow developers to use Boost < 1.74 if (NOT BOOST_MIN_VERSION) set(BOOST_MIN_VERSION 1.74) @@ -97,9 +89,7 @@ macro(CompilerChecksAndSetups) # # https://en.wikipedia.org/wiki/Xcode#Latest_versions if (APPLE) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") add_definitions(-DGL_SILENCE_DEPRECATION) elseif (UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") From 99b088e94e3a4116e88eb3e27c76c1c3b23c2169 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 21 Feb 2025 11:05:38 -0600 Subject: [PATCH 14/16] Mesh: Remove explicit C++17 requirement --- src/Mod/Mesh/App/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Mod/Mesh/App/CMakeLists.txt b/src/Mod/Mesh/App/CMakeLists.txt index 5acc8a3765..d889f63f97 100644 --- a/src/Mod/Mesh/App/CMakeLists.txt +++ b/src/Mod/Mesh/App/CMakeLists.txt @@ -413,8 +413,6 @@ endif () add_library(Mesh SHARED ${Core_SRCS} ${WildMagic4_SRCS} ${Mesh_SRCS}) target_link_libraries(Mesh ${Mesh_LIBS}) -set_target_properties(Mesh PROPERTIES CXX_STANDARD_REQUIRED ON) -set_target_properties(Mesh PROPERTIES CXX_STANDARD 17) if (FREECAD_WARN_ERROR) target_compile_warn_error(Mesh) endif() From 86e8355478523b4c51197d04d1292c3191df22e0 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 21 Feb 2025 11:07:01 -0600 Subject: [PATCH 15/16] CAM: Remove C++14 workaround for boost --- src/Mod/CAM/App/CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/Mod/CAM/App/CMakeLists.txt b/src/Mod/CAM/App/CMakeLists.txt index 75f186d863..3139881bb7 100644 --- a/src/Mod/CAM/App/CMakeLists.txt +++ b/src/Mod/CAM/App/CMakeLists.txt @@ -124,20 +124,6 @@ if (FREECAD_WARN_ERROR) target_compile_warn_error(Path) endif() -# Boost >= 1.75.0 -if(NOT ${Boost_VERSION} LESS 107500) - set_target_properties(Path PROPERTIES CXX_STANDARD_REQUIRED ON) - set_target_properties(Path PROPERTIES CXX_STANDARD 14) - - # Suppress -Wc++17-extensions when using OCCT 7.5 or newer - if (MINGW AND CMAKE_COMPILER_IS_CLANGXX) - unset(_flag_found CACHE) - check_cxx_compiler_flag("-Wno-c++17-extensions" _flag_found) - if (_flag_found) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-extensions") - endif() - endif() -endif() if(FREECAD_USE_PCH) add_definitions(-D_PreComp_) From 38f9fecaf6ab42e726e48bc03f51d4cc964f80ae Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 21 Feb 2025 11:45:28 -0600 Subject: [PATCH 16/16] CMake: Correct formatting to match existing --- cMake/FreeCadMacros.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index 3b92f6d73b..4fbc86bf8e 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -266,8 +266,8 @@ ENDMACRO(SET_PYTHON_PREFIX_SUFFIX) # Locate the include directory for a pip-installed package -- uses pip show to find the base pip # install directory, and then appends the package name and "/include" to the end macro(find_pip_package PACKAGE) - unset(${PACKAGE}_FOUND) # Remove from local scope - unset(${PACKAGE}_FOUND CACHE) # Remove from CMake cache (if it exists) + unset(${PACKAGE}_FOUND) # Remove from local scope + unset(${PACKAGE}_FOUND CACHE) # Remove from CMake cache (if it exists) execute_process( COMMAND ${Python3_EXECUTABLE} -m pip show ${PACKAGE} RESULT_VARIABLE FAILURE