From 5fa591a765b0bec31951c03ec1b46362c0ac373f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 14 Apr 2021 11:58:57 +0800 Subject: [PATCH] cmake: update civetweb.h on demand 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 --- src/rgw/CMakeLists.txt | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index b63351f2f92..673f80c8a63 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -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} $) -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 $ $) -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") -- 2.39.5