From: Matthew Fernandez Date: Sat, 26 Mar 2022 20:39:07 +0000 (-0700) Subject: CMake: enable 'diffimg' X-Git-Tag: 4.0.0~155^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59f40f789c23f52e7b5ab9473a6a5cc0efa1d545;p=graphviz CMake: enable 'diffimg' Note that the rtest/rtest.py work around is still not fully removed because libgd is not currently available in the 64-bit Windows CI environment. Gitlab: closes #1788 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb4e69f9..8ea800479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- the `mingle` and `edgepaint` binaries are now included in the CMake build +- the `mingle`, `diffimg`, and `edgepaint` binaries are now included in the + CMake build system - a brief note about the (previously undocumented) behavior of Graphviz when sent `SIGUSR1` is now mentioned in the man page diff --git a/CMakeLists.txt b/CMakeLists.txt index 8186859f8..e77e87c54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,6 +279,7 @@ include(CPack) Include(CTest) # ======================= Specify subdirectories to build ====================== +add_subdirectory(contrib/diffimg) add_subdirectory(lib) add_subdirectory(plugin) add_subdirectory(cmd) diff --git a/ci/tests.py b/ci/tests.py index 39eea310d..a2a2dae10 100644 --- a/ci/tests.py +++ b/ci/tests.py @@ -100,7 +100,6 @@ def test_existence(binary: str): tools_not_built_with_cmake = [ "cluster", - "diffimg", "dot_builtins", "dotty", "gv2gxl", @@ -171,6 +170,10 @@ def test_existence(binary: str): check_that_tool_does_not_exist(binary, os_id) pytest.skip(f"{binary} is not built on some Windows due to lacking libANN") + if binary == "diffimg" and is_win64(): + check_that_tool_does_not_exist(binary, os_id) + pytest.skip(f"{binary} is not built on 64-bit Windows due to lacking libgd") + assert shutil.which(binary) is not None def check_that_tool_does_not_exist(tool, os_id): diff --git a/contrib/diffimg/CMakeLists.txt b/contrib/diffimg/CMakeLists.txt new file mode 100644 index 000000000..17c44b1fb --- /dev/null +++ b/contrib/diffimg/CMakeLists.txt @@ -0,0 +1,37 @@ +find_package(GD) + +if(GD_FOUND) + + add_executable(diffimg diffimg.c) + target_include_directories(diffimg PRIVATE ${GRAPHVIZ_LIB_DIR}) + target_include_directories(diffimg SYSTEM PRIVATE ${GD_INCLUDE_DIRS}) + target_link_libraries(diffimg ${GD_LIBRARIES}) + + install( + TARGETS diffimg + RUNTIME DESTINATION ${BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR} + ) + + if(GZIP) + add_custom_target(man-diffimg ALL DEPENDS diffimg.1.gz + COMMENT "diffimg man page") + add_custom_command( + OUTPUT diffimg.1.gz + COMMAND ${GZIP} -9 --no-name --to-stdout diffimg.1 + >"${CMAKE_CURRENT_BINARY_DIR}/diffimg.1.gz" + MAIN_DEPENDENCY diffimg.1 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "compress diffimg man page") + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/diffimg.1.gz + DESTINATION ${MAN_INSTALL_DIR}/man1) + else() + install( + FILES diffimg.1 + DESTINATION ${MAN_INSTALL_DIR}/man1 + ) + endif() + +endif() diff --git a/rtest/rtest.py b/rtest/rtest.py index 874b76fa5..e50682e3f 100755 --- a/rtest/rtest.py +++ b/rtest/rtest.py @@ -152,10 +152,11 @@ def doDiff(OUTFILE, testname, subtest_index, fmt): returncode = 0 if a.strip() == b.strip() else -1 elif F == "png": # FIXME: remove when https://gitlab.com/graphviz/graphviz/-/issues/1788 is fixed - if os.environ.get("build_system") == "cmake": + if os.environ.get("build_system") == "cmake" and \ + platform.system() == "Windows": print(f"Warning: Skipping PNG image comparison for test {testname}:" - f"{subtest_index} : format: {fmt} because CMake builds does not " - "contain the diffimg utility (#1788)", + f"{subtest_index} : format: {fmt} because CMake builds on Windows " + "do not contain the diffimg utility (#1788)", file=sys.stderr) return returncode = subprocess.call( @@ -404,7 +405,8 @@ if not GENERATE: print("Could not find a value for DIFFIMG", file=sys.stderr) # FIXME: Remove workaround for missing diffimg when # https://gitlab.com/graphviz/graphviz/-/issues/1788 is fixed - if os.environ.get("build_system") != "cmake": + if os.environ.get("build_system") != "cmake" or \ + platform.system() != "Windows": sys.exit(1) # sys.exit(1)