From fbcf74e1a922dda28e1928e602c297409b40ed71 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Wed, 9 Oct 2024 17:07:03 +0200 Subject: [PATCH] swig issues --- .github/workflows/sub_buildWindows.yml | 2 + CMakeSettings.json | 27 ---------- cmake/SetupBoost.cmake | 2 +- src/isimpa/CMakeLists.txt | 56 ++++++++++----------- src/isimpa/GL/opengl_inc.h | 2 + src/lib_interface/input_output/ply/rply.cpp | 5 +- src/python_bindings/CMakeLists.txt | 21 +++++--- 7 files changed, 49 insertions(+), 66 deletions(-) delete mode 100644 CMakeSettings.json diff --git a/.github/workflows/sub_buildWindows.yml b/.github/workflows/sub_buildWindows.yml index b04d37ad..6e84f483 100644 --- a/.github/workflows/sub_buildWindows.yml +++ b/.github/workflows/sub_buildWindows.yml @@ -112,6 +112,7 @@ jobs: shell: powershell run: | nuget install swigwintools -OutputDirectory "${{ env.builddir }}/Tools" -Version 4.2.0 + nuget install python -Version 3.8 -OutputDirectory "${{ env.builddir }}/Tools" - name: Configuring CMake run: > cmake -B"${{ env.builddir }}" . @@ -120,6 +121,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=${{ env.builddir }}swigwintools.4.2.0/tools/swigwin-4.2.0/swig.exe -DSWIG_DIR=${{ env.builddir }}swigwintools.4.2.0/tools/swigwin-4.2.0 + -DPython_ROOT_DIR${{ env.builddir }}python.3.8.0/tools - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 - name: Compiling sources diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index 0c5fbf94..00000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "" - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ], - "variables": [] - } - ] -} \ No newline at end of file diff --git a/cmake/SetupBoost.cmake b/cmake/SetupBoost.cmake index 36548768..214b389e 100644 --- a/cmake/SetupBoost.cmake +++ b/cmake/SetupBoost.cmake @@ -14,7 +14,7 @@ macro(SetupBoost) VERSION 1.86.0 URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.xz URL_HASH SHA256=2c5ec5edcdff47ff55e27ed9560b0a0b94b07bd07ed9928b476150e16b0efc57 - OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES system\\\;algorithm\\\;random\\\;filesystem\\\;regex\\\;thread\\\;chrono\\\;test\\\;date_time\\\;python\\\;numeric/conversion" # Note the escapes! + OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_ENABLE_PYTHON ON" "BOOST_INCLUDE_LIBRARIES system\\\;algorithm\\\;random\\\;filesystem\\\;regex\\\;thread\\\;chrono\\\;test\\\;date_time\\\;python\\\;numeric/conversion" # Note the escapes! ) endif() endmacro(SetupBoost) diff --git a/src/isimpa/CMakeLists.txt b/src/isimpa/CMakeLists.txt index 91c591c9..be1fffa1 100644 --- a/src/isimpa/CMakeLists.txt +++ b/src/isimpa/CMakeLists.txt @@ -369,7 +369,7 @@ source_group( "" FILES ${ISIMPA_SOURCES} ) # Build auto-generated source files # Find package for generation -FIND_PACKAGE(PythonInterp REQUIRED) +find_package(Python3 COMPONENTS Interpreter Development) find_package(OpenGL) include(FindPackageMessage) @@ -480,8 +480,6 @@ GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets GIT_TAG v3.2.1 ) -# Find package for buildingfind_package(Python3 COMPONENTS Interpreter Development) -FIND_PACKAGE(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; import sysconfig; print(list(sysconfig.get_paths().values()))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -596,32 +594,32 @@ if(WIN32) # Check if we are on Windows install( PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION . COMPONENT Runtime ) endif( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ) # Try to fetch x64 version of python dll - get_filename_component(PYTHON_DLL_FILENAME "${PYTHON_LIBRARY}" NAME_WLE) - - SET(CMAKE_FIND_LIBRARY_PREFIXES "") - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") - - find_library( - PYTHON_DLL - NAMES ${PYTHON_DLL_FILENAME} - PATHS ${PYTHON_ROOT_FOLDER} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH - ) - if(NOT EXISTS ${PYTHON_DLL}) - MESSAGE(FATAL_ERROR "Python not found here ${PYTHON_DLL_FILENAME}.DLL") - else() - MESSAGE(STATUS "Python dll found here ${PYTHON_DLL}") - endif() - - install(FILES ${PYTHON_DLL} DESTINATION .) - - install(CODE " - set(INSTALL_DLL \"\${CMAKE_INSTALL_PREFIX}/${PYTHON_DLL_FILENAME}.DLL\") - file(SHA512 \${INSTALL_DLL} INSTALL_DLL_HASH) - MESSAGE(STATUS \"INSTALL_DLL_HASH \${INSTALL_DLL_HASH}\") - ") + #get_filename_component(PYTHON_DLL_FILENAME "${PYTHON_LIBRARY}" NAME_WLE) + + #SET(CMAKE_FIND_LIBRARY_PREFIXES "") + #SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") + + #find_library( + # PYTHON_DLL + # NAMES ${PYTHON_DLL_FILENAME} + # PATHS ${PYTHON_ROOT_FOLDER} + # NO_DEFAULT_PATH + # NO_SYSTEM_ENVIRONMENT_PATH + # NO_CMAKE_SYSTEM_PATH + #) + #if(NOT EXISTS ${PYTHON_DLL}) + # MESSAGE(FATAL_ERROR "Python not found here ${PYTHON_DLL_FILENAME}.DLL") + #else() + # MESSAGE(STATUS "Python dll found here ${PYTHON_DLL}") + #endif() + + #install(FILES ${PYTHON_DLL} DESTINATION .) + + #install(CODE " + #set(INSTALL_DLL \"\${CMAKE_INSTALL_PREFIX}/${PYTHON_DLL_FILENAME}.DLL\") + #file(SHA512 \${INSTALL_DLL} INSTALL_DLL_HASH) + #MESSAGE(STATUS \"INSTALL_DLL_HASH \${INSTALL_DLL_HASH}\") + #") endif() # Package creation instructions, NSIS under windows diff --git a/src/isimpa/GL/opengl_inc.h b/src/isimpa/GL/opengl_inc.h index c99b648e..df4d8ed9 100644 --- a/src/isimpa/GL/opengl_inc.h +++ b/src/isimpa/GL/opengl_inc.h @@ -31,6 +31,8 @@ #include "first_header_include.hpp" #ifdef _WINDOWS +#include +#include #include #endif #ifdef _UNIX diff --git a/src/lib_interface/input_output/ply/rply.cpp b/src/lib_interface/input_output/ply/rply.cpp index 2fcbb0fe..bcbc6899 100644 --- a/src/lib_interface/input_output/ply/rply.cpp +++ b/src/lib_interface/input_output/ply/rply.cpp @@ -377,11 +377,11 @@ p_ply ply_open_from_file(FILE *fp, p_ply_error_cb error_cb, p_ply ply; if (error_cb == NULL) error_cb = ply_error_cb; assert(fp); + ply = ply_alloc(); if (!ply_type_check()) { error_cb(ply, "Incompatible type system"); return NULL; } - ply = ply_alloc(); if (!ply) { error_cb(NULL, "Out of memory"); return NULL; @@ -477,13 +477,12 @@ p_ply ply_create(const char *name, e_ply_storage_mode storage_mode, p_ply ply_create_to_file(FILE *fp, e_ply_storage_mode storage_mode, p_ply_error_cb error_cb, long idata, void *pdata) { - p_ply ply; + p_ply ply = ply_alloc(); assert(fp && storage_mode <= PLY_DEFAULT); if (!ply_type_check()) { error_cb(ply, "Incompatible type system"); return NULL; } - ply = ply_alloc(); if (!ply) { error_cb(NULL, "Out of memory"); return NULL; diff --git a/src/python_bindings/CMakeLists.txt b/src/python_bindings/CMakeLists.txt index be1b515e..b826335a 100644 --- a/src/python_bindings/CMakeLists.txt +++ b/src/python_bindings/CMakeLists.txt @@ -9,13 +9,22 @@ include( InstallRequiredSystemLibraries ) #---------------------------------------# # require swig > v3 -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) -# Find package for building -FIND_PACKAGE(PythonLibs REQUIRED) -# Find package for testing -FIND_PACKAGE(PythonInterp REQUIRED) +find_package(SWIG REQUIRED) +include(UseSWIG) + +if(${SWIG_VERSION} VERSION_GREATER_EQUAL 4) + list(APPEND CMAKE_SWIG_FLAGS "-doxygen") +endif() + +if(UNIX AND NOT APPLE) + list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64") +endif() + +# Find Python 3 +find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) +list(APPEND CMAKE_SWIG_FLAGS "-py3" "-DPY3") + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})