[CMake] INSTALL_COMMAND for ExternalProject not overriding the install step

Chris Morgan chmorgan at gmail.com
Tue Nov 5 10:16:09 EST 2013


Hello.

I'm using ExternalProject to build a CMakeLists.txt in a subdirectory.
This subdirectory is used by other applications, files are included
from that subdirectory directly, but that subdirectory doesn't install
anything but does contain the unit tests for the files in that
directory and I'd still like 'make test' to work properly from my top
level CMakeLists.txt that is including this ExternalProject.

So, I'm trying to override the INSTALL_COMMAND but it doesn't appear
to be working correctly.

#add_subdirectory(shared_cpp)
ExternalProject_Add(
    shared_cpp
    SOURCE_DIR ${CMAKE_SOURCE_DIR}/shared_cpp
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
               -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
    TEST_COMMAND make test
    INSTALL_COMMMAND ""
)


I'm still seeing cmake calling 'make install' and this causes a build failure:

make[2]: Entering directory `/home/cmorgan/projects/external/build'
/usr/bin/cmake -E cmake_progress_report
/home/cmorgan/projects/external/build/CMakeFiles 18
[ 39%] Performing install step for 'shared_cpp'
cd /home/cmorgan/projects/external/build/shared_cpp-prefix/src/shared_cpp-build
&& make install
make[3]: Entering directory
`/home/cmorgan/projects/external/build/shared_cpp-prefix/src/shared_cpp-build'
make[3]: *** No rule to make target `install'.  Stop.
make[3]: Leaving directory
`/home/cmorgan/projects/external/build/shared_cpp-prefix/src/shared_cpp-build'
make[2]: *** [shared_cpp-prefix/src/shared_cpp-stamp/shared_cpp-install] Error 2
make[2]: Leaving directory `/home/cmorgan/projects/external/build'
make[1]: *** [CMakeFiles/shared_cpp.dir/all] Error 2
make[1]: Leaving directory `/home/cmorgan/projects/external/build'
make: *** [all] Error 2
[cmorgan at localhost build]$



Any ideas how I can fix this?

It may be that I've got something structurally wrong with the project,
for instance, because the shared_cpp/ CMakeLists.txt isn't installing
anything, so I'd welcome suggestions. The files in this directory are
used by several different applications (and the folder is itself a git
submodule). Should I be making this into a library?? I haven't been
able to find good cmake examples for large multi-executable projects
and I didn't really want to have separate git repositories for each of
our small executables that contained their own submodules of
shared_cpp, for instance.

Chris


More information about the CMake mailing list