Brydon Gibson
Brydon Gibson

Reputation: 1317

How to simply build an external project with cmake externalproject_add

I've got a library I want to integrate into an existing cmake build. All cmake has to do is go into that directory, run "make", perform install steps as I lay out (probably just a copy to an included binary directory), and then keep doing its thing. Cmake continues to step on my toes trying to create directories and guess at pathnames.

The command in the base CMakeLists.txt is:

ExternalProject_Add(mylib BINARY_DIR ${CMAKE_SOURCE_DIR}/mylib/sdk BUILD_COMMAND make)

However, when I try to build, cmake complains about:

    CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:2630 (message):
  No download info given for 'mylib' and its source directory:

   /home/brydon/build/myTarget/existingLib/mylib-prefix/src/mylib

  is not an existing non-empty directory.  Please specify one of:

   * SOURCE_DIR with an existing non-empty directory
   * DOWNLOAD_COMMAND
   * URL
   * GIT_REPOSITORY
   * SVN_REPOSITORY
   * HG_REPOSITORY
   * CVS_REPOSITORY and CVS_MODULE
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/ExternalProject.cmake:3236 (_ep_add_download_command)
  CMakeLists.txt:83 (ExternalProject_Add)

Why is it jumping at all of these directories? I don't understand what CMake is trying to do here - all it needs to do is run make in the directory that I very clearly spefified as the build dir.

I have tried using SOURCE_DIR but then I get an error that there is no CMakeLists.txt in that directory, which again is not what I want.

How can I get cmake to very simply use an existing makefile, and nothing more?

Upvotes: 0

Views: 4179

Answers (1)

Alan Birtles
Alan Birtles

Reputation: 36613

If you aren't downloading code then SOURCE_DIR needs to be set to an existing directory containing your library.

If you aren't using cmake then you need to set CONFIGURE_COMMAND to an empty string as stated in the ExternalProject_Add documentation.

Upvotes: 1

Related Questions