Skip to content
Snippets Groups Projects
Commit 8f0ff05b authored by Ammar Nejati's avatar Ammar Nejati
Browse files

[a.fixPythonWrappers] Minor fix to CMake scripts which produce the Python wrappers

Merging branch 'a.fixPythonWrappers'  into 'main'.

Related to issue #223

See merge request !2295
parents a5428635 3293aa8a
No related branches found
No related tags found
1 merge request!2295Minor fix to CMake scripts which produce the Python wrappers
Pipeline #126967 passed
...@@ -145,7 +145,8 @@ function(add_library_to_wheel lib) ...@@ -145,7 +145,8 @@ function(add_library_to_wheel lib)
if(lib_LIBRARY_PY) if(lib_LIBRARY_PY)
add_custom_command(TARGET ${lib} add_custom_command(TARGET ${lib}
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_PROPERTY:${lib},_LIBRARY_PY>" ${_dst} COMMAND ${CMAKE_COMMAND} -E copy "${lib_LIBRARY_PY}" ${_dst}
DEPENDS lib${lib}_py_wrappers
COMMENT "Add Python wrapper-script of library ${lib} to the Python wheel..." COMMENT "Add Python wrapper-script of library ${lib} to the Python wheel..."
) )
endif() endif()
......
...@@ -55,24 +55,32 @@ function(SwigLib name lib swigtmpdir) ...@@ -55,24 +55,32 @@ function(SwigLib name lib swigtmpdir)
";-I${LibHeinz_INCLUDE_DIR}" ";-I${LibHeinz_INCLUDE_DIR}"
";-I${CMAKE_SOURCE_DIR};-I${CMAKE_BINARY_DIR}/inc") ";-I${CMAKE_SOURCE_DIR};-I${CMAKE_BINARY_DIR}/inc")
add_custom_command( add_custom_target(lib${lib}_py_wrappers ALL
OUTPUT ${AUTO_WRAP_DIR}/lib${lib}.py BYPRODUCTS ${swigtmpdir}/lib${lib}.py
COMMAND ${Python3_EXECUTABLE} ${SWIG_DIR}/tweaks.py
${swigtmpdir}/lib${lib}.py
${AUTO_WRAP_DIR}/lib${lib}.py
DEPENDS ${swigtmpdir}/lib${lib}.py
)
add_custom_command(
OUTPUT ${swigtmpdir}/lib${lib}.py
${AUTO_WRAP_DIR}/lib${lib}_wrap.h ${AUTO_WRAP_DIR}/lib${lib}_wrap.h
${AUTO_WRAP_DIR}/lib${lib}_wrap.cpp ${AUTO_WRAP_DIR}/lib${lib}_wrap.cpp
${AUTO_WRAP_DIR}/lib${lib}.py
# produce the Python wrapper
COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${SWIG_DIR}/lib${lib}.i COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${SWIG_DIR}/lib${lib}.i
# amend the Python wrapper
COMMAND ${Python3_EXECUTABLE} ${SWIG_DIR}/tweaks.py
${swigtmpdir}/lib${lib}.py
${AUTO_WRAP_DIR}/lib${lib}.py
DEPENDS ${swig_dependencies} ${include_files} DEPENDS ${swig_dependencies} ${include_files}
COMMENT "SWIG: build Python wrapper ${AUTO_WRAP_DIR}/lib${lib}.py"
) )
string(REPLACE ";" " " SWIG_FLAGS_STR "${SWIG_FLAGS}") string(REPLACE ";" " " SWIG_FLAGS_STR "${SWIG_FLAGS}")
set(SWIG_FLAGS_STR "${SWIG_FLAGS_STR}" CACHE INTERNAL "") set(SWIG_FLAGS_STR "${SWIG_FLAGS_STR}" CACHE INTERNAL "")
set(SWIG_DIR "${SWIG_DIR}" CACHE INTERNAL "") set(SWIG_DIR "${SWIG_DIR}" CACHE INTERNAL "")
else()
# assumes that lib${lib}_wrap.h, lib${lib}_wrap.cpp and lib${lib}.py
# are already present in ${AUTO_WRAP_DIR}
add_custom_target(lib${lib}_py_wrappers ALL
DEPENDS ${AUTO_WRAP_DIR}/lib${lib}_wrap.h
${AUTO_WRAP_DIR}/lib${lib}_wrap.cpp
${AUTO_WRAP_DIR}/lib${lib}.py
)
endif() endif()
# include Python and Numpy headers and link to Python shared library # include Python and Numpy headers and link to Python shared library
......
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