From: Matthew Fernandez Date: Sat, 16 Oct 2021 21:19:41 +0000 (-0700) Subject: CMake: only pass 'YY_NO_UNISTD_H' to Flex when unistd.h is not found X-Git-Tag: 2.49.3~7^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5358ba56ed67f689d9e110370033e17455269c13;p=graphviz CMake: only pass 'YY_NO_UNISTD_H' to Flex when unistd.h is not found 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. --- diff --git a/lib/cgraph/CMakeLists.txt b/lib/cgraph/CMakeLists.txt index 212c62f05..83b49e3e9 100644 --- a/lib/cgraph/CMakeLists.txt +++ b/lib/cgraph/CMakeLists.txt @@ -2,7 +2,10 @@ BISON_TARGET(Grammar ${CMAKE_CURRENT_SOURCE_DIR}/grammar.y ${CMAKE_CURRENT_BINAR 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