I am checking for accept4 on Linux like this:
check_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
However, accept4 is only defined if _GNU_SOURCE is defined beforehand. How can I force the checker to defined _GNU_SOURCE before the check?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure, use
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)before callingcheck_symbol_exists()andlist(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)to cleanup after the check.