This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new e6d8056977 cmake: add a format custom target (#10036)
e6d8056977 is described below

commit e6d805697777ab6d3e9475669cdefb9b40864224
Author: Brian Neradt <[email protected]>
AuthorDate: Thu Jul 13 20:54:17 2023 -0500

    cmake: add a format custom target (#10036)
    
    This adds a top-level format custom target that runs both clang-format
    and autopep8.
---
 CMakeLists.txt     | 8 +++++++-
 lib/CMakeLists.txt | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d36073d3e5..ccb73ed613 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -400,7 +400,7 @@ add_clang_format_target(tests)
 
 add_custom_target(clang-format
         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-        COMMENT "formatting all files"
+        COMMENT "formatting all C++ files"
         DEPENDS ${CLANG_FORMAT_TARGETS}
         VERBATIM
         )
@@ -411,6 +411,12 @@ add_custom_target(autopep8 
${CMAKE_SOURCE_DIR}/tools/autopep8.sh ${CMAKE_SOURCE_
         VERBATIM
         )
 
+# Add a format target that depends upon both clang-format and autopep8.
+add_custom_target(format
+        DEPENDS clang-format autopep8
+        COMMENT "formatting all files"
+        )
+
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
     message("Installing github hook")
     configure_file(${CMAKE_SOURCE_DIR}/tools/git/pre-commit 
${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit COPYONLY)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index dfcb5f94f8..de386044c5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -20,9 +20,14 @@
 # yamlcpp shadows a bunch of variables but we don't want to hear bout it
 add_compile_options(-Wno-shadow)
 set(BUILD_SHARED_LIBS 1)
+
+# Turning CLANG_FORMAT off causes yamlcpp to not add its format target which
+# otherwise conflicts with our format target.
+set(YAML_CPP_CLANG_FORMAT_EXE OFF)
 set(YAML_CPP_INSTALL ON)
 add_subdirectory(yamlcpp)
 set(YAML_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/lib/yamlcpp/include PARENT_SCOPE)
+
 add_subdirectory(fastlz)
 add_subdirectory(swoc)
 set(SWOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lib/swoc/include PARENT_SCOPE)

Reply via email to