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
m开发者_如何学编程ake[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?
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.
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.
精彩评论