2014-05-22 17:56:42 +02:00
|
|
|
# Compile and link with python
|
2014-05-08 22:15:15 +02:00
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_NUMPY_INCLUDE_DIR})
|
|
|
|
|
|
|
|
# This function add the target to build a python module
|
|
|
|
#
|
2014-05-22 17:56:42 +02:00
|
|
|
# ModuleName = the python name of the module
|
|
|
|
# ModuleDest = path in the pytriqs tree [ FOR INSTALLATION ONLY] IMPROVE MAKE THIS OPTIONAL (for test)
|
2014-05-08 22:15:15 +02:00
|
|
|
|
2014-05-20 17:45:16 +02:00
|
|
|
EXECUTE_PROCESS(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/include/pytriqs/converters/)
|
2014-05-22 17:56:42 +02:00
|
|
|
include_directories( ${CMAKE_BINARY_DIR})
|
2014-05-16 19:35:48 +02:00
|
|
|
|
2014-05-08 22:15:15 +02:00
|
|
|
macro (triqs_python_extension ModuleName)
|
2014-05-16 19:35:48 +02:00
|
|
|
message(STATUS "Preparing extension module ${ModuleName}")
|
2014-05-08 22:15:15 +02:00
|
|
|
|
|
|
|
SET(wrap_name ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}_wrap.cpp)
|
2014-05-20 17:45:16 +02:00
|
|
|
SET(converter_name ${CMAKE_BINARY_DIR}/include/pytriqs/converters/${ModuleName}.hpp)
|
2014-05-08 22:15:15 +02:00
|
|
|
|
|
|
|
# Adjust pythonpath so that pytriqs is visible and the wrap_generator too...
|
2014-05-22 17:56:42 +02:00
|
|
|
# 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} )
|
2014-05-16 19:35:48 +02:00
|
|
|
|
|
|
|
set_property (GLOBAL APPEND PROPERTY TRIQS_PY_CONVERTERS_TARGETS "python_wrap_${ModuleName}")
|
2014-05-08 22:15:15 +02:00
|
|
|
|
2014-05-22 17:56:42 +02:00
|
|
|
add_custom_target(python_wrap_${ModuleName} ALL DEPENDS ${wrap_name} ${converter_name})
|
2014-05-16 19:35:48 +02:00
|
|
|
add_dependencies(python_wrap_${ModuleName} py_copy ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}_desc.py )
|
2014-05-08 22:15:15 +02:00
|
|
|
|
|
|
|
add_library(${ModuleName} MODULE ${wrap_name})
|
2014-05-22 17:56:42 +02:00
|
|
|
set_target_properties(${ModuleName} PROPERTIES PREFIX "") #eliminate the lib in front of the module name
|
2014-05-08 22:15:15 +02:00
|
|
|
target_link_libraries(${ModuleName} ${TRIQS_LINK_LIBS} triqs)
|
2014-05-22 17:56:42 +02:00
|
|
|
|
2014-05-08 22:15:15 +02:00
|
|
|
if (${ARGN} MATCHES "")
|
2014-05-20 17:45:16 +02:00
|
|
|
install (FILES ${converter_name} DESTINATION "include/pytriqs/converters")
|
2014-05-08 22:15:15 +02:00
|
|
|
install (TARGETS ${ModuleName} DESTINATION ${TRIQS_PYTHON_LIB_DEST}/${ARGN} )
|
|
|
|
endif (${ARGN} MATCHES "")
|
|
|
|
|
|
|
|
endmacro (triqs_python_extension)
|
|
|
|
|