mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
if (NOT PYTHONINTERP_FOUND)
|
|
find_package (PythonInterp REQUIRED)
|
|
endif ()
|
|
function(add_python_package target package_path source_files install_package)
|
|
|
|
set(build_files "")
|
|
|
|
foreach (file ${source_files} )
|
|
set( source_file ${CMAKE_CURRENT_SOURCE_DIR}/${file} )
|
|
set( build_file ${PROJECT_BINARY_DIR}/${package_path}/${file} )
|
|
set( install_file ${CMAKE_INSTALL_PREFIX}/${package_path}/${file} )
|
|
|
|
add_custom_command(
|
|
OUTPUT ${build_file}
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
ARGS ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc2 ${source_file} ${build_file}
|
|
DEPENDS ${source_file} )
|
|
|
|
list(APPEND build_files ${build_file} )
|
|
|
|
if (install_package)
|
|
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${package_path})
|
|
install(CODE "execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc_file ${install_file})")
|
|
endif()
|
|
|
|
endforeach()
|
|
add_custom_target( ${target} ALL DEPENDS ${build_files})
|
|
|
|
endfunction() |