This macro tells Flex that #including unistd.h should be avoided. There is no
need for this on almost any platform except Windows, hence why `YY_NO_UNISTD_H`
is only mentioned elsewhere in the MS Build build system, not in the Autotools
build system. In the CMake build system which is meant to be used across Windows
and non-Windows platforms, we can do something more nuanced and depend on the
existence check of unistd.h itself.
FLEX_TARGET(Scan ${CMAKE_CURRENT_SOURCE_DIR}/scan.l ${CMAKE_CURRENT_BINARY_DIR}/scan.c)
ADD_FLEX_BISON_DEPENDENCY(Scan Grammar)
-add_definitions(-DEXPORT_CGRAPH -DEXPORT_AGXBUF -DEXPORT_CGHDR -DYY_NO_UNISTD_H)
+add_definitions(-DEXPORT_CGRAPH -DEXPORT_AGXBUF -DEXPORT_CGHDR)
+if(NOT HAVE_UNISTD_H)
+ add_definitions(-DYY_NO_UNISTD_H)
+endif()
add_library(cgraph SHARED
# Header files