]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: update civetweb.h on demand 40843/head
authorKefu Chai <kchai@redhat.com>
Wed, 14 Apr 2021 03:58:57 +0000 (11:58 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 14 Apr 2021 04:17:50 +0000 (12:17 +0800)
instead of using a dedicated target for updating civetweb.h, use
add_custom_command() with OUTPUT option.

so the generated rule does not rerun the command specified by the
civetweb_h target every time we build the targets depending on it.

use the header file as the dependency helps to improve the readability
as there is one less link in the dependency chain, and by specifying the
OUTPUT, cmake is able to figure out the dependency on the header file so
it does not try to regenerate it every time.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/rgw/CMakeLists.txt

index b63351f2f923ea1734bd6dbeafd4ed362c35d80e..673f80c8a63c816435b5194eecf617f2f4b0310b 100644 (file)
@@ -1,9 +1,14 @@
-add_custom_target(civetweb_h
+set(civetweb_h
+  "${CMAKE_BINARY_DIR}/src/include/civetweb/civetweb.h")
+
+add_custom_command(
+  OUTPUT ${civetweb_h}
   COMMAND ${CMAKE_COMMAND} -E make_directory
-  "${CMAKE_BINARY_DIR}/src/include/civetweb"
+    "${CMAKE_BINARY_DIR}/src/include/civetweb"
   COMMAND ${CMAKE_COMMAND} -E copy_if_different
-  "${CMAKE_SOURCE_DIR}/src/civetweb/include/civetweb.h"
-  "${CMAKE_BINARY_DIR}/src/include/civetweb"
+    "${CMAKE_SOURCE_DIR}/src/civetweb/include/civetweb.h"
+    ${civetweb_h}
+  DEPENDS "${CMAKE_SOURCE_DIR}/src/civetweb/include/civetweb.h"
   COMMENT "keep civetweb.h up-to-date")
 
 find_program(GPERF gperf)
@@ -231,7 +236,8 @@ set(rgw_a_srcs
   rgw_usage.cc
   rgw_opa.cc
   rgw_sts.cc
-  rgw_rest_sts.cc)
+  rgw_rest_sts.cc
+  ${civetweb_h})
 
 gperf_generate(${CMAKE_SOURCE_DIR}/src/rgw/rgw_iam_policy_keywords.gperf
   rgw_iam_policy_keywords.frag.cc)
@@ -248,8 +254,6 @@ add_library(rgw_a STATIC
     ${rgw_a_srcs}
     $<TARGET_OBJECTS:rgw_common>)
 
-add_dependencies(rgw_a civetweb_h)
-
 target_compile_definitions(rgw_a PUBLIC "-DCLS_CLIENT_HIDE_IOCTX")
 target_include_directories(rgw_a PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src")
 target_include_directories(rgw_a SYSTEM PUBLIC "../rapidjson/include")
@@ -305,7 +309,8 @@ set(radosgw_srcs
   rgw_loadgen_process.cc
   rgw_civetweb.cc
   rgw_civetweb_frontend.cc
-  rgw_civetweb_log.cc)
+  rgw_civetweb_log.cc
+  ${civetweb_h})
 if (WITH_RADOSGW_FCGI_FRONTEND)
   list(APPEND radosgw_srcs rgw_fcgi_process.cc)
 endif()
@@ -326,8 +331,6 @@ add_library(radosgw SHARED ${radosgw_srcs} ${rgw_a_srcs} rgw_main.cc
   $<TARGET_OBJECTS:rgw_kmip>
   $<TARGET_OBJECTS:civetweb_common_objs>)
 
-add_dependencies(radosgw civetweb_h)
-
 target_compile_definitions(radosgw PUBLIC "-DCLS_CLIENT_HIDE_IOCTX")
 target_include_directories(radosgw PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src")
 target_include_directories(radosgw SYSTEM PUBLIC "../rapidjson/include")