From d01ce32a1f6de77a6b3438413d9a35137061ff8f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 24 Jun 2024 11:25:05 -0500 Subject: [PATCH] Update for LibPack3 (#10337) * cMake: Add base support for LibPack3 Minor changes to FreeCAD source code to support compiling with Qt 6.5 on MSVC, and changes to cMake setup to support the new Libpack. * NETGENPlugin: Fix compilation with MSVC and OCCT 7.8 * Material: Switch to Wrapped_ParseTupleAndKeywords for /fpermissive- on MSVC * Base: Prevent accidental definition of MIN and MAX by MSVC * cMake: Prevent accidentally finding an old LibPack * Material: Wrap another ParseTuple call * OCCT: Modify includes for 7.8.x * Part: Change TNP code to use Wrapped_ParseTupleAndArgs * Spreadsheet: Workaround for MSVC macro pollution * Mesh: Workaround for MSVC macro pollution * Base: Remove extra MSVC flag (moved to CMake) * Tests: Fix compiling with /permissive- * FEM: Fix Qt warnings about duplicate element names * cMake: Ensure major version numbers are set * Address review comments. * cMake: Further tweaks for LibPack3 * cMake: Modify specification of compiler flags for MSVC * Main: Remove QtQuick testing code * cmake: Find Boost before SMESH (which uses it) * Fixes for LibPack2 * cMake: Another try at importinhg VTK cleanly --- CMakeLists.txt | 6 +- cMake/FindPySide6.cmake | 22 +++++++ cMake/FindShiboken6.cmake | 28 +++++++++ cMake/FreeCAD_Helpers/ChooseQtVersion.cmake | 15 ++++- .../CopyLibpackDirectories.cmake | 31 ++++++++-- .../FreeCADLibpackChecks.cmake | 12 +++- .../InitializeFreeCADBuildOptions.cmake | 1 + .../SetGlobalCompilerAndLinkerSettings.cmake | 9 ++- cMake/FreeCAD_Helpers/SetupCoin3D.cmake | 51 +++++++++------- cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake | 8 ++- .../SetupShibokenAndPyside.cmake | 37 ------------ cMake/FreeCadMacros.cmake | 51 +++++++++++++++- cMake/UseLibPack3.cmake | 38 ++++++++++++ .../NETGENPlugin/NETGENPlugin_Hypothesis.cpp | 7 +++ .../NETGENPlugin_Hypothesis_2D.cpp | 7 +++ .../src/NETGENPlugin/NETGENPlugin_Mesher.cpp | 24 ++++++++ .../NETGENPlugin/NETGENPlugin_NETGEN_2D.cpp | 7 +++ .../NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cpp | 7 +++ .../NETGENPlugin_NETGEN_2D_ONLY.cpp | 8 +++ .../NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp | 7 +++ .../NETGENPlugin_SimpleHypothesis_2D.cpp | 7 +++ .../NETGENPlugin_SimpleHypothesis_3D.cpp | 7 +++ src/Base/ParameterPy.cpp | 2 +- src/Gui/CMakeLists.txt | 7 +++ src/Gui/MainWindow.cpp | 23 +++++-- src/LibraryVersions.h.cmake | 22 +++---- src/Mod/CAM/libarea/CMakeLists.txt | 2 +- src/Mod/Fem/Gui/DlgSettingsFemCcx.ui | 4 +- src/Mod/Fem/Gui/TaskTetParameter.ui | 4 +- .../Material/App/MaterialManagerPyImpl.cpp | 33 +++++----- src/Mod/Mesh/App/Core/IO/Reader3MF.cpp | 4 +- src/Mod/MeshPart/App/CMakeLists.txt | 2 +- src/Mod/Part/App/OpenCascadeAll.h | 6 +- src/Mod/Part/App/TopoShapePyImp.cpp | 60 ++++++++++--------- src/Mod/Spreadsheet/App/Cell.cpp | 3 + tests/src/App/ElementMap.cpp | 2 +- tests/src/Mod/Material/App/Model.cpp | 0 tests/src/Mod/Part/App/PartTestHelpers.cpp | 2 +- tests/src/Mod/Part/App/PartTestHelpers.h | 2 +- tests/src/Mod/Part/App/PropertyTopoShape.cpp | 2 +- tests/src/Mod/Part/App/TopoShapeExpansion.cpp | 4 +- .../App/TopoShapeMakeShapeWithElementMap.cpp | 3 + 42 files changed, 421 insertions(+), 156 deletions(-) create mode 100644 cMake/FindPySide6.cmake create mode 100644 cMake/FindShiboken6.cmake create mode 100644 cMake/UseLibPack3.cmake create mode 100644 tests/src/Mod/Material/App/Model.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 15b6c6a0f9..b57afcd8ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ FreeCADLibpackChecks() SetupDoxygen() SetupLibFmt() SetupYamlCpp() -if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) +if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIBPACK_CHECKFILE_VERSION) SetupPython() SetupPCL() SetupPybind11() @@ -68,8 +68,8 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) # OPENGL_gl_LIBRARY empty that results into linker errors SetupOpenGL() endif(BUILD_GUI) - SetupSalomeSMESH() SetupBoost() + SetupSalomeSMESH() if (BUILD_FEM_NETGEN) find_package(NETGEN) endif(BUILD_FEM_NETGEN) @@ -88,7 +88,7 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) SetupShibokenAndPyside() SetupMatplotlib() endif(BUILD_GUI) -endif(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) +endif() if(BUILD_VR) find_package(Rift) diff --git a/cMake/FindPySide6.cmake b/cMake/FindPySide6.cmake new file mode 100644 index 0000000000..2b0a58069e --- /dev/null +++ b/cMake/FindPySide6.cmake @@ -0,0 +1,22 @@ +# The Qt for Python project officially recommends using pip to install PySide, so we expect to find PySide in the +# site-packages directory. The library will be called "PySide6.abi3.*", and there will be an "include" directory inside +# the site-packages/PySide6. Over time some distros may provide custom versions, so we also support using a more normal +# cMake find_package() call + +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) + endif() + + if(NOT PySide6_INCLUDE_DIR) + 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() + endif() + +endif() diff --git a/cMake/FindShiboken6.cmake b/cMake/FindShiboken6.cmake new file mode 100644 index 0000000000..5288d88ea1 --- /dev/null +++ b/cMake/FindShiboken6.cmake @@ -0,0 +1,28 @@ +# The Qt for Python project officially recommends using pip to install Shiboken, so we expect to find Shiboken in the +# site-packages directory. FreeCAD also requires shiboken6_generator, so this find script also locates that package +# and ensures the inclusion of its include directory when using the pip finding mechanism + + +find_package(Shiboken6 CONFIG QUIET) +if(NOT Shiboken6_FOUND) + if(NOT Shiboken6_INCLUDE_DIR AND TARGET Shiboken6::Shiboken6) + get_property(Shiboken6_INCLUDE_DIR TARGET Shiboken6::Shiboken6 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + endif() + 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) + 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 "") + 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) +endif() diff --git a/cMake/FreeCAD_Helpers/ChooseQtVersion.cmake b/cMake/FreeCAD_Helpers/ChooseQtVersion.cmake index 8e822492cb..3e5609da22 100644 --- a/cMake/FreeCAD_Helpers/ChooseQtVersion.cmake +++ b/cMake/FreeCAD_Helpers/ChooseQtVersion.cmake @@ -57,9 +57,22 @@ macro(ChooseQtVersion) endif() if(FREECAD_LIBPACK_USE) - if (NOT Qt5_DIR OR Qt5_DIR STREQUAL "Qt5_DIR-NOTFOUND") + find_file(FREECAD_LIBPACK_CHECKFILE_VERSION NAMES FREECAD_LIBPACK_VERSION PATHS ${FREECAD_LIBPACK_DIR} NO_DEFAULT_PATH) + if(FREECAD_LIBPACK_CHECKFILE_VERSION) + file(READ ${FREECAD_LIBPACK_CHECKFILE_VERSION} FREECAD_LIBPACK_VERSION) + message(STATUS "LibPack: read version file and got ${FREECAD_LIBPACK_VERSION}") + if(FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + message(STATUS "Using Qt6 directory from LibPack in ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt6") + set(Qt6_DIR ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt6) + set(FREECAD_QT_VERSION 6) + else() + message(ERROR ": Unrecognized LibPack version ${FREECAD_LIBPACK_CHECKFILE_VERSION}") + endif() + else() + if (NOT Qt5_DIR OR Qt5_DIR STREQUAL "Qt5_DIR-NOTFOUND") message(STATUS "Using Qt5 directory from LibPack in ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt5") set(Qt5_DIR ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt5) + endif() endif() endif() diff --git a/cMake/FreeCAD_Helpers/CopyLibpackDirectories.cmake b/cMake/FreeCAD_Helpers/CopyLibpackDirectories.cmake index a6753e8374..c7348499a6 100644 --- a/cMake/FreeCAD_Helpers/CopyLibpackDirectories.cmake +++ b/cMake/FreeCAD_Helpers/CopyLibpackDirectories.cmake @@ -1,8 +1,7 @@ macro(CopyLibpackDirectories) # Copy libpack dependency directories to build folder for user as part of overall build process if(FREECAD_COPY_DEPEND_DIRS_TO_BUILD) - message(STATUS "=======================================\n" - "Copying libpack dependency directories to build directory for Windows MSVC build.\n") + message(STATUS "Copying libpack dependency directories to build directory...") file(COPY ${FREECAD_LIBPACK_DIR}/bin/assistant.exe DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY ${FREECAD_LIBPACK_DIR}/bin/qt.conf DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY ${FREECAD_LIBPACK_DIR}/plugins/platforms DESTINATION ${CMAKE_BINARY_DIR}/bin) @@ -10,17 +9,30 @@ macro(CopyLibpackDirectories) file(COPY ${FREECAD_LIBPACK_DIR}/plugins/iconengines DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY ${FREECAD_LIBPACK_DIR}/plugins/sqldrivers DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY ${FREECAD_LIBPACK_DIR}/plugins/styles DESTINATION ${CMAKE_BINARY_DIR}/bin) - file(COPY ${FREECAD_LIBPACK_DIR}/plugins/printsupport DESTINATION ${CMAKE_BINARY_DIR}/bin) + if(NOT FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + file(COPY ${FREECAD_LIBPACK_DIR}/plugins/printsupport DESTINATION ${CMAKE_BINARY_DIR}/bin) + endif() + if(FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + file(COPY ${FREECAD_LIBPACK_DIR}/plugins/tls DESTINATION ${CMAKE_BINARY_DIR}/bin) + endif() file(COPY ${FREECAD_LIBPACK_DIR}/resources DESTINATION ${CMAKE_BINARY_DIR}) message(STATUS "... end copying.\n=======================================\n") endif() if(COPY_LIBPACK_BIN_TO_BUILD) if(FREECAD_COPY_LIBPACK_BIN_TO_BUILD) - message("=======================================\n" - "Copying libpack 'bin' directory to build directory.\n") + message("Copying LibPack 'bin' directory to build 'bin' directory...") file(COPY ${FREECAD_LIBPACK_DIR}/bin DESTINATION ${CMAKE_BINARY_DIR}) - message("... done copying libpack 'bin' directory.\n=======================================\n") + if(FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + message("Copying DLLs from LibPack 'lib' directory to build 'bin' directory...") + file(GLOB DLLS ${FREECAD_LIBPACK_DIR}/lib/*.dll) + file(COPY ${DLLS} DESTINATION ${CMAKE_BINARY_DIR}/bin) + file(GLOB DLLS ${FREECAD_LIBPACK_DIR}/bin/Lib/site-packages/shiboken6/shiboken*.dll) + file(COPY ${DLLS} DESTINATION ${CMAKE_BINARY_DIR}/bin) + file(GLOB DLLS ${FREECAD_LIBPACK_DIR}/bin/Lib/site-packages/PySide6/pyside6*.dll) + file(COPY ${DLLS} DESTINATION ${CMAKE_BINARY_DIR}/bin) + endif() + message(STATUS " ... done.") endif() if(FREECAD_COPY_PLUGINS_BIN_TO_BUILD) message(STATUS "=======================================\n" @@ -42,8 +54,15 @@ macro(CopyLibpackDirectories) install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/sqldrivers DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/styles DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/printsupport DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + if(NOT FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/printsupport DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + endif() + if(FREECAD_LIBPACK_VERSION VERSION_GREATER_EQUAL "3.0.0") + install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/tls DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + endif() install(DIRECTORY ${FREECAD_LIBPACK_DIR}/resources DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${FREECAD_LIBPACK_DIR}/bin DESTINATION ${CMAKE_INSTALL_PREFIX}) + install(DIRECTORY ${FREECAD_LIBPACK_DIR}/lib DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.dll") message(STATUS "Created install commands for INSTALL target.\n") endif() endmacro() diff --git a/cMake/FreeCAD_Helpers/FreeCADLibpackChecks.cmake b/cMake/FreeCAD_Helpers/FreeCADLibpackChecks.cmake index a3b7ea4b95..7585bc33d1 100644 --- a/cMake/FreeCAD_Helpers/FreeCADLibpackChecks.cmake +++ b/cMake/FreeCAD_Helpers/FreeCADLibpackChecks.cmake @@ -4,17 +4,25 @@ macro(FreeCADLibpackChecks) if(FREECAD_LIBPACK_USE) # checking for a unique file in LibPack location to make sure the right version of the LibPack is there - find_file(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER MANIFEST.db ${FREECAD_LIBPACK_DIR}) + find_file(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER MANIFEST.db PATHS ${FREECAD_LIBPACK_DIR} NO_DEFAULT_PATH NO_CACHE) + find_file(FREECAD_LIBPACK_CHECKFILE_VERSION FREECAD_LIBPACK_VERSION PATHS ${FREECAD_LIBPACK_DIR} NO_DEFAULT_PATH NO_CACHE) # don't show them in the GUI set(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER "${FREECAD_LIBPACK_CHECKFILE_CLBUNDLER}" CACHE INTERNAL "Find libpack") + set(FREECAD_LIBPACK_CHECKFILE_VERSION "${FREECAD_LIBPACK_CHECKFILE_VERSION}" CACHE INTERNAL "Find libpack v3+") if (FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) set(FREECAD_LIBPACK_VERSION "CLbundler" CACHE STRING "Displays if the libpack has been found" FORCE) + message("Found LibPack v2 (CLBundler) via ${FREECAD_LIBPACK_CHECKFILE_CLBUNDLER}") include(cMake/UseLibPackCLbundler.cmake) + elseif (FREECAD_LIBPACK_CHECKFILE_VERSION) + file(READ ${FREECAD_LIBPACK_CHECKFILE_VERSION} FREECAD_LIBPACK_VERSION) + set(FREECAD_LIBPACK_VERSION "${FREECAD_LIBPACK_VERSION}" CACHE STRING "Version of the LibPack, if found" FORCE) + message("Found LibPack " ${FREECAD_LIBPACK_VERSION}) + include(cMake/UseLibPack3.cmake) else(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) set(FREECAD_LIBPACK_VERSION "NOTFOUND" CACHE STRING "Displays if the libpack has been found" FORCE) - message(SEND_ERROR "Could not find libpack in specified location:" ${FREECAD_LIBPACK_DIR}) + message(SEND_ERROR "Could not find LibPack in specified location:" ${FREECAD_LIBPACK_DIR}) endif(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) # -------------------------------- PyCXX -------------------------------- diff --git a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake index 9324fc10fe..17ed6d2d9c 100644 --- a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake +++ b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake @@ -55,6 +55,7 @@ macro(InitializeFreeCADBuildOptions) option(FREECAD_COPY_PLUGINS_BIN_TO_BUILD "Copy plugins to the build directory." OFF) endif() else() + message(WARNING Could not locate ${FREECAD_LIBPACK_DIR}/plugins/imageformats/qsvg.dll) message("Libpack NOT found.\nIf you intend to use a Windows libpack, set the FREECAD_LIBPACK_DIR to the libpack directory.") message(STATUS "Visit: https://github.com/FreeCAD/FreeCAD-Libpack/releases/ for Windows libpack downloads.") endif() diff --git a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake index 13eb953dd1..12b4a784c0 100644 --- a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake +++ b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake @@ -21,9 +21,9 @@ macro(SetGlobalCompilerAndLinkerSettings) if(MSVC) # set default compiler settings - add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zm150 /bigobj") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFC_DEBUG /Zm150 /bigobj") + add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR -DNOMINMAX) + add_compile_options(/Zm150 /bigobj) + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFC_DEBUG") # set default libs set (CMAKE_C_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib SHFolder.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib winmm.lib comsupp.lib Ws2_32.lib dbghelp.lib ") set (CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}") @@ -50,8 +50,7 @@ macro(SetGlobalCompilerAndLinkerSettings) string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") endif(CCACHE_PROGRAM) - - option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" ON) + option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" ON) if(FREECAD_USE_MP_COMPILE_FLAG) # set "Build with Multiple Processes" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") diff --git a/cMake/FreeCAD_Helpers/SetupCoin3D.cmake b/cMake/FreeCAD_Helpers/SetupCoin3D.cmake index 2f4c5c99a8..fb0c7420e5 100644 --- a/cMake/FreeCAD_Helpers/SetupCoin3D.cmake +++ b/cMake/FreeCAD_Helpers/SetupCoin3D.cmake @@ -1,5 +1,5 @@ macro(SetupCoin3D) -# -------------------------------- Coin3D -------------------------------- + # -------------------------------- Coin3D -------------------------------- if (WIN32 AND MINGW) find_path(COIN3D_INCLUDE_DIRS Inventor/So.h) @@ -8,32 +8,37 @@ macro(SetupCoin3D) # Try MODULE mode find_package(Coin3D) - if(NOT COIN3D_FOUND) + if (NOT COIN3D_FOUND) # Try CONFIG mode find_package(Coin CONFIG REQUIRED) if (Coin_FOUND) - set (COIN3D_INCLUDE_DIRS ${Coin_INCLUDE_DIR}) - set (COIN3D_LIBRARIES ${Coin_LIBRARIES}) - else() - message(FATAL_ERROR "=================\n" - "Coin3D not found.\n" - "=================\n") - endif() - endif(NOT COIN3D_FOUND) + set(COIN3D_INCLUDE_DIRS ${Coin_INCLUDE_DIR}) + set(COIN3D_LIBRARIES ${Coin_LIBRARIES}) + endif () + ENDIF () - IF(NOT COIN3D_VERSION) - file(READ "${COIN3D_INCLUDE_DIRS}/Inventor/C/basic.h" _coin3d_basic_h) - string(REGEX MATCH "define[ \t]+COIN_MAJOR_VERSION[ \t]+([0-9?])" _coin3d_major_version_match "${_coin3d_basic_h}") - set(COIN3D_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+COIN_MINOR_VERSION[ \t]+([0-9?])" _coin3d_minor_version_match "${_coin3d_basic_h}") - set(COIN3D_MINOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+COIN_MICRO_VERSION[ \t]+([0-9?])" _coin3d_micro_version_match "${_coin3d_basic_h}") - set(COIN3D_MICRO_VERSION "${CMAKE_MATCH_1}") - set(COIN3D_VERSION "${COIN3D_MAJOR_VERSION}.${COIN3D_MINOR_VERSION}.${COIN3D_MICRO_VERSION}") - ENDIF() + IF (NOT COIN3D_VERSION) + file(READ "${COIN3D_INCLUDE_DIRS}/Inventor/C/basic.h" _coin3d_basic_h) + string(REGEX MATCH "define[ \t]+COIN_MAJOR_VERSION[ \t]+([0-9?])" _coin3d_major_version_match "${_coin3d_basic_h}") + set(COIN3D_MAJOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+COIN_MINOR_VERSION[ \t]+([0-9?])" _coin3d_minor_version_match "${_coin3d_basic_h}") + set(COIN3D_MINOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+COIN_MICRO_VERSION[ \t]+([0-9?])" _coin3d_micro_version_match "${_coin3d_basic_h}") + set(COIN3D_MICRO_VERSION "${CMAKE_MATCH_1}") + set(COIN3D_VERSION "${COIN3D_MAJOR_VERSION}.${COIN3D_MINOR_VERSION}.${COIN3D_MICRO_VERSION}") + ENDIF () - IF(NOT PIVY_VERSION) - execute_process (COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.__version__,end='')" OUTPUT_VARIABLE PIVY_VERSION) - ENDIF() + IF (NOT PIVY_VERSION) + message(STATUS "Checking Pivy version by importing it in a Python program...") + execute_process( + COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.__version__,end='')" + OUTPUT_VARIABLE PIVY_VERSION + RESULT_VARIABLE RETURN_CODE) + if (RETURN_CODE EQUAL 0) + message(STATUS "Found Pivy ${PIVY_VERSION}") + else () + message(FATAL_ERROR "Failed to import Pivy using ${Python3_EXECUTABLE}") + endif () + ENDIF () endmacro(SetupCoin3D) diff --git a/cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake b/cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake index 92f21a21b6..cd00c0d2cc 100644 --- a/cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake +++ b/cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake @@ -26,7 +26,13 @@ macro(SetupSalomeSMESH) # check which modules are available if(UNIX OR WIN32) - find_package(VTK COMPONENTS vtkCommonCore REQUIRED NO_MODULE) + # Module names changed between 8 and 9, so do a QUIET find for 9 and its module name first, and fall back + # to v7 minimum with the old component name if it is not found. + find_package(VTK 9 COMPONENTS CommonCore QUIET NO_MODULE) + if(NOT VTK_FOUND) + message(STATUS "Did not find VTK 9, trying for an older version") + find_package(VTK COMPONENTS vtkCommonCore REQUIRED NO_MODULE) + endif() if(${VTK_MAJOR_VERSION} LESS 9) list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI vtkhdf5 vtkFiltersParallelDIY2 vtkRenderingCore vtkInteractionStyle vtkRenderingFreeType vtkRenderingOpenGL2) foreach(_module ${VTK_COMPONENTS}) diff --git a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake index 6500b464ab..d6078c07c4 100644 --- a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake +++ b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake @@ -170,43 +170,6 @@ macro(SetupShibokenAndPyside) endmacro(SetupShibokenAndPyside) -# 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) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -m pip show ${PACKAGE} - RESULT_VARIABLE FAILURE - OUTPUT_VARIABLE PRINT_OUTPUT - ) - if(NOT FAILURE) - # Extract Name: and Location: lines and use them to construct the include directory - string(REPLACE "\n" ";" PIP_OUTPUT_LINES ${PRINT_OUTPUT}) - foreach(LINE IN LISTS PIP_OUTPUT_LINES) - STRING(FIND "${LINE}" "Name: " NAME_STRING_LOCATION) - STRING(FIND "${LINE}" "Location: " LOCATION_STRING_LOCATION) - if(${NAME_STRING_LOCATION} EQUAL 0) - STRING(SUBSTRING "${LINE}" 6 -1 PIP_PACKAGE_NAME) - elseif(${LOCATION_STRING_LOCATION} EQUAL 0) - STRING(SUBSTRING "${LINE}" 10 -1 PIP_PACKAGE_LOCATION) - endif() - endforeach() - message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") - file(TO_NATIVE_PATH "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/include" INCLUDE_DIR) - file(TO_NATIVE_PATH "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/lib" LIBRARY) - if(EXISTS ${INCLUDE_DIR}) - set(${PACKAGE}_INCLUDE_DIR ${INCLUDE_DIR}) - else() - message(STATUS "${PACKAGE} include directory '${INCLUDE_DIR}' does not exist") - endif() - if(EXISTS ${LIBRARY}) - set(${PACKAGE}_LIBRARY ${LIBRARY}) - else() - message(STATUS "${PACKAGE} library directory '${LIBRARY}' does not exist") - endif() - set(${PACKAGE}_FOUND TRUE) - endif() -endmacro() - # Macros similar to FindQt4.cmake's WRAP_UI and WRAP_RC, for the automatic generation of Python # code from Qt4's user interface ('.ui') and resource ('.qrc') files. These macros are called: diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index 34f5ddfec8..f4f628e483 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -269,8 +269,57 @@ MACRO(SET_PYTHON_PREFIX_SUFFIX ProjectName) endif(WIN32) 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) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -m pip show ${PACKAGE} + RESULT_VARIABLE FAILURE + OUTPUT_VARIABLE PRINT_OUTPUT + ) + if(NOT FAILURE) + # Extract Name: and Location: lines and use them to construct the include directory + string(REPLACE "\n" ";" PIP_OUTPUT_LINES ${PRINT_OUTPUT}) + foreach(LINE IN LISTS PIP_OUTPUT_LINES) + STRING(FIND "${LINE}" "Name: " NAME_STRING_LOCATION) + STRING(FIND "${LINE}" "Location: " LOCATION_STRING_LOCATION) + if(${NAME_STRING_LOCATION} EQUAL 0) + STRING(SUBSTRING "${LINE}" 6 -1 PIP_PACKAGE_NAME) + STRING(STRIP "${PIP_PACKAGE_NAME}" PIP_PACKAGE_NAME) + STRING(REPLACE "-" "_" PIP_PACKAGE_NAME "${PIP_PACKAGE_NAME}") + elseif(${LOCATION_STRING_LOCATION} EQUAL 0) + STRING(SUBSTRING "${LINE}" 9 -1 PIP_PACKAGE_LOCATION) + STRING(STRIP "${PIP_PACKAGE_LOCATION}" PIP_PACKAGE_LOCATION) + endif() + endforeach() + file(TO_CMAKE_PATH "${PIP_PACKAGE_LOCATION}" PIP_PACKAGE_LOCATION) + if(EXISTS "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/include") + set(INCLUDE_DIR "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/include") + endif() + # There are many different library naming schemes, but basically we are looking for things that look like + # PACKAGE*.lib/so or PACKAGE_d*.lib/so + if(WIN32) + file(GLOB OPT_LIBRARIES "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/${PIP_PACKAGE_NAME}.*.lib") + file(GLOB DEBUG_LIBRARIES "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/${PIP_PACKAGE_NAME}_d.*.lib") + else() + file(GLOB OPT_LIBRARIES "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/${PIP_PACKAGE_NAME}.*.so") + file(GLOB DEBUG_LIBRARIES "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/${PIP_PACKAGE_NAME}_d.*.so") + endif() + if (OPT_LIBRARIES AND DEBUG_LIBRARIES) + set(${PACKAGE}_LIBRARIES optimized ${OPT_LIBRARIES} debug ${DEBUG_LIBRARIES} CACHE PATH "") + elseif(OPT_LIBRARIES) + set(${PACKAGE}_LIBRARIES ${OPT_LIBRARIES} CACHE PATH "") + elseif(DEBUG_LIBRARIES) + set(${PACKAGE}_LIBRARIES ${DEBUG_LIBRARIES} CACHE PATH "") + endif() + set(${PACKAGE}_INCLUDE_DIRS ${INCLUDE_DIR} CACHE PATH "") + set(${PACKAGE}_FOUND ON CACHE BOOL OFF) + message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") + endif() +endmacro() + function(target_compile_warn_error ProjectName) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) target_compile_options(${ProjectName} PRIVATE -Werror) endif() -endfunction() +endfunction() \ No newline at end of file diff --git a/cMake/UseLibPack3.cmake b/cMake/UseLibPack3.cmake new file mode 100644 index 0000000000..25c2dd3a89 --- /dev/null +++ b/cMake/UseLibPack3.cmake @@ -0,0 +1,38 @@ +set(ENV{PATH} "${FREECAD_LIBPACK_DIR};$ENV{PATH}") +list(PREPEND CMAKE_PREFIX_PATH "${FREECAD_LIBPACK_DIR}") + +set (Python3_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe) +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + +# Make sure we are using the static versions of Boost here: the LibPack includes both +set(Boost_USE_STATIC_LIBS OFF) +find_package(Boost COMPONENTS filesystem program_options regex system thread date_time REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/lib/cmake NO_DEFAULT_PATH) + +set(OCE_DIR ${FREECAD_LIBPACK_DIR}/lib/cmake CACHE PATH "" FORCE) + +set(SWIG_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/swig.exe CACHE FILEPATH "Swig" FORCE) + +find_package(Qt6 REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/lib/cmake NO_DEFAULT_PATH) +message(STATUS "Found LibPack 3 Qt ${Qt6_VERSION}") + +find_package(XercesC REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/cmake NO_DEFAULT_PATH) +message(STATUS "Found LibPack 3 XercesC ${XercesC_VERSION}") + +find_package(yaml-cpp REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/lib/cmake NO_DEFAULT_PATH) +message(STATUS "Found LibPack 3 yaml-cpp ${XercesC_VERSION}") + +find_package(Coin REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/lib/cmake NO_DEFAULT_PATH) +message(STATUS "Found LibPack 3 Coin ${Coin_VERSION}") +# For compatibility with the rest of the cMake scripts: +set (COIN3D_FOUND TRUE) + +set (NETGENDATA ${FREECAD_LIBPACK_DIR}/include/netgen) + +if (FREECAD_USE_FREETYPE) + find_package(freetype REQUIRED PATHS ${FREECAD_LIBPACK_DIR}/lib/cmake NO_DEFAULT_PATH) + message(STATUS "Found LibPack 3 Freetype ${freetype_VERSION} library from ${freetype_LIBRARY}") +endif (FREECAD_USE_FREETYPE) + +set (HDF5_DIR ${FREECAD_LIBPACK_DIR}/share/cmake) + +link_directories (${FREECAD_LIBPACK_DIR}/lib) diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis.cpp index 246502f644..89e7160a1b 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis.cpp @@ -26,6 +26,13 @@ // Date : 28/03/2006 // Project : SALOME // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_Hypothesis.hxx" #include "NETGENPlugin_Mesher.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cpp index 2d3a48aaee..c83b9e911d 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cpp @@ -27,6 +27,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_Hypothesis_2D.hxx" #include diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp index 0e0f662b92..2d43a3e08d 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp @@ -27,6 +27,14 @@ // Project : SALOME //============================================================================= +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif + #include "NETGENPlugin_Mesher.hxx" #include "NETGENPlugin_Hypothesis_2D.hxx" #include "NETGENPlugin_SimpleHypothesis_3D.hxx" @@ -367,11 +375,27 @@ struct Link { return (( Contains( other.n1 ) || Contains( other.n2 )) && ( this != &other )); } + bool operator==(const Link& rhs) const { + return rhs.n1 == n1 && rhs.n2 == n2; + } +}; + +template<> +struct std::hash +{ + std::size_t operator()(const Link& aLink) const noexcept + { + return std::hash {}(aLink.n1 + aLink.n2); + } }; int HashCode(const Link& aLink, int aLimit) { +#if OCC_VERSION_HEX >= 0x070800 + return std::hash {}(aLink); +#else return HashCode(aLink.n1 + aLink.n2, aLimit); +#endif } Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2) diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cpp index 5dfe76bed4..2a7a8908a3 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cpp @@ -27,6 +27,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_NETGEN_2D.hxx" #include "NETGENPlugin_Hypothesis_2D.hxx" #include "NETGENPlugin_SimpleHypothesis_2D.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cpp index d9695c5640..570625809d 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cpp @@ -27,6 +27,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_NETGEN_2D3D.hxx" #include "NETGENPlugin_Hypothesis.hxx" #include "NETGENPlugin_SimpleHypothesis_3D.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cpp index 72269e84db..2ccde3e472 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cpp @@ -21,6 +21,14 @@ // Author : Edward AGAPOV (OCC) // Project : SALOME // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif + #include "NETGENPlugin_NETGEN_2D_ONLY.hxx" #include "NETGENPlugin_Mesher.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp index ea53b5563c..e391249b67 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp @@ -28,6 +28,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_NETGEN_3D.hxx" #include "NETGENPlugin_Hypothesis.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cpp index 85532091ba..251ba8b72a 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cpp @@ -23,6 +23,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_SimpleHypothesis_2D.hxx" #include "NETGENPlugin_Hypothesis.hxx" diff --git a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cpp b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cpp index b5d7302137..d257f33ded 100644 --- a/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cpp +++ b/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cpp @@ -23,6 +23,13 @@ // Project : SALOME //============================================================================= // +#ifdef _WIN32 +// Include this before any possible calls to "using namespace std" to avoid conflicts +// with std::byte in the Windows API header files - as of MSVC 2022 17.10.1, June 2024 +#define NOMINMAX 1 +#include +#undef NOMINMAX +#endif #include "NETGENPlugin_SimpleHypothesis_3D.hxx" #include "NETGENPlugin_Hypothesis.hxx" diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index a0bf57a8b7..58b88f0bf5 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -592,7 +592,7 @@ Py::Object ParameterGrpPy::setString(const Py::Tuple& args) Py::Object ParameterGrpPy::getString(const Py::Tuple& args) { char* pstr = nullptr; - char* str = ""; + const char* str = ""; if (!PyArg_ParseTuple(args.ptr(), "s|s", &pstr, &str)) { throw Py::Exception(); } diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 1d3208b00c..760ab0e5d8 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -70,6 +70,13 @@ if(MSVC) ${OPENGL_gl_LIBRARY} ) + if(FREECAD_QT_MAJOR_VERSION EQUAL 6) + list(APPEND FreeCADGui_LIBS + Qt6::GuiPrivate + ) + endif() + + if(FREECAD_USE_3DCONNEXION) list(APPEND FreeCADGui_LIBS hid diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 31a63c394d..63672bfbe4 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -55,8 +55,12 @@ # include #endif -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6,0,0) -# include +#if defined(Q_OS_WIN) + #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) + #include + #else + #include + #endif #endif #include @@ -1808,10 +1812,17 @@ void MainWindow::loadWindowSettings() max ? showMaximized() : show(); // make menus and tooltips usable in fullscreen under Windows, see issue #7563 -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6,0,0) - if (QWindow* win = this->windowHandle()) { - QWindowsWindowFunctions::setHasBorderInFullScreen(win, true); - } +#if defined(Q_OS_WIN) + #if QT_VERSION < QT_VERSION_CHECK(6,0,0) + if (QWindow* win = this->windowHandle()) { + QWindowsWindowFunctions::setHasBorderInFullScreen(win, true); + } + #else + using namespace QNativeInterface::Private; + if (auto *windowsWindow = dynamic_cast(this->windowHandle())) { + windowsWindow->setHasBorderInFullScreen(true); + } + #endif #endif statusBar()->setVisible(showStatusBar); diff --git a/src/LibraryVersions.h.cmake b/src/LibraryVersions.h.cmake index df24cba839..c2c9d39116 100644 --- a/src/LibraryVersions.h.cmake +++ b/src/LibraryVersions.h.cmake @@ -25,37 +25,37 @@ // No CMake version info for libarea, Zipios, or KDL // Coin3D -constexpr char * fcCoin3dVersion = "${COIN3D_VERSION}"; +constexpr const char * fcCoin3dVersion = "${COIN3D_VERSION}"; // Eigen3 -constexpr char * fcEigen3Version = "${EIGEN3_VERSION}"; +constexpr const char * fcEigen3Version = "${EIGEN3_VERSION}"; // FreeType -constexpr char * fcFreetypeVersion = "${FREETYPE_VERSION_STRING}"; +constexpr const char * fcFreetypeVersion = "${FREETYPE_VERSION_STRING}"; // pcl -constexpr char * fcPclVersion = "${PCL_VERSION}"; +constexpr const char * fcPclVersion = "${PCL_VERSION}"; // PyCXX -constexpr char * fcPycxxVersion = "${PYCXX_VERSION}"; +constexpr const char * fcPycxxVersion = "${PYCXX_VERSION}"; // PySide -constexpr char * fcPysideVersion = "${PySide2_VERSION}"; +constexpr const char * fcPysideVersion = "${PySide2_VERSION}"; // PyBind -constexpr char * fcPybind11Version = "${pybind11_VERSION}"; +constexpr const char * fcPybind11Version = "${pybind11_VERSION}"; // Shiboken -constexpr char * fcShibokenVersion = "${Shiboken2_VERSION}"; +constexpr const char * fcShibokenVersion = "${Shiboken2_VERSION}"; // vtk -constexpr char * fcVtkVersion = "${VTK_VERSION}"; +constexpr const char * fcVtkVersion = "${VTK_VERSION}"; // Xerces-C -constexpr char * fcXercescVersion = "${XercesC_VERSION}"; +constexpr const char * fcXercescVersion = "${XercesC_VERSION}"; // Pivy -constexpr char * fcPivyVersion = "${PIVY_VERSION}"; +constexpr const char * fcPivyVersion = "${PIVY_VERSION}"; #endif // LIBRARY_VERSIONS_H diff --git a/src/Mod/CAM/libarea/CMakeLists.txt b/src/Mod/CAM/libarea/CMakeLists.txt index 00aff760c1..34eb218b6e 100644 --- a/src/Mod/CAM/libarea/CMakeLists.txt +++ b/src/Mod/CAM/libarea/CMakeLists.txt @@ -19,7 +19,7 @@ link_directories(${OCC_LIBRARY_DIR}) if(NOT FREECAD_USE_PYBIND11) - if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) + if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIBPACK_CHECKFILE_VERSION) # boost-python >= 1.67 on some platforms has suffix if (FORCE_BOOST_PY_SUFFIX) set(BOOST_PY_SUFFIX ${FORCE_BOOST_PY_SUFFIX}) diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui b/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui index f09608cf7f..b76e93c8c4 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui @@ -550,7 +550,7 @@ - + Qt::Horizontal @@ -605,7 +605,7 @@ - + Qt::Horizontal diff --git a/src/Mod/Fem/Gui/TaskTetParameter.ui b/src/Mod/Fem/Gui/TaskTetParameter.ui index 8f41bf617f..2560d0c513 100644 --- a/src/Mod/Fem/Gui/TaskTetParameter.ui +++ b/src/Mod/Fem/Gui/TaskTetParameter.ui @@ -21,7 +21,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/src/Mod/Material/App/MaterialManagerPyImpl.cpp b/src/Mod/Material/App/MaterialManagerPyImpl.cpp index 833fdb0d6c..c84075d1cb 100644 --- a/src/Mod/Material/App/MaterialManagerPyImpl.cpp +++ b/src/Mod/Material/App/MaterialManagerPyImpl.cpp @@ -31,6 +31,8 @@ #include "MaterialManagerPy.cpp" +#include + using namespace Materials; // returns a string which represents the object e.g. when printed in python @@ -229,12 +231,11 @@ PyObject* MaterialManagerPy::save(PyObject* args, PyObject* kwds) PyObject* overwrite = Py_False; PyObject* saveAsCopy = Py_False; PyObject* saveInherited = Py_False; - static char* kwds_save[] = - {"library", "material", "path", "overwrite", "saveAsCopy", "saveInherited", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, + static const std::array kwlist { "library", "material", "path", "overwrite", "saveAsCopy", "saveInherited", nullptr }; + if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "etOet|O!O!O!", - kwds_save, + kwlist, "utf-8", &libraryName, &obj, "utf-8", &path, @@ -302,18 +303,18 @@ PyObject* MaterialManagerPy::filterMaterials(PyObject* args, PyObject* kwds) { PyObject* filterPy {}; PyObject* includeLegacy = Py_False; - static char* kwds_save[] = {"filter", - "includeLegacy", - nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, - kwds, - // "O|O!", - "O!|O!", - kwds_save, - &MaterialFilterPy::Type, - &filterPy, - &PyBool_Type, - &includeLegacy)) { + static const std::array kwds_save{ "filter", + "includeLegacy", + nullptr }; + if (!Base::Wrapped_ParseTupleAndKeywords(args, + kwds, + // "O|O!", + "O!|O!", + kwds_save, + &MaterialFilterPy::Type, + &filterPy, + &PyBool_Type, + &includeLegacy)) { return nullptr; } diff --git a/src/Mod/Mesh/App/Core/IO/Reader3MF.cpp b/src/Mod/Mesh/App/Core/IO/Reader3MF.cpp index eeb595cd76..5bd217a3cc 100644 --- a/src/Mod/Mesh/App/Core/IO/Reader3MF.cpp +++ b/src/Mod/Mesh/App/Core/IO/Reader3MF.cpp @@ -95,7 +95,7 @@ bool Reader3MF::LoadModel(std::istream& str) Base::StdInputSource inputSource(str, "3dmodel.model"); parser->parse(inputSource); - std::unique_ptr xmlDocument(parser->adoptDocument()); + std::unique_ptr xmlDocument(parser->adoptDocument()); return LoadModel(*xmlDocument); } catch (const XMLException&) { @@ -106,7 +106,7 @@ bool Reader3MF::LoadModel(std::istream& str) } } -bool Reader3MF::LoadModel(DOMDocument& xmlDocument) +bool Reader3MF::LoadModel(XERCES_CPP_NAMESPACE::DOMDocument& xmlDocument) { DOMNodeList* nodes = xmlDocument.getElementsByTagName(XStr("model").unicodeForm()); for (XMLSize_t i = 0; i < nodes->getLength(); i++) { diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index ec9581f5da..11a84e1a13 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -113,7 +113,7 @@ if (BUILD_FLAT_MESH) SET_BIN_DIR(flatmesh flatmesh /Mod/MeshPart) install(TARGETS flatmesh DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() - if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) + if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIBPACK_CHECKFILE_VERSION) # boost-python >= 1.67 on some platforms has suffix if (FORCE_BOOST_PY_SUFFIX) set(BOOST_PY_SUFFIX ${FORCE_BOOST_PY_SUFFIX}) diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index 6ca245d082..dcae1c7925 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -26,8 +26,11 @@ // OpenCASCADE // Standard* +#include #include +#if OCC_VERSION_HEX < 0x070800 #include +#endif #include #include #include @@ -41,7 +44,9 @@ #include #include #include +#if OCC_VERSION_HEX < 0x070800 #include +#endif #include #include #include @@ -76,7 +81,6 @@ #include #include #include -#include #if OCC_VERSION_HEX < 0x070700 # include diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 33e031e3d0..a556600cf5 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -156,20 +156,24 @@ PyObject *TopoShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // int TopoShapePy::PyInit(PyObject* args, PyObject* keywds) { #ifdef FC_USE_TNP_FIX - static char* kwlist[] = {"shape", "op", "tag", "hasher", nullptr}; + static const std::array kwlist{ "shape", + "op", + "tag", + "hasher", + nullptr }; long tag = 0; PyObject* pyHasher = nullptr; const char* op = nullptr; PyObject* pcObj = nullptr; - if (!PyArg_ParseTupleAndKeywords(args, - keywds, - "|OsiO!", - kwlist, - &pcObj, - &op, - &tag, - &App::StringHasherPy::Type, - &pyHasher)) { + if (!Base::Wrapped_ParseTupleAndKeywords(args, + keywds, + "|OsiO!", + kwlist, + &pcObj, + &op, + &tag, + &App::StringHasherPy::Type, + &pyHasher)) { return -1; } auto& self = *getTopoShapePtr(); @@ -2476,14 +2480,14 @@ PyObject* TopoShapePy::makeEvolved(PyObject *args, PyObject *kwds) PyObject* ProfOnSpine = Py_False; auto JoinType = JoinType::arc; double Tolerance = 0.0000001; - - static char* kwds_evolve[] = {"Profile", "Join", "AxeProf", "Solid", "ProfOnSpine", "Tolerance", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|iO!O!O!d", kwds_evolve, - &TopoShapePy::Type, &Profile, &JoinType, - &PyBool_Type, &AxeProf, &PyBool_Type, &Solid, - &PyBool_Type, &ProfOnSpine, &Tolerance)) + + static const std::array kwds_evolve{"Profile", "Join", "AxeProf", "Solid", "ProfOnSpine", "Tolerance", nullptr}; + if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!|iO!O!O!d", kwds_evolve, + &TopoShapePy::Type, &Profile, &JoinType, + &PyBool_Type, &AxeProf, &PyBool_Type, &Solid, + &PyBool_Type, &ProfOnSpine, &Tolerance)) { return nullptr; - + } try { return Py::new_reference_to(shape2pyshape(getTopoShapePtr()->makeElementEvolve( *static_cast(Profile)->getTopoShapePtr(), JoinType, @@ -3125,22 +3129,22 @@ PyObject* TopoShapePy::findSubShape(PyObject* args) PyObject* TopoShapePy::findSubShapesWithSharedVertex(PyObject* args, PyObject* keywds) { - static char* kwlist[] = {"shape", "needName", "checkGeometry", "tol", "atol", nullptr}; + static const std::array kwlist {"shape", "needName", "checkGeometry", "tol", "atol", nullptr}; PyObject* pyobj; PyObject* needName = Py_False; PyObject* checkGeometry = Py_True; double tol = 1e-7; double atol = 1e-12; - if (!PyArg_ParseTupleAndKeywords(args, - keywds, - "O!|OOdd", - kwlist, - &Type, - &pyobj, - &needName, - &checkGeometry, - &tol, - &atol)) { + if (!Base::Wrapped_ParseTupleAndKeywords(args, + keywds, + "O!|OOdd", + kwlist, + &Type, + &pyobj, + &needName, + &checkGeometry, + &tol, + &atol)) { return nullptr; } diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index a7b459e2b2..cd826c3f4d 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -46,6 +46,9 @@ FC_LOG_LEVEL_INIT("Spreadsheet", true, true) #ifdef _MSC_VER #define __func__ __FUNCTION__ +#ifdef PropertySheet +#undef PropertySheet // Microsoft's #define conflicts with the use below +#endif #endif using namespace App; diff --git a/tests/src/App/ElementMap.cpp b/tests/src/App/ElementMap.cpp index 38c6784bf1..3369b05e2f 100644 --- a/tests/src/App/ElementMap.cpp +++ b/tests/src/App/ElementMap.cpp @@ -363,7 +363,7 @@ TEST_F(ElementMapTest, mimicSimpleUnion) // pattern: new doc, create Cube, create Cylinder, Union of both (Cube first) std::ostringstream ss; std::ostringstream finalSs; - char* docName = "Unnamed"; + const char* docName = "Unnamed"; LessComplexPart cube(1L, "Box", _hasher); LessComplexPart cylinder(2L, "Cylinder", _hasher); diff --git a/tests/src/Mod/Material/App/Model.cpp b/tests/src/Mod/Material/App/Model.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/src/Mod/Part/App/PartTestHelpers.cpp b/tests/src/Mod/Part/App/PartTestHelpers.cpp index 4c65b746a5..a97de3c0e8 100644 --- a/tests/src/Mod/Part/App/PartTestHelpers.cpp +++ b/tests/src/Mod/Part/App/PartTestHelpers.cpp @@ -75,7 +75,7 @@ void ExecutePython(const std::vector& python) } -void rectangle(double height, double width, char* name) +void rectangle(double height, double width, const char* name) { std::vector rectstring { "import FreeCAD, Part", diff --git a/tests/src/Mod/Part/App/PartTestHelpers.h b/tests/src/Mod/Part/App/PartTestHelpers.h index ee3efba95f..9a6589ed6f 100644 --- a/tests/src/Mod/Part/App/PartTestHelpers.h +++ b/tests/src/Mod/Part/App/PartTestHelpers.h @@ -47,7 +47,7 @@ const double minimalDistance = Base::Precision::Confusion() * 1000; void executePython(const std::vector& python); -void rectangle(double height, double width, char* name); +void rectangle(double height, double width, const char* name); std::tuple CreateRectFace(float len = 2.0, float wid = 3.0); diff --git a/tests/src/Mod/Part/App/PropertyTopoShape.cpp b/tests/src/Mod/Part/App/PropertyTopoShape.cpp index 1271dce6c6..a4c80dfeb1 100644 --- a/tests/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/tests/src/Mod/Part/App/PropertyTopoShape.cpp @@ -147,7 +147,7 @@ TEST_F(PropertyTopoShapeTest, testPropertyShapeCache) PropertyShapeCache propertyShapeCache; TopoShape topoShapeIn {_boxes[0]->Shape.getShape()}; // Any TopoShape to test with TopoShape topoShapeOut; - char* subName = "Face1"; // Cache key + const char* subName = "Face1"; // Cache key // Act auto gotShapeNotYet = propertyShapeCache.getShape(_boxes[0], topoShapeOut, subName); propertyShapeCache.setShape(_boxes[0], topoShapeIn, subName); diff --git a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp index ec4c24b373..556f93c61c 100644 --- a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -785,7 +785,7 @@ TEST_F(TopoShapeExpansionTest, setElementComboName) topoShape.getMappedName(Data::IndexedName::fromConst("Face", 7), true); Data::MappedName faceName2 = topoShape.getMappedName(Data::IndexedName::fromConst("Face", 8), true); - char* op = "Copy"; + const char* op = "Copy"; // Act Data::MappedName result = topoShape.setElementComboName(Data::IndexedName::fromConst("Edge", 1), {edgeName, faceName, faceName2}, @@ -810,7 +810,7 @@ TEST_F(TopoShapeExpansionTest, setElementComboNameCompound) topoShape.getMappedName(Data::IndexedName::fromConst("Face", 7), true); Data::MappedName faceName2 = topoShape.getMappedName(Data::IndexedName::fromConst("Face", 8), true); - char* op = "Copy"; + const char* op = "Copy"; // Act Data::MappedName result = topoShape.setElementComboName(Data::IndexedName::fromConst("Edge", 1), {edgeName, faceName, faceName2}, diff --git a/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp b/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp index 1d3254ac2f..b5910c5145 100644 --- a/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp +++ b/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp @@ -233,11 +233,14 @@ void testFindSubShapesForSourceWithTypeAndIndex(const std::string& shapeTypeStr, MappedName mappedName {elementStdMap[indexedName]}; const char shapeTypePrefix {indexedName.toString()[0]}; +#pragma warning(push) +#pragma warning(disable : 4834) // Discarding a [[nodiscard]], which we are about to do... EXPECT_NO_THROW(elementStdMap.at(indexedName)); // We check that the IndexedName // is one of the keys... EXPECT_NE(mappedName.find(shapeName.c_str()), -1); // ... that the element name is in the MappedName... EXPECT_EQ(mappedName.toString().back(), shapeTypePrefix); +#pragma warning(pop) } void testFindSubShapesForSourceWithType(const TopoShape& source,