From: Kefu Chai Date: Wed, 14 Apr 2021 03:58:57 +0000 (+0800) Subject: cmake: update civetweb.h on demand X-Git-Tag: v17.1.0~2251^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40843%2Fhead;p=ceph.git 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 --- diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index b63351f2f923..673f80c8a63c 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")