From: Magnus Jacobsson Date: Sat, 21 Nov 2020 16:17:52 +0000 (+0100) Subject: Add build of lib/expr using CMake X-Git-Tag: 2.47.0~73^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2592dff5848302c3250466e286e683afeede3f9e;p=graphviz Add build of lib/expr using CMake Towards https://gitlab.com/graphviz/graphviz/-/issues/1878. --- diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e36724a7c..34df31533 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(cdt) add_subdirectory(circogen) add_subdirectory(common) add_subdirectory(dotgen) +add_subdirectory(expr) add_subdirectory(fdpgen) add_subdirectory(ingraphs) add_subdirectory(label) diff --git a/lib/expr/CMakeLists.txt b/lib/expr/CMakeLists.txt new file mode 100644 index 000000000..727271610 --- /dev/null +++ b/lib/expr/CMakeLists.txt @@ -0,0 +1,70 @@ +BISON_TARGET( + Exparse + exparse.y + ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c + COMPILE_FLAGS "--yacc -Wno-yacc --defines --debug --verbose" +) + +add_custom_command( + OUTPUT exparse.c + MAIN_DEPENDENCY y.tab.c + COMMAND sed -e "s/fprintf/sfprintf/g" -e "s/FILE/Sfio_t/g" -e "s/stderr/sfstderr/g" ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c > exparse.c +) + +if (WIN32) + add_custom_command( + OUTPUT exparse.h + MAIN_DEPENDENCY y.tab.h + COMMAND echo \#ifndef _EXPARSE_H > exparse.h + COMMAND echo \#define _EXPARSE_H >> exparse.h + COMMAND type y.tab.h >> exparse.h + COMMAND echo \#endif /* _EXPARSE_H */ >> exparse.h + ) +else() + add_custom_command( + OUTPUT exparse.h + MAIN_DEPENDENCY y.tab.h + COMMAND echo "\\#ifndef _EXPARSE_H" > exparse.h + COMMAND echo "\\#define _EXPARSE_H" >> exparse.h + COMMAND cat y.tab.h >> exparse.h + COMMAND echo "\\#endif /* _EXPARSE_H */" >> exparse.h + ) +endif() + +add_library(expr STATIC + # Header files + exgram.h + exlib.h + exop.h + expr.h + + # Source files + excc.c + excontext.c + exdata.c + exerror.c + exeval.c + exexpr.c + exlexname.c + exopen.c + exrewind.c + extoken.c + extype.c + exzero.c + exnospace.c + exstash.c + + # Generated files + ${CMAKE_CURRENT_BINARY_DIR}/exparse.h + ${CMAKE_CURRENT_BINARY_DIR}/exparse.c +) + +target_include_directories(expr PRIVATE + ${GRAPHVIZ_LIB_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/.. # needed to find generated expr/exparse.h + ${GRAPHVIZ_LIB_DIR}/ast + ${GRAPHVIZ_LIB_DIR}/vmalloc + ${GRAPHVIZ_LIB_DIR}/sfio + ${GRAPHVIZ_LIB_DIR}/cdt +)