[CMake] ExternalProject_Add() macro does not set CMAKE_COMPILER_IS_GNUCXX

Nicholas Braden nicholas11braden at gmail.com
Wed Jan 20 12:58:46 EST 2016


Where/how is that variable normally set? External projects have no
awareness of the project they are in, they just run CMake as usual the
same way you would. If the variable is normally set by CMake itself,
make sure that your containing project and the external project both
find the same compiler. (They each do their own automatic search for
compilers)

On Wed, Jan 20, 2016 at 11:41 AM, fkillus via CMake <cmake at cmake.org> wrote:
> I have been trying to compile Ogre [1] as external dependency with
> ExternalProject_Add(). In theory this should be straightforward since Ogre
> itself also uses CMake as buildsystem. However, in the process I encountered
> the following problem:
>
> Ogre checks the value of the CMAKE_COMPILER_IS_GNUCXX variable in some
> places (e.g. [2]). I am running Linux and compiling with g++ and everything
> works fine if I manually configure Ogre with cmake or cmake-gui.
> Unfortunately, after wrapping everything inside ExternalProject_Add(), the
> CMAK_COMPILER_IS_GNUCXX variable is no longer being set correctly.
>
> A simple workaround is to manually set this variable, i.e.:
>
>  ExternalProject_Add(
>     ogre
>     URL https://bitbucket.org/sinbad/ogre/get/v1-9-0.zip
>     CMAKE_ARGS
>       -DCMAKE_INSTALL_PREFIX=${DEPENDENCIES_OUTPUT_DIR}
>       -DCMAKE_COMPILER_IS_GNUCXX=${CMAKE_COMPILER_IS_GNUCXX}   # workaround
>   )
>
> This works, but I'm uncertain if this should be necessary. Is this a bug or
> a feature?
>
>
> [1] https://bitbucket.org/sinbad/ogre
> [2]
> https://bitbucket.org/sinbad/ogre/src/0d580c7216abe27fafe41cb43e31d8ed86ded591/CMake/Utils/OgreConfigTargets.cmake?at=default&fileviewer=file-view-default#OgreConfigTargets.cmake-277
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list