Skip to content
Snippets Groups Projects
Commit 67369d95 authored by AlQuemist's avatar AlQuemist Committed by Wuttke, Joachim
Browse files

SwigLib: move compile-flag setting and Windows post-build and installation commands to MakeLib

parent 5a766087
No related branches found
No related tags found
1 merge request!1636PyCore: Re-implementation of embedded Python as a separate module (Major change)
# Configure Python bindings for one component library.
# Called from function MakeLib.
function(SwigLib name lib tmpdir)
function(SwigLib name lib swigtmpdir)
if(NOT BORNAGAIN_PYTHON)
message(FATAL_ERROR "Function SwigLib called though BORNAGAIN_PYTHON=false")
endif()
message(STATUS "SwigLib ${name}: ${lib} ${tmpdir}")
message(STATUS "SwigLib ${name}: ${lib} ${swigtmpdir}")
if(CONFIGURE_BINDINGS)
file(MAKE_DIRECTORY ${tmpdir})
file(MAKE_DIRECTORY ${swigtmpdir})
# static (manually written) input files
set(swig_dependencies
......@@ -30,19 +30,19 @@ function(SwigLib name lib tmpdir)
# Please keep -Werror, in order not to overlook critical warnings.
# Dispensable warnings are disabled in Wrap/Swig/warnings.i.
# Joachim, oct20.
set(SWIG_FLAGS "-c++;-python;-Werror;-o;${AUTO_DIR}/lib${lib}_wrap.cpp;-outdir;${tmpdir}"
set(SWIG_FLAGS "-c++;-python;-Werror;-o;${AUTO_DIR}/lib${lib}_wrap.cpp;-outdir;${swigtmpdir}"
";-I${LibHeinz_INCLUDE_DIR}"
";-I${CMAKE_SOURCE_DIR};-I${CMAKE_BINARY_DIR}/inc")
add_custom_command(
OUTPUT ${AUTO_DIR}/lib${lib}.py
COMMAND ${Python3_EXECUTABLE} ${SWIG_DIR}/tweaks.py
${tmpdir}/lib${lib}.py
${swigtmpdir}/lib${lib}.py
${AUTO_DIR}/lib${lib}.py
DEPENDS ${tmpdir}/lib${lib}.py
DEPENDS ${swigtmpdir}/lib${lib}.py
)
add_custom_command(
OUTPUT ${tmpdir}/lib${lib}.py
OUTPUT ${swigtmpdir}/lib${lib}.py
${AUTO_DIR}/lib${lib}_wrap.h
${AUTO_DIR}/lib${lib}_wrap.cpp
COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${SWIG_DIR}/lib${lib}.i
......@@ -68,26 +68,10 @@ function(SwigLib name lib tmpdir)
add_dependencies(${lib} ${lib}_python)
target_compile_definitions(${lib} PUBLIC -DBORNAGAIN_PYTHON)
target_include_directories(${lib} PRIVATE ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
target_link_libraries(${lib} PRIVATE ${Python3_LIBRARIES})
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${lib}.py
DESTINATION ${destination_python} COMPONENT Libraries) # required by swig
if(WIN32)
# python in windows required .pyd extension for the library name
if(BORNAGAIN_PYTHON)
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${lib}.pyd
DESTINATION ${destination_python} COMPONENT Libraries)
add_custom_command(
TARGET ${lib}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/bin/${libprefix}${lib}${libsuffix}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${libprefix}${lib}${libsuffix}
)
endif()
endif()
endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment