Skip to content

Commit

Permalink
cmake: adjust for multi-config generators
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Oct 3, 2024
1 parent 11610d2 commit 3d3eecb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,9 @@ if (USE_PYTHON)
target_link_libraries(gemmi_py PRIVATE gemmi_cpp)
endif()
set_property(TARGET gemmi_py PROPERTY OUTPUT_NAME gemmi_ext)
set_property(TARGET gemmi_py PROPERTY LIBRARY_OUTPUT_DIRECTORY py/gemmi)
configure_file(python/gemmi/__init__.py py/gemmi/__init__.py COPYONLY)
set(py_dir $<IF:$<STREQUAL:$<CONFIG>,>,py,$<CONFIG>/py>)
set_property(TARGET gemmi_py PROPERTY LIBRARY_OUTPUT_DIRECTORY ${py_dir}/gemmi)
file(GENERATE OUTPUT ${py_dir}/gemmi/__init__.py INPUT python/gemmi/__init__.py)

# nanobind gives warnings with -Wpedantic and -Wshadow
if(CMAKE_CXX_FLAGS MATCHES "-Wshadow")
Expand Down Expand Up @@ -528,17 +529,17 @@ if (USE_PYTHON)
nanobind_add_stub(
gemmi_stub
MODULE gemmi
OUTPUT py/gemmi/__init__.pyi
PYTHON_PATH py
OUTPUT ${py_dir}/gemmi/__init__.pyi
PYTHON_PATH ${py_dir}
DEPENDS gemmi_py
PATTERN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/python/stubs.pat"
MARKER_FILE py/gemmi/py.typed
MARKER_FILE ${py_dir}/gemmi/py.typed
)
nanobind_add_stub(
gemmi_cif_stub
MODULE gemmi.cif
OUTPUT py/gemmi/cif.pyi
PYTHON_PATH py
OUTPUT ${py_dir}/gemmi/cif.pyi
PYTHON_PATH ${py_dir}
DEPENDS gemmi_py
)
endif()
Expand Down Expand Up @@ -603,10 +604,10 @@ if (USE_PYTHON)
PATTERN "[._]*" EXCLUDE)
if (GENERATE_STUBS AND NOT CMAKE_CROSSCOMPILING)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/py/gemmi/__init__.py"
"${CMAKE_CURRENT_BINARY_DIR}/py/gemmi/py.typed"
"${CMAKE_CURRENT_BINARY_DIR}/py/gemmi/__init__.pyi"
"${CMAKE_CURRENT_BINARY_DIR}/py/gemmi/cif.pyi"
"${CMAKE_CURRENT_BINARY_DIR}/${py_dir}/gemmi/__init__.py"
"${CMAKE_CURRENT_BINARY_DIR}/${py_dir}/gemmi/py.typed"
"${CMAKE_CURRENT_BINARY_DIR}/${py_dir}/gemmi/__init__.pyi"
"${CMAKE_CURRENT_BINARY_DIR}/${py_dir}/gemmi/cif.pyi"
DESTINATION "${Python_SITEARCH}/gemmi" COMPONENT py)
endif()
endif()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers = [

[tool.scikit-build]
#build-dir = "/tmp/gemmi_build2/{wheel_tag}"
experimental = true # needed for install-dir
experimental = true # needed for install-dir starting with '/'
wheel.install-dir = "/data"
wheel.expand-macos-universal-tags = true # not sure if this is useful
wheel.packages = []
Expand Down
1 change: 1 addition & 0 deletions python/gemmi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Importing C++ extension populates this module.
from . import gemmi_ext
del gemmi_ext

0 comments on commit 3d3eecb

Please sign in to comment.