Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在像这样在 Linux 上检查 accept4:
check_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
但是,仅当预先定义了 _GNU_SOURCE 时才定义 accept4。如何强制检查器在检查之前定义 _GNU_SOURCE?
当然,list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)在调用之前使用check_symbol_exists()并list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)在检查之后进行清理。
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists()
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)