![]() ![]() ![]() For example say I want Catch2 in my project, which is only for testing, if I put it in the dependencies folder I have to check again if BUILD_TESTING is True (compared to when I put the code in the test folder, where I already do that check) Should all fetchContent depencencies go in there.There are two problems / things I wondered In Craig’s book there is a recommendation to put dependency stuff in a subfolder dependencies if I understood it correctly. My second question is regarding folder structure. What is the best approach to overwrite a cache variable, which might be not declared as option, but rather with the set command? It won’t though if it’s just a set command, this is due to the inconsistency between set(CACHE) and option I believe. The approach with a different scope (directory for each depedency in my case) works quite well for say variables declared option(…). Got a few other question regarding fetchContent and dependency managment in general. Good that projects like CPM are trying to help. Often it feels that CMake is similar to C++ (std) in a way, that it is “standard” library that provides some essential functions and language, but in itself does not provide finished scripts for easy use and final real world solutions. I didn’t understand from the code yet, how they are able to pass the flags, FMT_TEST in this case, forward to FetchContent-functions. However I noticed it was possible to set variables with another function provided by CPM (Setup-free CMake dependency management), which is supposed to be just a wrapper around FetchContent. I think it is possible with ExternalProject_Add, but then the script will be longer and won’t have features of FetchContent. Hi Leon, I had the same problem and did not found a way to pass variables for FetchContent_Declare. Is there a possibility to do that more conveniently? Or is fetchContent just not suitable for bigger projects, which need configuration? There is somthing similar for FetchContent_Declare called CMAKE_ARGS, which looks promising, but doesn’t work. The best approach would be to be able to just have a command like target_compile_options() and use the name of the lib fetched. But that makes the cmake code really complicated. The first one could be solved as well by setting the variable in the script and do some restore magic. Also that might still be annoying to have a lot of different lines to configure that lib. I could probably resolve the second issue by specifiying those in my cmake script with some force magic, although I’m not entirely sure how (I think it could also be problematic that the cmake cache variable behaviours has changed in recent versions). Like SOME_PROJECT_OPTION might always be ON, because of how I use the lib It’s especially annoying for Options, where the value is definitely known. I might include 10 subprojects and then I have 100 variables to set on the first run. It’s annoying to pass all these variables via the command line, it only makes it more difficult for other projects.I probably still want my own tests, just not the project ones It might share variables with my project, for example BUILD_TESTING.There are a couple of issues with that approach: B build -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DSOME_PROJECT_OPTION=ON Say I do want shared libs and no testing for that lib and use some project specific option, I might configure my project like:Ĭmake -S. I wondered what the best method is to pass values for cache variables to a project included with FetchContent. ![]()
0 Comments
Leave a Reply. |