mirror of
https://github.com/triqs/dft_tools
synced 2024-11-01 11:43:47 +01:00
243d4a798b
- a module can use the converters used by another with the use_module('A') command. In which case : - the generate converter header for A will be included. - the header, at the top, now contains a simple list of all wrapped types, which is then included in the wrapped_types of the module for proper code generation. - simplify the code generation : just generate_code. - all arguments are analyzed from sys.argv at the import of the wrap_generator module. In any case, the xx_desc.py will be called from the corresponding cmake command, hence with the right arguments. - Added a dependencies in my_module_B of wrap_test to show how to make the dependencies in the cmake file, if needed.
45 lines
2.1 KiB
CMake
45 lines
2.1 KiB
CMake
# Compile and link with python
|
|
include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_NUMPY_INCLUDE_DIR})
|
|
|
|
# This function add the target to build a python module
|
|
#
|
|
# ModuleName = the python name of the module
|
|
# ModuleDest = path in the pytriqs tree [ FOR INSTALLATION ONLY] IMPROVE MAKE THIS OPTIONAL (for test)
|
|
|
|
EXECUTE_PROCESS(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/include/pytriqs/converters/)
|
|
include_directories( ${CMAKE_BINARY_DIR})
|
|
|
|
macro (triqs_python_extension ModuleName)
|
|
message(STATUS "Preparing extension module ${ModuleName}")
|
|
|
|
SET(wrap_name ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}_wrap.cpp)
|
|
SET(converter_name ${CMAKE_BINARY_DIR}/include/pytriqs/converters/${ModuleName}.hpp)
|
|
|
|
# Adjust pythonpath so that pytriqs is visible and the wrap_generator too...
|
|
# pytriqs needed since we import modules with pure python method to extract the doc..
|
|
add_custom_command(OUTPUT ${wrap_name} ${converter_name} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ModuleName}_desc.py
|
|
COMMAND PYTHONPATH=${CMAKE_BINARY_DIR}/pytriqs/wrap_generator:${CMAKE_BINARY_DIR}/ ${PYTHON_INTERPRETER} ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}_desc.py
|
|
${CMAKE_SOURCE_DIR}/pytriqs/wrap_generator/wrapper.mako.cpp
|
|
${wrap_name}
|
|
${CMAKE_SOURCE_DIR}/pytriqs/wrap_generator/py_converter_wrapper.mako.hpp
|
|
${converter_name}
|
|
${CMAKE_BINARY_DIR}/include/pytriqs/converters/
|
|
)
|
|
|
|
set_property (GLOBAL APPEND PROPERTY TRIQS_PY_CONVERTERS_TARGETS "python_wrap_${ModuleName}")
|
|
|
|
add_custom_target(python_wrap_${ModuleName} ALL DEPENDS ${wrap_name} ${converter_name})
|
|
add_dependencies(python_wrap_${ModuleName} py_copy ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}_desc.py )
|
|
|
|
add_library(${ModuleName} MODULE ${wrap_name})
|
|
set_target_properties(${ModuleName} PROPERTIES PREFIX "") #eliminate the lib in front of the module name
|
|
target_link_libraries(${ModuleName} ${TRIQS_LINK_LIBS} triqs)
|
|
|
|
if (${ARGN} MATCHES "")
|
|
install (FILES ${converter_name} DESTINATION "include/pytriqs/converters")
|
|
install (TARGETS ${ModuleName} DESTINATION ${TRIQS_PYTHON_LIB_DEST}/${ARGN} )
|
|
endif (${ARGN} MATCHES "")
|
|
|
|
endmacro (triqs_python_extension)
|
|
|