ExternalProject_Add error finding source directory

Hello,

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:

ExternalProject_Add(${SUBPROJECT_NAME}
    PREFIX ${SUBPROJECT_NAME}
    DOWNLOAD_DIR ${SUBPROJECT_NAME}
    STAMP_DIR ${SUBPROJECT_STAMP_PATH}
    SOURCE_DIR ${SUBPROJECT_SOURCE_PATH}
    BINARY_DIR ${SUBPROJECT_BUILD_PATH}
    URL  ${GLEW_URL}
    LIST_SEPARATOR | # Use the alternate list separator
    CMAKE_ARGS
      -DCMAKE_BUILD_TYPE=Release
      -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
      -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
      -DCMAKE_INSTALL_PREFIX:PATH=${SUBPROJECT_INSTALL_PATH}
      -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
      -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
      -DCMAKE_INSTALL_DOCDIR=${CMAKE_INSTALL_DOCDIR}
      -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
      -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
      ${BUILD_SUBPROJECT_BUILD_ARGS}
    BUILD_COMMAND "cmake -G ${CMAKE_GENERATOR} -S ${EXTERNAL_DIR_LOCATION}/${SUBPROJECT_NAME}/source/build/cmake --build ."
    BUILD_ALWAYS OFF
  )

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.

Thanks,