Add building ovpncli swig library to cmake build

This also moves ovpncli.i to a proper place
This commit is contained in:
Arne Schwabe
2021-12-15 13:01:42 +01:00
parent d7b316bd11
commit 9ad98bae8f
3 changed files with 38 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
cmake_minimum_required(VERSION 3.5)
add_subdirectory(client)
add_subdirectory(test/unittests)
add_subdirectory(test/ovpncli)
add_subdirectory(test/ssl)

37
client/CMakeLists.txt Normal file
View File

@@ -0,0 +1,37 @@
include(findcoredeps)
find_package(PythonInterp)
find_package(PythonLibs)
FIND_PACKAGE(SWIG 3.0)
# We test building this library with python instead of java since that is easier to do and both languages should work
if (${PYTHONLIBS_FOUND} AND ${SWIG_FOUND})
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
)
add_library(ovpnclilib SHARED
ovpncli.cpp
ovpncli_wrap.cxx
ovpncli_wrap.h
)
add_core_dependencies(ovpnclilib)
target_link_libraries(ovpnclilib ${PYTHON_LIBRARIES})
target_include_directories(ovpnclilib PRIVATE ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
# Use proper python library name to generate _ovpncli.so/dylib/dll
set_target_properties(ovpnclilib PROPERTIES OUTPUT_NAME "_ovpncli")
set_target_properties(ovpnclilib PROPERTIES PREFIX "")
# Swig generates code with deprecated python declarations
set_source_files_properties(ovpncli_wrap.cxx PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations -Wno-sometimes-uninitialized")
else ()
MESSAGE(INFO "Python libraries or swig not found, skipping ovpncli swig build")
endif ()