From 0f0d22ab61a5d252830e67e20906070b52cbe95a Mon Sep 17 00:00:00 2001 From: Mikael Bourhis Date: Wed, 25 Oct 2023 16:22:49 +0200 Subject: [PATCH] Python wrapper: update and improve CMakeLists Tested and compatible with: Ubuntu 20.04.6 LTS : Python 3.8.10; CMake 3.16.3; Swig 4.0.1 Debian 11 : Python 3.9.2; CMake 3.13.4; Swig 4.0.2 Ubuntu 22.04.3 LTS : Python 3.10.12; CMake 3.22.1; Swig 4.0.2 Ubuntu 23.10 : Python 3.11.6; CMake 3.27.4; Swig 4.1.0 Alpine 3.18.4 : Python 3.11.6; CMake 3.26.5; Swig 4.1.1 Signed-off-by: Mikael Bourhis --- pyiec61850/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyiec61850/CMakeLists.txt b/pyiec61850/CMakeLists.txt index ce03da9c..a42960f9 100644 --- a/pyiec61850/CMakeLists.txt +++ b/pyiec61850/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.12) -set(CMAKE_POLICY_DEFAULT_CMP0078 NEW) +cmake_policy(SET CMP0078 NEW) + +if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0") + cmake_policy(SET CMP0086 NEW) +endif() find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) @@ -12,6 +16,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_SWIG_FLAGS "") set_property(SOURCE iec61850.i PROPERTY CPLUSPLUS ON) +set_property(SOURCE iec61850.i PROPERTY SWIG_MODULE_NAME pyiec61850) if(WIN32) set(LIBS iec61850 ws2_32) @@ -29,7 +34,7 @@ swig_link_libraries(pyiec61850 ${LIBS}) # Finding python modules install path execute_process( COMMAND ${Python_EXECUTABLE} -c - "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib())" + "from sysconfig import get_path; import sys; sys.stdout.write(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_SITE_DIR )