I have (mostly) successfully set up ExternalProject_Add for googletest. However, I noticed that things like my choice of C++ compiler, build type, etc. are not automatically forwarded to the ExternalProject.
I can easily add any given flag by adding it to CMAKE_ARGS in the call to ExternalProject_Add like so:
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
However, this requires that I enumerate all of the possible arguments that should be forwarded to googletests's CMake invocation, and that list is pretty enormous. I would also need to create that same list for every other ExternalProject_Add I wanted. That seems fragile and error prone.
Is there a way to tell CMake to "forward" the configuration that the user provided along? In other words, if I invoked CMake as:
cmake <path-to-project> -DCMAKE_C_COMPILER=/usr/bin/clang -DSOME_RANDOM_FLAG=stuff
Then I would like my call to ExternalProject_Add to provide the same compiler selection and value for SOME_RANDOM_FLAG
, without needing to explicitly list those names. I'm not sure that simply passing CMake's ARGV along would work, since saying
CC=/usr/bin/clang cmake <path-to-project>
would ideally work as well.
Any thoughts on how to accomplish this?