0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-19 19:52:15 +02:00

client: Switch to UseSWIG instead of manual custom command

On modern CMake this gets us swig dependency management,
which should reduce problems for incremental builds.
Also it is just cleaner.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
This commit is contained in:
Frank Lichtenheld 2023-10-13 13:31:13 +02:00 committed by David Sommerseth
parent cb06f9e330
commit 72275db1d5
No known key found for this signature in database
GPG Key ID: 86CF944C9671FDF2
3 changed files with 20 additions and 17 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0048 NEW)
project(OpenVPN3-core VERSION 3)

View File

@ -1,19 +1,21 @@
include(findcoredeps)
include(findswigdeps)
if (${BUILD_SWIG_LIB})
add_custom_command(
OUTPUT ovpncli_wrap.cxx ovpncli_wrap.h
COMMENT "Generating ovpncli Python swig files"
COMMAND ${SWIG_EXECUTABLE} -c++ -python -threads -DSWIG_PYTHON_2_UNICODE -outcurrentdir -I${CORE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ovpncli.i
DEPENDS ovpncli.i
)
if (BUILD_SWIG_LIB)
set_property(SOURCE ovpncli.i PROPERTY CPLUSPLUS ON)
if (NOT MSVC)
# Swig generates code with deprecated python declarations
set_property(SOURCE ovpncli.i PROPERTY GENERATED_COMPILE_OPTIONS -Wno-deprecated-declarations -Wno-sometimes-uninitialized -Wno-class-memaccess -Wno-unknown-warning-option)
endif()
add_library(ovpnclilib SHARED
ovpncli.cpp
ovpncli_wrap.cxx
ovpncli_wrap.h
)
swig_add_library(ovpnclilib
TYPE SHARED
LANGUAGE python
SOURCES ovpncli.cpp ovpncli.i
)
set_property(TARGET ovpnclilib PROPERTY SWIG_COMPILE_DEFINITIONS SWIG_PYTHON_2_UNICODE)
set_property(TARGET ovpnclilib PROPERTY SWIG_COMPILE_OPTIONS -threads)
set_property(TARGET ovpnclilib PROPERTY SWIG_INCLUDE_DIRECTORIES ${CORE_DIR})
add_core_dependencies(ovpnclilib)
target_link_libraries(ovpnclilib ${Python3_LIBRARIES})
@ -23,8 +25,4 @@ if (${BUILD_SWIG_LIB})
set_target_properties(ovpnclilib PROPERTIES OUTPUT_NAME "_ovpncli")
set_target_properties(ovpnclilib PROPERTIES PREFIX "")
if (NOT WIN32)
# Swig generates code with deprecated python declarations
set_source_files_properties(ovpncli_wrap.cxx PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations -Wno-sometimes-uninitialized -Wno-class-memaccess -Wno-unknown-warning-option")
endif()
endif ()

View File

@ -2,6 +2,11 @@ find_package(Python3 COMPONENTS Interpreter Development)
FIND_PACKAGE(SWIG 3.0)
include(UseSWIG)
if (CMAKE_VERSION VERSION_GREATER "3.20")
set(SWIG_USE_SWIG_DEPENDENCIES TRUE)
endif()
# We test building this library with python instead of java since that is easier to do and both languages should work
if (Python3_Development_FOUND AND SWIG_FOUND)