Skip to content

Commit 9b6230b

Browse files
committed
cmake: change copying __init__.py to custom command
this ensures that it's always copied when the extension is built
1 parent 0134d45 commit 9b6230b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,17 @@ if (USE_PYTHON)
494494
endif()
495495
set_property(TARGET gemmi_py PROPERTY OUTPUT_NAME gemmi_ext)
496496
if (CMAKE_CONFIGURATION_TYPES)
497-
set(py_dir $<CONFIG>/py>)
497+
set(py_dir $<CONFIG>/py)
498498
else()
499499
set(py_dir py)
500500
endif()
501501
set_property(TARGET gemmi_py PROPERTY LIBRARY_OUTPUT_DIRECTORY ${py_dir}/gemmi)
502-
file(GENERATE OUTPUT ${py_dir}/gemmi/__init__.py INPUT python/gemmi/__init__.py)
502+
add_custom_command(TARGET gemmi_py PRE_BUILD
503+
COMMENT "Copying gemmi/__init__.py"
504+
COMMAND ${CMAKE_COMMAND} -E copy
505+
"${CMAKE_CURRENT_SOURCE_DIR}/python/gemmi/__init__.py"
506+
${py_dir}/gemmi/__init__.py
507+
BYPRODUCTS ${py_dir}/gemmi/__init__.py)
503508
504509
# nanobind gives warnings with -Wpedantic and -Wshadow
505510
if(CMAKE_CXX_FLAGS MATCHES "-Wshadow")

0 commit comments

Comments
 (0)