Copilot commented on code in PR #3596:
URL: https://github.com/apache/brpc/pull/3596#discussion_r4240332600


##########
src/butil/CMakeLists.txt:
##########
@@ -0,0 +1,338 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set(WITH_GLOG_VAL "0")
+if(WITH_GLOG)
+    set(WITH_GLOG_VAL "1")
+    set(BRPC_WITH_GLOG 1)
+endif()
+
+set(WITH_CPU_FREQUENCY_VAL "0")
+if(WITH_CPU_FREQUENCY)
+    set(WITH_CPU_FREQUENCY_VAL "1")
+    set(BUTIL_USE_CPU_FREQUENCY 1)
+endif()
+
+set(BUTIL_DEFINITIONS
+    BRPC_WITH_GLOG=${WITH_GLOG_VAL}
+    BUTIL_USE_CPU_FREQUENCY=${WITH_CPU_FREQUENCY_VAL})
+if(WITH_MESALINK)
+    list(APPEND BUTIL_DEFINITIONS USE_MESALINK)
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    include(CheckFunctionExists)
+    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
+    if(NOT HAVE_CLOCK_GETTIME)
+        list(APPEND BUTIL_DEFINITIONS NO_CLOCK_GETTIME_IN_MAC)
+    endif()
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)

Review Comment:
   Generate `butil/config.h` in the build tree rather than the source tree. 
This file records `WITH_GLOG` and `WITH_CPU_FREQUENCY`, so two build 
directories configured with different options overwrite the same header; 
whichever configures last can make the other build compile or install a header 
that disagrees with its object files. The generated path also needs to be added 
ahead of the source include root and installed explicitly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to