I am including an external project with ExternalProject_Add. What I want is to be able to do
cmake -DCMAKE_CXX_COMPILER=<some compiler> <assume correct path>
for the top-level project so that my chosen compiler propagates to the externally included projects. I expect something that I can put in the ExternalProject_Add command:
ExternalProject_Add (
some_external_project
PREFIX ... # Assume this works.
GIT_REPOSITORY ... # Assume this works too.
# What should I write here to tell it to use the ${CMAKE_CXX_COMPILER}
# of the top-level project ?
)
CMake needs a way to determine which compiler to use to invoke the linker. This is determined by the LANGUAGE property of source files of the target , and in the case of static libraries, the LANGUAGE of the dependent libraries.
CMake ExternalProject allows building a wide variety of subprojects isolated from the main CMake project. For GNU Make Makefile projects, it is necessary to invoke the make command.
In the C/C++ ecosystem, the best tool for project configuration is CMake. CMake allows you to specify the build of a project, in files named CMakeLists. txt, with a simple syntax (much simpler than writing Makefiles).
The following worked for me in the top-level project:
ExternalProject_Add (
some_external_project
PREFIX ... # Assume this works.
GIT_REPOSITORY ... # Assume this works too.
# This did the trick for me.
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With