netgen/python/CMakeLists.txt
Monty Montgomery b82796e58d CMake enhancements for automated external package building
Add explicit defaults where missing for clarity.

Support passing in NETGEN_GIT_VERSION for use when building, eg, RPM
packages using rpkg, which requires building from an untagged source
bundle, that is, not directly from a git checkout.

Add option to choose build against internal or external Pybind11; add
cmake module to find and configure against system Pybind.

re-add versioning of shared library files.

Add section for GCC-specific options setting (right now, to turn off
harmless warnings).

Warn if pybind11_stubgen is not found.

Adjust stubgen paths to work when build is not in-place in the source tree.
2022-05-15 01:16:51 -04:00

41 lines
1.8 KiB
CMake

get_target_property(ngcore_compile_definitions ngcore INTERFACE_COMPILE_DEFINITIONS)
get_property(have_options TARGET ngcore PROPERTY INTERFACE_COMPILE_OPTIONS SET)
if(have_options)
get_target_property(ngcore_compile_options ngcore INTERFACE_COMPILE_OPTIONS)
endif(have_options)
configure_file(config_template.py ${CMAKE_CURRENT_BINARY_DIR}/config.py @ONLY)
configure_file(version_template.py ${CMAKE_CURRENT_BINARY_DIR}/version.py @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/config.py
${CMAKE_CURRENT_BINARY_DIR}/version.py
__main__.py __init__.py
meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py occ.py
read_gmsh.py read_meshio.py
webgui.py
DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen
COMPONENT netgen
)
install(FILES
pyngcore/__init__.py
DESTINATION ${NG_INSTALL_DIR_PYTHON}/pyngcore
COMPONENT netgen
)
# build stub files for pybind11 packages
if(BUILD_STUB_FILES)
message(STATUS "Building Python stub files...")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pybind11_stubgen; print(pybind11_stubgen.__file__)" OUTPUT_VARIABLE stubgen_path RESULT_VARIABLE pybind11_stubgen)
if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0)
message(WARNING "pybind11-stubgen not found. If you want to create stub files for better autocompletion support,
install pybind11-stubgen with pip.")
else()
message("-- Found pybind11-stubgen: ${stubgen_path}")
set(env{PYTHONPATH} ".:${CMAKE_INSTALL_PREFIX}/${PYTHON_PACKAGES_INSTALL_DIR}")
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11_stubgen -o ${CMAKE_BINARY_DIR}/stubs --no-setup-py netgen)")
install(DIRECTORY ${CMAKE_BINARY_DIR}/stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen COMPONENT netgen)
endif()
endif(BUILD_STUB_FILES)