[CMake] Checking if git submodules have been initialized

Arnaud Gelas arnaudgelas at gmail.com
Wed May 9 08:54:42 EDT 2012


if( NOT EXISTS "${MY_SOURCE_DIR}/project/.git" )
message( SEND_ERROR "The git submodules are not available. Please run
git submodule update --init --recursive"
)
endif()


HTH

On 05/09/2012 02:52 PM, David Doria wrote:
> I have recently started using git submodules in my projects. I have
> had multiple complains from my users "It gives me a "missing xyz.h"
> type of error when I try to compile." The reason is that they haven't
> initialized the submodules (like it says to do in the readme :) ). Is
> there a CMake way to check if a submodule is initialized so I can
> throw a more appropriate error - "Please initialize the xyz submodule"
> instead of letting the error get all the way to the compiler?
>
> Thanks,
>
> David
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list