添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
知识渊博的橡皮擦  ·  Build systems - ...·  32 分钟前    · 
刚毅的长颈鹿  ·  Windows10 ...·  32 分钟前    · 
谦和的跑步鞋  ·  pybind11 documentation·  32 分钟前    · 
聪明的冰棍  ·  pybind11 + Mingw-w64 ...·  32 分钟前    · 
打酱油的莴苣  ·  Unable to import ...·  4 小时前    · 
另类的杨桃  ·  汽车也有免疫系统? ...·  2 月前    · 
酒量小的领带  ·  JavaScript ...·  3 月前    · 
逆袭的凉面  ·  致高考考生之 诚信考试·  4 月前    · 

When testing CMake 3.27.1 on windows, our project (C++ static library + pybind11 wrapper and python wheel generation) fails to configure.

the ZERO_CHECK seems to generate a cyclic dependency, which was not the case up to CMake 3.26.4...

$ cd .../bazel-pybind11
$ cmake -S. -Bbuild
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "ZERO_CHECK" of type UTILITY
    depends on "foo" (strong)
    depends on "foo_pybind11" (strong)
  "foo" of type STATIC_LIBRARY
    depends on "ZERO_CHECK" (strong)
  "foo_pybind11" of type MODULE_LIBRARY
    depends on "ZERO_CHECK" (strong)
    depends on "foo" (weak)
    depends on "ZERO_CHECK" (strong)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed.  Build files cannot be regenerated correctly.

So we have the graph:

flowchart BT
Z["ZERO_CHECK<br>Type: UTILITY"]
F["foo.lib<br>Type: STATIC_LIBRARY"]
FP["foo_pybind11.pyd<br>Type: MODULE_LIBRARY"]
SI["setup.py.in"]
SO["setup.py"]
W["Python wheel package"]
Z --> F & FP
F --> Z
FP --> F & Z
SI --> F & FP
SO -->|"configure_file + file(GENERATE)"| SI
W --> SO & F & FP

note: if removing the setup.py.in configure_file() the problem gone -> it seems it is this generation of the file which make the python package dependent of ZERO_CHECK which make the circular dependency.

# setup.py.in contains cmake variable e.g. @PYTHON_PROJECT@ and
# generator expression e.g. $<TARGET_FILE_NAME:foo_pybind11>
#configure_file(
#  ${PROJECT_SOURCE_DIR}/python/setup.py.in
#  ${PROJECT_BINARY_DIR}/python/setup.py.in
#  @ONLY)
file(GENERATE
  OUTPUT ${PROJECT_BINARY_DIR}/python/setup.py
  CONTENT "")
  #INPUT ${PROJECT_BINARY_DIR}/python/setup.py.in)
add_custom_command(
  OUTPUT python/dist/timestamp

https://github.com/mizux/bazel-pybind11

Edited by Mizux