Copilot commented on code in PR #2298:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2298#discussion_r4513723092


##########
cmake/ConcurrentQueue.cmake:
##########
@@ -0,0 +1,33 @@
+# 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.
+include(FetchContent)
+
+FetchContent_Declare(
+    concurrentqueue
+    URL           
https://github.com/cameron314/concurrentqueue/archive/refs/tags/v1.0.5.tar.gz
+    URL_HASH      
SHA256=4d6368a27492d86011fde5ca0cf386dce7c49cd425aa3d9b063ca6ec373a6ef3
+    SOURCE_DIR    ${CMAKE_BINARY_DIR}/concurrentqueue_include/moodycamel
+    SOURCE_SUBDIR does-not-exist   # don't run upstream CMake; we define the 
target
+)
+FetchContent_MakeAvailable(concurrentqueue)
+
+if(NOT TARGET concurrentqueue::concurrentqueue)
+    add_library(concurrentqueue INTERFACE)
+    target_include_directories(concurrentqueue SYSTEM INTERFACE
+        ${CMAKE_BINARY_DIR}/concurrentqueue_include)

Review Comment:
   Same pattern as in `CppLint.cmake`: `FetchContent_MakeAvailable()` + 
`SOURCE_SUBDIR does-not-exist` is very likely to break CMake configure because 
it will try to `add_subdirectory()` into a non-existent directory. Prefer 
`FetchContent_Populate(concurrentqueue)` (download/extract only) and then build 
the `concurrentqueue::concurrentqueue` interface target from 
`${concurrentqueue_SOURCE_DIR}`.



##########
cmake/CppLint.cmake:
##########
@@ -0,0 +1,34 @@
+# 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.
+include(FetchContent)
+
+set(PATCH_FILE 
"${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/main_args.patch")
+set(PC ${Bash_EXECUTABLE}  -c "set -x &&\
+        (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i 
\\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i 
\\\"${PATCH_FILE}\\\")")
+
+FetchContent_Declare(
+    cpplint
+    URL           
https://github.com/cpplint/cpplint/archive/refs/tags/2.0.2.tar.gz
+    URL_HASH      
SHA256=fc6d0cd40f934b58e8e0bb5eb5f1f2b651880b5fbc0e93a54e6fb6503f733b3d
+    PATCH_COMMAND ${PC}
+    SOURCE_DIR    ${CMAKE_BINARY_DIR}/cpplint
+    SOURCE_SUBDIR does-not-exist   # only download the source
+)
+FetchContent_MakeAvailable(cpplint)
+
+set(CPPLINT_DIR ${CMAKE_BINARY_DIR}/cpplint)

Review Comment:
   `FetchContent_MakeAvailable()` will attempt to `add_subdirectory()` using 
`SOURCE_SUBDIR`. Pointing `SOURCE_SUBDIR` to a non-existent path will typically 
fail configuration. If the intent is “download only”, use 
`FetchContent_Populate(cpplint)` (or `FetchContent_GetProperties` + `Populate`) 
and then reference `${cpplint_SOURCE_DIR}` / your chosen directory without 
calling `MakeAvailable`, or provide a real subdir containing a minimal 
CMakeLists that does nothing.



##########
cmake/RapidJSON.cmake:
##########
@@ -0,0 +1,33 @@
+# 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.
+include(FetchContent)
+
+set(RAPIDJSON_BUILD_TESTS    OFF CACHE BOOL "" FORCE)
+set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
+set(RAPIDJSON_BUILD_DOC      OFF CACHE BOOL "" FORCE)
+
+FetchContent_Declare(
+    rapidjson_src
+    GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
+    GIT_TAG        297637bc0a0f00dc504dbc1a47ebdaa577f8ae19
+    SYSTEM
+)
+FetchContent_MakeAvailable(rapidjson_src)
+
+add_library(rapidjson INTERFACE)

Review Comment:
   `FetchContent_MakeAvailable(rapidjson_src)` will `add_subdirectory()` the 
upstream RapidJSON project, which may define its own targets. Immediately 
defining another target named `rapidjson` risks a hard configure error if 
upstream already creates a `rapidjson` (or similarly named) target. To make 
this robust, either (1) only “populate” RapidJSON (no `add_subdirectory`) and 
define your interface target yourself, or (2) rely on the upstream exported 
target and create an ALIAS/INTERFACE wrapper only if your preferred target name 
doesn’t already exist (e.g. `if(NOT TARGET rapidjson) ...`).



##########
cmake/GetRapidJSON.cmake:
##########
@@ -0,0 +1,25 @@
+# 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.
+
+if(MINIFI_RAPIDJSON_SOURCE STREQUAL "CONAN")
+    message("Using Conan to install RapidJSON")
+    find_package(RapidJSON REQUIRED)
+    target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING=1)
+elseif(MINIFI_RAPIDJSON_SOURCE STREQUAL "BUILD")
+    message("Using CMake to build RapidJSON from source")
+    include(RapidJSON)

Review Comment:
   In the Conan branch, `rapidjson` is not created here (and may not exist at 
all), but you immediately call `target_compile_definitions(rapidjson ...)`, 
which will fail. Also, the rest of the build links against `rapidjson` 
(lowercase) rather than the Conan-provided imported target (commonly 
`RapidJSON::RapidJSON`). A concrete fix is to create/ensure a consistent 
project-local target (e.g. `rapidjson`) in both branches: in the Conan branch, 
define an `INTERFACE` library `rapidjson` that links to `RapidJSON::RapidJSON` 
(or the actual imported target name provided), then apply compile definitions 
to that wrapper target.



##########
CMakeLists.txt:
##########
@@ -55,6 +55,26 @@ if (DOCKER_BUILD_ONLY)
     return()
 endif()
 
+# Find bash executable
+find_package(Bash REQUIRED)
+
+# Find patch executable
+find_package(Patch REQUIRED)
+
+include(CppLint)
+add_custom_target(linter COMMAND
+        python3 ${CPPLINT_DIR}/run_linter.py -q -i 
${CMAKE_SOURCE_DIR}/controller/ ${CMAKE_SOURCE_DIR}/core-framework/ 
${CMAKE_SOURCE_DIR}/encrypt-config/ ${CMAKE_SOURCE_DIR}/extension-framework/ 
${CMAKE_SOURCE_DIR}/extensions/ ${CMAKE_SOURCE_DIR}/libminifi/ 
${CMAKE_SOURCE_DIR}/minifi-api/ ${CMAKE_SOURCE_DIR}/minifi_main/)
+set_target_properties(linter PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
+
+if(NOT WIN32)
+add_custom_target(shellcheck
+    COMMAND ${CMAKE_SOURCE_DIR}/run_shellcheck.sh ${CMAKE_SOURCE_DIR})
+endif(NOT WIN32)
+

Review Comment:
   `Bash` and `Patch` become hard requirements at configure time for all builds 
(including platforms/environments that may not have them installed, e.g. some 
Windows toolchains), because `CppLint` is also included unconditionally. If 
these tools are only required for static analysis/lint targets, consider gating 
these `find_package(... REQUIRED)` calls and `include(CppLint)` behind a 
dedicated option (or at least behind `MINIFI_STATIC_ANALYSIS_ONLY` / `NOT 
WIN32`) so normal builds don’t fail configuration due to missing developer 
tooling.



-- 
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]

Reply via email to