ExternalProject_Add error finding source directory


I am writing a C.I script for my c++ project, and I would like to use ExternalProject_Add command to autodownload and build the dependencies. One of those is glew (graphics library) which I get from the url “https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.zip”. This is the cmake command:

    URL  ${GLEW_URL}
    LIST_SEPARATOR | # Use the alternate list separator
    BUILD_COMMAND "cmake -G ${CMAKE_GENERATOR} -S ${EXTERNAL_DIR_LOCATION}/${SUBPROJECT_NAME}/source/build/cmake --build ."

Now, the problem is when I try to build the glew project I get the error:

CMake error : The source directory "D:/VR-Volumeviewer/superbuild/build/install" does not exist.

I dont really know where the error is coming from. I checked the visual studio project, and it seems that path comes from the DCMAKE_PREFIX_PATH, but not sure.

Any thoughts on how to overcome it ?

(I reformatted your post a little to make the example code clearer)

It looks like you’ve tried to combine the configure and build steps into the one command. These are separate steps. I’m assuming that you found that the configure and build commands that CMake normally creates for you automatically don’t do what you want, presumably because you want to use a different source directory than just the top of the source tree obtained from the URL? I would suggest you use the SOURCE_SUBDIR option to specify that instead of trying to provide your own configure/build commands. You shouldn’t need to specify BUILD_COMMAND or BUILD_ALWAYS here.

You may also want to check the contents of the BUILD_SUBPROJECT_BUILD_ARGS variable. Do they contain what you expect them to? Are they valid arguments to a cmake command? Do they contain any words that would be picked up as keywords for the ExternalProject_Add() command?

SOURCE_SUBDIR made the trick.