Open paigeadelethompson opened 1 year ago
Oh hey I think I figured this out now, I was on the right path, you just have to make sure to require it for those variables to work:
find_package(libxcrypt REQUIRED)
include_directories(
include/
${argon2_INCLUDE_DIR}
)
and then I could see it was correct and adding the -I path/
in the build output from cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake && cmake --build . --parallel 8
To be honest I don't even know if thats the way you're supposed to do it because that seems counter intuitive? I don't know, I just haven't had much luck finding the right answers maybe..
Hi @paigeadelethompson
Thanks for your suggestion. The thing is that such variables are internal implementation detail of the CMakeDeps generator. They shouldn't be used directly, also because modern CMake good practices discourage that approach. The recommended approach is to link with the target, and such target will bring everything in it: the include-dirs, the lib-dirs, the libs, the necessary flags and definitions, etc. So mostly:
find_package(mydep REQUIRED)
target_link_libraries(mylib_or_app mydep::mydep)
The name of the target is by default the name of the package::package, but it can vary for open source third parties with different conventions. They will typically be printed on screen when find_package()
finds the package.
Ah interesting, yeah I'm not really sure then I thought maybe I saw someone say that it had something to do with trying to use add_subdirectory()
caused the includes to not get injected into the executor but I really don't know I must've read through a dozen pages trying to get it to work and instead I settled for the counter intuitive way of doing it for now, and it works:
https://github.com/paigeadelethompson/clandestine/blob/master/CMakeLists.txt
maybe if you wanna take a look at that and see if you can figure out why I had to do it that way feel free but for now everything seems to be working so I can't complain other than
https://github.com/paigeadelethompson/clandestine/blob/master/src/modules/extra/CMakeLists.txt#L1
some of the pkg_FOUND names are really hard to guess. Stuff appears to be linking correctly but I'm not sure if I have to also install(pkgName) or if its statically linked or whats going on (haven't had much of a chance to test it just kinda got it together and building for now.)
I put an action into workflows for building this if you wanna take a look at the build log in github instead of building yourself:
https://github.com/paigeadelethompson/clandestine/actions/runs/4449257228/jobs/7813179909
yeah I couldn't quite figure out how to get XCode / CMake / Conan working together right either. XCode builds my project ok, but it's not picking up any of my Conan dependencies for some reason. I actually switched to using target_include_directories
for some things, I've been working in a different branch:
https://github.com/paigeadelethompson/clandestine/blob/services/ircd/src/CMakeLists.txt#L44
I wonder though I'm still using include_directories
in places where I have lots of targets like here: https://github.com/paigeadelethompson/clandestine/blob/services/ircd/src/modules/CMakeLists.txt#L3
But I wonder now if maybe if include_directories
is breaking Conan and causing things like target_link_libraries
to not work correctly:
In XCode what I'm noticing is that when I try to build, if(sqlite3_FOUND) will evaluate to true but target_link_libraries(m_sqlite3 clandestine SQLite::SQLite3)
never links because when it XCode tries to link there are unresolved symbol errors. However building with CMake from command line this works fine. So I'll check when I get a chance later today, I imagine there's probably something somewhere that I've overlooked, but at least its coming along some :)
I'm sorta noticing that the CONAN_INCLUDE_DIRS_XXX isn't substantiated by the CMakeDeps CMakeToolchain generators,
I had to go rooting around to find the INCLUDE DIR path names look like
But, it don't work. Is it broke? Why'd they even change this it looks like Conan 1.x did what it was supposed to do?