Closed 79t1ckz closed 1 month ago
If you modify this, please guard it with an if(TARGET ...)
because everything is working fine on my side. How are you using gflags exactly? I am using v2.2.2
and it's working perfectly fine with gflags::gflags
. When using FetchContent
this will most likely not work...
On the current master it says to use gflags::gflags
too:
I solved this problem by modifying the gflag's config.cmake...
# my-adapter.cmake
message("[P-WARN]: gflags::gflags adapter is activated!!")
if(TARGET gflags::gflags)
message("[P-INFO]: gflags::gflags is existing!!")
else()
message("[P-INFO]: gflags::gflags is created!!")
add_library(gflags::gflags ALIAS gflags)
endif()
# gflags-config.cmake
message("==========[PATCHED CODE]==========")
include("${CMAKE_CURRENT_LIST_DIR}/my-adapter.cmake")
message("==========[PATCHED END]===========")
I compiled the project successfully, but I think this method is too crazy. If I got a better method, I will post it here. Thanks for your help :)
We could feasibly vendor gflags and glog via submodules. Perhaps we don't do that because I was hesitant to do it in the past and never had good results with submodules, and we switched to vcpkg / cxx-common and then it was a non-issue. Anyway, the way multiplier manages its vendored dependencies, include glog and gflags, could potentially be used.
@chkzh you need to set -DGFLAGS_USE_TARGET_NAMESPACE=ON
, then everything works as expected: https://github.com/mrexodia/cxx-common-cmake/blob/master/CMakeLists.txt#L89
We are using a super build instead of vcpkg. For public dependencies using find_package
is always preferred because that is how CMake was designed to operate. Mixing this with FetchContent is usually a recipe for disaster (unless the dependency is private, then it obviously doesn't matter how you get the .cpp
files).
In the compilation dependency package downloaded from
build.sh
, the version of gflags is v2.2.2. In this version, gflags modified the linking method in cmake fromtarget_link_libraries(test gflags::gflags)
totarget_link_libraries(test gflags)
(which is not specified on their official website 😅 ), but it was not modified in the CMakeLists.txt of remix and anvill. This can cause programs that use remix to compile to fail, such as the test program I wrote myself and anvill