Ask FetchContent_Declare to dowload to ${project_SOURCE_DIR}/<subdir>

I’m using FetchContent to get CryptoPP into my project.

The point is that ${cryptopp_SOURCE_DIR} already contains .h and .cpp files.

I would like to tell FetchContent to download the package to a ${cryptopp_SOURCE_DIR}/cryptopp folder, so that, in my code, I could #include "cryptopp/whatever.h".

Is that possible?

${cryptopp_SOURCE_DIR} is defined as the place the source is downloaded to, so trying to make it download to ${cryptopp_SOURCE_DIR}/cryptopp isn’t the right thing to be trying to do. You can define the actual directory by specifying SOURCE_DIR as one of the FetchContent_Declare() arguments. Then you take on the full responsibility of where to put the source dir too (i.e. the full path), not just the name of the leaf directory.

1 Like