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
This commit is contained in:
Chris Hennes
2024-06-24 11:25:05 -05:00
committed by GitHub
parent c06cbce42c
commit 5e47f6804f
42 changed files with 421 additions and 156 deletions

View File

@@ -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)

22
cMake/FindPySide6.cmake Normal file
View File

@@ -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()

28
cMake/FindShiboken6.cmake Normal file
View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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 --------------------------------

View File

@@ -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()

View File

@@ -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")

View File

@@ -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)

View File

@@ -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})

View File

@@ -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:

View File

@@ -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()

38
cMake/UseLibPack3.cmake Normal file
View File

@@ -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)

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_Hypothesis.hxx"
#include "NETGENPlugin_Mesher.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_Hypothesis_2D.hxx"
#include <utilities.h>

View File

@@ -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 <windows.h>
#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<Link>
{
std::size_t operator()(const Link& aLink) const noexcept
{
return std::hash<int> {}(aLink.n1 + aLink.n2);
}
};
int HashCode(const Link& aLink, int aLimit)
{
#if OCC_VERSION_HEX >= 0x070800
return std::hash<Link> {}(aLink);
#else
return HashCode(aLink.n1 + aLink.n2, aLimit);
#endif
}
Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2)

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_NETGEN_2D.hxx"
#include "NETGENPlugin_Hypothesis_2D.hxx"
#include "NETGENPlugin_SimpleHypothesis_2D.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_NETGEN_2D3D.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "NETGENPlugin_SimpleHypothesis_3D.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
#include "NETGENPlugin_Mesher.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_NETGEN_3D.hxx"
#include "NETGENPlugin_Hypothesis.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_SimpleHypothesis_2D.hxx"
#include "NETGENPlugin_Hypothesis.hxx"

View File

@@ -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 <windows.h>
#undef NOMINMAX
#endif
#include "NETGENPlugin_SimpleHypothesis_3D.hxx"
#include "NETGENPlugin_Hypothesis.hxx"

View File

@@ -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();
}

View File

@@ -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

View File

@@ -55,8 +55,12 @@
# include <QPushButton>
#endif
#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
# include <QtPlatformHeaders/QWindowsWindowFunctions>
#if defined(Q_OS_WIN)
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#else
#include <qpa/qplatformwindow_p.h>
#endif
#endif
#include <boost/algorithm/string/predicate.hpp>
@@ -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<QWindowsWindow*>(this->windowHandle())) {
windowsWindow->setHasBorderInFullScreen(true);
}
#endif
#endif
statusBar()->setVisible(showStatusBar);

View File

@@ -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

View File

@@ -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})

View File

@@ -550,7 +550,7 @@
</widget>
</item>
<item row="7" column="1">
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -605,7 +605,7 @@
</widget>
</item>
<item row="8" column="1">
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>

View File

@@ -21,7 +21,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout1">
<item>
<widget class="QLabel" name="label">
<property name="text">
@@ -39,7 +39,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout2">
<item>
<widget class="QLabel" name="label">
<property name="text">

View File

@@ -31,6 +31,8 @@
#include "MaterialManagerPy.cpp"
#include <Base/PyWrapParseTupleAndKeywords.h>
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<const char *, 7> 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<const char*, 3> 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;
}

View File

@@ -95,7 +95,7 @@ bool Reader3MF::LoadModel(std::istream& str)
Base::StdInputSource inputSource(str, "3dmodel.model");
parser->parse(inputSource);
std::unique_ptr<DOMDocument> xmlDocument(parser->adoptDocument());
std::unique_ptr<XERCES_CPP_NAMESPACE::DOMDocument> 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++) {

View File

@@ -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})

View File

@@ -26,8 +26,11 @@
// OpenCASCADE
// Standard*
#include <Standard_Version.hxx>
#include <Standard_AbortiveTransaction.hxx>
#if OCC_VERSION_HEX < 0x070800
#include <Standard_Address.hxx>
#endif
#include <Standard_Boolean.hxx>
#include <Standard_Byte.hxx>
#include <Standard_Character.hxx>
@@ -41,7 +44,9 @@
#include <Standard_DomainError.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_ExtCharacter.hxx>
#if OCC_VERSION_HEX < 0x070800
#include <Standard_ExtString.hxx>
#endif
#include <Standard_Failure.hxx>
#include <Standard_GUID.hxx>
#include <Standard_ImmutableObject.hxx>
@@ -76,7 +81,6 @@
#include <Standard_TypeMismatch.hxx>
#include <Standard_Underflow.hxx>
#include <Standard_UUID.hxx>
#include <Standard_Version.hxx>
#if OCC_VERSION_HEX < 0x070700
# include <Standard_TooManyUsers.hxx>

View File

@@ -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<const char*, 5> 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<const char*, 7> 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<TopoShapePy*>(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<const char*, 6> 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;
}

View File

@@ -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;

View File

@@ -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);

View File

View File

@@ -75,7 +75,7 @@ void ExecutePython(const std::vector<std::string>& python)
}
void rectangle(double height, double width, char* name)
void rectangle(double height, double width, const char* name)
{
std::vector<std::string> rectstring {
"import FreeCAD, Part",

View File

@@ -47,7 +47,7 @@ const double minimalDistance = Base::Precision::Confusion() * 1000;
void executePython(const std::vector<std::string>& python);
void rectangle(double height, double width, char* name);
void rectangle(double height, double width, const char* name);
std::tuple<TopoDS_Face, TopoDS_Wire, TopoDS_Edge, TopoDS_Edge, TopoDS_Edge, TopoDS_Edge>
CreateRectFace(float len = 2.0, float wid = 3.0);

View File

@@ -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);

View File

@@ -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},

View File

@@ -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,