The static library 'common' has no dependencies.
The following checks have been added:
- FindAWK (custom CMake module added)
- FindPerl
- FindEXPAT
- FindZLIB
- HAVE_SINCOS
- HAVE_STRINGS_H
- HAVE_SYS_TYPES_H
- HAVE_STRNCASECMP_H
The steps to generate `colortbl.h` and `ps_font_equiv.h` are the same as
in the Autotools build. DEFAULT_DPI is now set in the config.h generated
by CMake.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# ============================= Build dependencies =============================
-find_package(Git REQUIRED)
+find_package(AWK REQUIRED)
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
+find_package(Git REQUIRED)
+find_package(Perl REQUIRED)
# ================== Convenient values for CMake configuration =================
set(BINARY_INSTALL_DIR bin)
endif()
find_package(ANN)
+find_package(EXPAT)
+find_package(ZLIB)
+
+# Find DLLs on Windows
+if (WIN32)
+ find_file(EXPAT_RUNTIME_LIBRARY NAMES libexpat.dll expat.dll)
+ find_file(ZLIB_RUNTIME_LIBRARY NAMES zlib1.dll zlib.dll)
+endif()
# ============================ Set Graphviz version ============================
set(GRAPHVIZ_VERSION_MAJROR 2)
--- /dev/null
+find_program(AWK_EXECUTABLE NAMES gawk awk)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(AWK DEFAULT_MSG
+ AWK_EXECUTABLE)
# Header checks
include(CheckIncludeFile)
-check_include_file( malloc.h HAVE_MALLOC_H )
-check_include_file( stat.h HAVE_STAT_H )
-check_include_file( sys/stat.h HAVE_SYS_STAT_H )
-check_include_file( unistd.h HAVE_UNISTD_H )
+check_include_file( malloc.h HAVE_MALLOC_H )
+check_include_file( stat.h HAVE_STAT_H )
+check_include_file( strings.h HAVE_STRINGS_H )
+check_include_file( sys/stat.h HAVE_SYS_STAT_H )
+check_include_file( sys/types.h HAVE_SYS_TYPES_H )
+check_include_file( unistd.h HAVE_UNISTD_H )
# Function checks
include(CheckFunctionExists)
-check_function_exists( drand48 HAVE_DRAND48 )
-check_function_exists( cbrt HAVE_CBRT )
-check_function_exists( getpagesize HAVE_GETPAGESIZE)
-check_function_exists( mallinfo HAVE_MALLINFO )
-check_function_exists( mallopt HAVE_MALLOPT )
-check_function_exists( mstats HAVE_MSTATS )
-check_function_exists( srand48 HAVE_SRAND48 )
-check_function_exists( strcasecmp HAVE_STRCASECMP )
+check_function_exists( drand48 HAVE_DRAND48 )
+check_function_exists( cbrt HAVE_CBRT )
+check_function_exists( getpagesize HAVE_GETPAGESIZE )
+check_function_exists( mallinfo HAVE_MALLINFO )
+check_function_exists( mallopt HAVE_MALLOPT )
+check_function_exists( mstats HAVE_MSTATS )
+check_function_exists( sincos HAVE_SINCOS )
+check_function_exists( srand48 HAVE_SRAND48 )
+check_function_exists( strcasecmp HAVE_STRCASECMP )
+check_function_exists( strncasecmp HAVE_STRNCASECMP )
+check_function_exists( vsnprintf HAVE_VSNPRINTF )
# Type checks
# The function check_size_type also checks if the type exists
check_type_size( intptr_t INTPTR_T )
# Library checks
-if (ANN_FOUND)
- set(HAVE_ANN 1)
-endif()
+set( HAVE_ANN ${ANN_FOUND} )
+set( HAVE_EXPAT ${EXPAT_FOUND} )
+set( HAVE_ZLIB ${ZLIB_FOUND} )
+
+# Values
+set(DEFAULT_DPI 96)
# Write check results to config.h header
configure_file(config-cmake.h.in config.h)
--- /dev/null
+file(READ @CMAKE_CURRENT_BINARY_DIR@/svgcolor_lib svgcolor_lib)
+file(READ @CMAKE_CURRENT_BINARY_DIR@/brewer_lib brewer_lib)
+file(READ @CMAKE_CURRENT_SOURCE_DIR@/color_names color_names)
+
+# Do not ignore empty elements in list
+cmake_policy(SET CMP0007 NEW)
+
+# Make it a list for sorting
+string(REPLACE "\n" ";" color_lib ${svgcolor_lib} ${brewer_lib} ${color_names})
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/color_lib-temp "${color_lib}")
+list(SORT color_lib)
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/color_lib-sort "${color_lib}")
+string(REGEX REPLACE ";" "\\n" color_lib "${color_lib}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/color_lib ${color_lib})
--- /dev/null
+file(READ @CMAKE_CURRENT_BINARY_DIR@/htmlparse.h file_contents)
+string(REPLACE "yy" "html" file_contents "${file_contents}")
+string(REPLACE "unsigned long int" "uint_64_t" file_contents "${file_contents}")
+string(REPLACE "unsigned long" "uint_64_t" file_contents "${file_contents}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/htmlparse.h "${file_contents}")
+
+file(READ @CMAKE_CURRENT_BINARY_DIR@/htmlparse.c file_contents)
+string(REPLACE "yy" "html" file_contents "${file_contents}")
+string(REPLACE "unsigned long int" "uint_64_t" file_contents "${file_contents}")
+string(REPLACE "unsigned long" "uint_64_t" file_contents "${file_contents}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/htmlparse.c "${file_contents}")
// Include headers
#cmakedefine HAVE_MALLOC_H
#cmakedefine HAVE_STAT_H
+#cmakedefine HAVE_STRINGS_H
#cmakedefine HAVE_SYS_STAT_H
+#cmakedefine HAVE_SYS_TYPES_H
#cmakedefine HAVE_UNISTD_H
// Functions
#cmakedefine HAVE_MALLINFO
#cmakedefine HAVE_MALLOPT
#cmakedefine HAVE_MSTATS
+#cmakedefine HAVE_SINCOS
#cmakedefine HAVE_SRAND48
#cmakedefine HAVE_STRCASECMP
+#cmakedefine HAVE_STRNCASECMP
+#cmakedefine HAVE_VSNPRINTF
// Types
#cmakedefine HAVE_SSIZE_T
// Libraries
#cmakedefine HAVE_ANN
+#cmakedefine HAVE_EXPAT
+#cmakedefine HAVE_ZLIB
+
+// Values
+#define DEFAULT_DPI @DEFAULT_DPI@
# No dependencies
add_subdirectory(cdt)
add_subdirectory(circogen)
+add_subdirectory(common)
add_subdirectory(dotgen)
add_subdirectory(fdpgen)
add_subdirectory(ingraphs)
--- /dev/null
+BISON_TARGET(HTMLparse htmlparse.y ${CMAKE_CURRENT_BINARY_DIR}/htmlparse.c)
+
+# Modify files generated by Bison, to match the Autotools build.
+# - Replace "yy" with "aag"
+# - Replace "unsigned long int" with "uint64_t"
+# - Replace "unsigned long" with "uint64_t"
+configure_file(
+ "${TOP_SOURCE_DIR}/cmake/modify_common_htmlparse.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/modify_common_htmlparse.cmake"
+ @ONLY
+)
+add_custom_command(
+ OUTPUT ${BISON_HTMLparse_OUTPUTS}
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/modify_common_htmlparse.cmake
+ APPEND
+)
+
+add_definitions(-DGVC_EXPORTS -D_BLD_gvc=1)
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TOP_SOURCE_DIR}
+ ${GRAPHVIZ_LIB_DIR}/cdt
+ ${GRAPHVIZ_LIB_DIR}/cgraph
+ ${GRAPHVIZ_LIB_DIR}/gvc
+ ${GRAPHVIZ_LIB_DIR}/label
+ ${GRAPHVIZ_LIB_DIR}/pack
+ ${GRAPHVIZ_LIB_DIR}/pathplan
+ ${GRAPHVIZ_LIB_DIR}/fdpgen
+ ${GRAPHVIZ_LIB_DIR}/xdot
+)
+
+if (WIN32)
+ include_directories(${WINDOWS_DEPENDENCY_DIR}/include)
+endif()
+
+# Generate colortbl.h from sources
+add_custom_command(
+ OUTPUT svgcolor_lib
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/svgcolor_names ${TOP_SOURCE_DIR}/awk/svgcolor.awk
+ COMMAND ${AWK_EXECUTABLE} -f ${TOP_SOURCE_DIR}/awk/svgcolor.awk
+ ${CMAKE_CURRENT_SOURCE_DIR}/svgcolor_names > ${CMAKE_CURRENT_BINARY_DIR}/svgcolor_lib
+)
+add_custom_command(
+ OUTPUT brewer_lib
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/brewer_colors ${TOP_SOURCE_DIR}/awk/brewer.awk
+ COMMAND ${AWK_EXECUTABLE} -f ${TOP_SOURCE_DIR}/awk/brewer.awk
+ ${CMAKE_CURRENT_SOURCE_DIR}/brewer_colors > ${CMAKE_CURRENT_BINARY_DIR}/brewer_lib
+)
+configure_file(
+ "${TOP_SOURCE_DIR}/cmake/generate_color_lib.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/generate_color_lib.cmake"
+ @ONLY
+)
+add_custom_command(
+ OUTPUT color_lib
+ DEPENDS svgcolor_lib brewer_lib ${CMAKE_CURRENT_SOURCE_DIR}/color_names
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/generate_color_lib.cmake
+)
+add_custom_command(
+ OUTPUT colortbl.h
+ DEPENDS color_lib
+ COMMAND ${AWK_EXECUTABLE} -f ${TOP_SOURCE_DIR}/awk/colortbl.awk
+ ${CMAKE_CURRENT_BINARY_DIR}/color_lib > ${CMAKE_CURRENT_BINARY_DIR}/colortbl.h
+)
+
+# Generate ps_font_equiv.h from sources
+add_custom_command(
+ OUTPUT ps_font_equiv.h
+ DEPENDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/mksvgfonts.pl
+ ${CMAKE_CURRENT_SOURCE_DIR}/ps_font_equiv.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/fontmap.cfg
+ ${CMAKE_CURRENT_SOURCE_DIR}/ps_fontmap.txt
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ps_fontmap.txt
+ ${CMAKE_CURRENT_BINARY_DIR}/ps_font_equiv.h
+ COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mksvgfonts.pl
+ ${CMAKE_CURRENT_SOURCE_DIR}/fontmap.cfg
+ ${CMAKE_CURRENT_SOURCE_DIR}/ps_font_equiv.txt
+ >> ${CMAKE_CURRENT_BINARY_DIR}/ps_font_equiv.h
+)
+
+add_library(common STATIC
+ # Header files
+ arith.h
+ color.h
+ colorprocs.h
+ colortbl.h
+ const.h
+ entities.h
+ geom.h
+ geomprocs.h
+ globals.h
+ intset.h
+ htmllex.h
+ htmltable.h
+ logic.h
+ macros.h
+ memory.h
+ pointset.h
+ ps_font_equiv.h
+ render.h
+ textspan.h
+ types.h
+ usershape.h
+ utils.h
+
+ # Source files
+ args.c
+ arrows.c
+ colxlate.c
+ ellipse.c
+ emit.c
+ geom.c
+ globals.c
+ htmllex.c
+ htmltable.c
+ input.c
+ intset.c
+ labels.c
+ ns.c
+ memory.c
+ output.c
+ pointset.c
+ postproc.c
+ psusershape.c
+ routespl.c
+ shapes.c
+ splines.c
+ taper.c
+ textspan.c
+ timing.c
+ utils.c
+
+ # Generated files
+ ${BISON_HTMLparse_OUTPUTS}
+)
+
+# Specify headers to be installed
+install(
+ FILES
+ arith.h
+ color.h
+ geom.h
+ textspan.h
+ types.h
+ usershape.h
+ DESTINATION ${HEADER_INSTALL_DIR}
+)