File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,8 +35,20 @@ FetchContent_MakeAvailable(fpcap)
3535pybind11_add_module (_fpcap src/bindings.cpp )
3636target_link_libraries (_fpcap PRIVATE fpcap::fpcap )
3737
38- # Disable MSVC C++20 module scanning (we don't use C++ modules and the scanner
39- # fails on Windows because it lacks platform architecture defines)
40- set_target_properties (_fpcap PROPERTIES CXX_SCAN_FOR_MODULES OFF )
38+ if (MSVC )
39+ # Disable MSVC C++20 module scanning (we don't use C++ modules and the scanner
40+ # fails on Windows because it lacks platform architecture defines)
41+ set_target_properties (_fpcap PROPERTIES CXX_SCAN_FOR_MODULES OFF )
42+
43+ # Fix "No Target Architecture" error: Python.h pulls in winnt.h which needs
44+ # _AMD64_/_X86_/_ARM64_ defined. MSVC defines _M_AMD64 intrinsically, but the
45+ # macro-to-define chain in winnt.h can fail with certain header include orders
46+ # (Python.h + C++20 + recent Windows SDK). Define the architecture explicitly.
47+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
48+ target_compile_definitions (_fpcap PRIVATE _AMD64_ )
49+ elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
50+ target_compile_definitions (_fpcap PRIVATE _X86_ )
51+ endif ()
52+ endif ()
4153
4254install (TARGETS _fpcap LIBRARY DESTINATION .)
You can’t perform that action at this time.
0 commit comments