1

The problem I have is very strange: I try to add an external project (the metis library) to my CMake project:

set(METIS_VERSION "5.1.0")

set(METIS_ARCHIVE "${PROJECT_SOURCE_DIR}/third-party/metis-${METIS_VERSION}.tar.gz")
if(NOT EXISTS ${METIS_ARCHIVE})
  set(METIS_ARCHIVE "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-${METIS_VERSION}.tar.gz")
endif()

set(METIS_DIR ${PROJECT_BINARY_DIR}/third-party/metis)
set(METIS_ROOT ${METIS_DIR}/src/Metis)

ExternalProject_Add(Metis
  PREFIX ${METIS_DIR}
  DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/third-party"
  URL ${METIS_ARCHIVE}
  URL_HASH "MD5=5465e67079419a69e0116de24fce58fe"
  PATCH_COMMAND patch ${METIS_ROOT}/CMakeLists.txt < ${PROJECT_SOURCE_DIR}/cmake/Metis-CMakeLists.txt.patch
  SOURCE_DIR ${METIS_ROOT}
  CONFIGURE_COMMAND $(MAKE) config shared=1 prefix=${METIS_ROOT} cc=${CMAKE_C_COMPILER}
  BINARY_DIR ${METIS_ROOT}
  BUILD_COMMAND $(MAKE)
)

The configure goes fine, but when I try to make, I get the following error message:

[100%] Built target metis
make[5]: *** No rule to make target `s'.  Stop.
make[4]: *** [all] Error 2
make[3]: *** [third-party/metis/src/Metis-stamp/Metis-build] Error 2
make[2]: *** [CMakeFiles/Metis.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

Now the interesting part, if I invoke make in verbose mode (VERBOSE=1 make), the code runs fine and I have no errors. Also, I checked running make -C build/Darwin-x86_64/third-party/metis/src/Metis/ and this also works fine Does someone know what's the issue here?

aa

aaragon
  • 2,314
  • 4
  • 26
  • 60

1 Answers1

1

I checked running make -C build/Darwin-x86_64/third-party/metis/src/Metis/ and this also works fine

99,9% blame environment (:

You can test it by using printenv command:

BUILD_COMMAND printenv && make

copy the result of printenv and compare it with the "clean" one. You must see some diffs, for me it's:

  • MFLAGS
  • MAKEFLAGS
  • MAKELEVEL

I don't know what is the reason of the issue exactly but when I unset this variables everything works fine (note that you need to update the install command too):

BUILD_COMMAND unset MFLAGS && unset MAKEFLAGS && unset MAKELEVEL && make
INSTALL_COMMAND unset MFLAGS && unset MAKEFLAGS && unset MAKELEVEL && make install
  • That indeed solved the problem. Is there a way to check if something else in cmake is polluting the environment? – aaragon Aug 06 '14 at 15:01
  • 1
    @AlejandroMarcosAragon I'm pretty sure it's not a CMake, it's makefile running from other makefile. For example Xcode environment: https://github.com/ruslo/hunter/blob/master/scripts/clear-all.sh –  Aug 06 '14 at 15:11
  • @rusio thanks again for your answer. I'm actually using CMake to build a project that depends on various other projects. Everything I do is from the terminal. I did `grep -r MAKEFLAGS` in my root directory, and I didn't find anything that sets the `MAKEFLAGS=s`. I really don't understand then how it's possible that the environment is messed up. I don't think I can use that script you posted to clean the environment before every build, can I? – aaragon Aug 06 '14 at 18:58
  • `didn't find anything that sets the MAKEFLAGS=s` as I said earlier I don't quite understand the exact reason why it break the build, but it's definitely the only reason)) The diff that I've seen did not has any `s` values too, but it has extra variables like MFLAGS. –  Aug 06 '14 at 19:06
  • `I don't think I can use that script you posted to clean the environment before every build, can I?` I don't thinks I understand what you're asking exactly) You can use it by adding command: `. /clear-all.sh && your-commands-here`. Note that it's project dependent, most of the projects don't need it. –  Aug 06 '14 at 19:09
  • Thanks again. I assume you're Russian because of the name and the))) :) – aaragon Aug 06 '14 at 19:29
  • @AlejandroMarcosAragon `I assume you're Russian because of the name and the)))` heh, yep, you're right) –  Aug 06 '14 at 19:34