Skip to content
Snippets Groups Projects
Commit 11ed456f authored by AlQuemist's avatar AlQuemist
Browse files

rm unneeded `SwigLib.cmake`

The SWIG-produced API is made using `BornAgain/multipython/MakeSwigLib.cmake`.
parent 42e609d6
No related branches found
No related tags found
2 merge requests!601Remove unneeded CMake modules (Minor cleanup),!600Remove unneeded CMake modules (Minor cleanup)
......@@ -103,7 +103,6 @@ endif()
# function definitions
include(commons/GetFilenameComponent) # fct get_filename_component (overwrites CMake's built-in)
include(BornAgain/SwigLib) # fct SwigLib
# main settings
......
# Configure Python bindings for one component library.
# Called from function MakeLib.
function(SwigLib name lib tmpdir)
if(NOT BORNAGAIN_PYTHON)
message(FATAL_ERROR "Function SwigLib called though BORNAGAIN_PYTHON=false")
endif()
message(STATUS "SwigLib ${name}: ${lib} ${tmpdir}")
if(CONFIGURE_BINDINGS)
file(MAKE_DIRECTORY ${tmpdir})
# static (manually written) input files
set(swig_dependencies
${SWIG_DIR}/lib${lib}.i
${SWIG_DIR}/deprecation.i
${SWIG_DIR}/warnings.i
${SWIG_DIR}/ignoreBase.i
${SWIG_DIR}/ignoreSample.i
)
foreach(FNAM ${swig_dependencies})
if(NOT EXISTS ${FNAM})
message(FATAL_ERROR "Could NOT find SWIG input ${FNAM}")
endif()
endforeach()
# dynamic (autogenerated) input files
GeneratePythonDocs(${AUTO_DIR}/doxygen${name}.i ${SWIG_DIR} ${tmpdir})
list(APPEND swig_dependencies ${AUTO_DIR}/doxygen${name}.i)
# Run Swig.
# 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}"
";-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
${AUTO_DIR}/lib${lib}.py
DEPENDS ${tmpdir}/lib${lib}.py
)
add_custom_command(
OUTPUT ${tmpdir}/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
DEPENDS ${swig_dependencies} ${include_files}
)
endif(CONFIGURE_BINDINGS)
add_custom_target(
${lib}_python
COMMAND ${CMAKE_COMMAND}
-E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/lib${lib}.py
COMMAND ${CMAKE_COMMAND}
-E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/bornagain/lib${lib}.py
DEPENDS ${AUTO_DIR}/lib${lib}.py
)
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_BINARY_DIR}/lib/lib${lib}.py
DESTINATION ${destination_lib} COMPONENT Libraries) # required by swig
if(WIN32)
# python in windows required .pyd extension for the library name
if(BORNAGAIN_PYTHON)
add_custom_command(
TARGET ${lib}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/bin/${libprefix}${lib}${libsuffix}
${CMAKE_BINARY_DIR}/lib/${libprefix}${lib}".pyd"
)
install(FILES ${CMAKE_BINARY_DIR}/lib/${libprefix}${lib}.pyd
DESTINATION ${destination_lib} COMPONENT Libraries)
add_custom_command(
TARGET ${lib}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/bin/${libprefix}${lib}${libsuffix}
${CMAKE_BINARY_DIR}/lib/${libprefix}${lib}${libsuffix}
)
endif()
endif()
endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment