1

We have some dependency libraries in our repository. The main part is build with cmake. Now the cmake-makefiles shall build the dependency libraries, which do not have a cmake build system. For one specific library there is a "Makefile.squirrel" which should be used. The cmakelists.txt for that library:

cmake_minimum_required (VERSION 2.8)

include(ExternalProject)

ExternalProject_Add(squirrel,
    SOURCE_DIR "./"
    UPDATE_COMMAND ""
    BUILD_IN_SOURCE 1
    CONFIGURE_COMMAND ""
    BUILD_COMMAND "make -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.squirrel"
    INSTALL_COMMAND ""
    )

However, when running make I get an error message:

[ 93%] Performing build step for 'squirrel,'
/bin/sh: make -f /home/enrico/projekte/projectname/dependencies/SQUIRREL2/Makefile.squirrel: not found
make[2]: *** [dependencies/SQUIRREL2/squirrel,-prefix/src/squirrel,-stamp/squirrel,-build] Error 127
make[1]: *** [dependencies/SQUIRREL2/CMakeFiles/squirrel,.dir/all] Error 2
make: *** [all] Error 2

ls -lA on /home/enrico/projekte/projectname/dependencies/SQUIRREL2/Makefile.squirrel shows that the file exists.

Hardcoding the file path (not an option for the solution) does not work, too.

Any ideas or hints?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Enrico
  • 61
  • 5

2 Answers2

3

Three observations:

1) You're using "squirrel," as the name of the project. Arguments to CMake functions are space separated, so the comma is part of the name you've given. (Probably not what you want.)

2) You should use:

SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"

rather than

SOURCE_DIR "./"

Because the "./" is simply relative to that full path name anyhow.

3) The real source of your problem is your BUILD_COMMAND value:

BUILD_COMMAND "make -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.squirrel"

It should read:

BUILD_COMMAND make -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.squirrel

If you have the quotes there, then the shell is looking for an actual file named "make -f .../Makefile.squirrel" because CMake parses arguments by spaces, but the double quotes tell CMake "this is exactly one argument that includes spaces..." If there are spaces in the expanded value of ${CMAKE_CURRENT_SOURCE_DIR} then CMake will properly double quote (or escape, depending on the platform/shell) it when it generates the command in its generated makefiles.

DLRdave
  • 13,876
  • 4
  • 53
  • 70
0

You could try writing a script that calls make with the correct makefile. Just export the CMAKE_CURRENT_SOURCE_DIR to an environmental variable that the script reads.

RobertJMaynard
  • 2,183
  • 14
  • 13
  • I had the very same idea a few hours after posted. I created a separate shell script which is called by BUILD_COMMAND. Works for now but it "feels" like a hack. And I need more of that for the rest of the dependencies... – Enrico Jan 02 '11 at 12:55