conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.25k stars 980 forks source link

[bug] Conan can't find cmake to build sdl2_image on mac os x 10.14.6 #7147

Open Kintawesar opened 4 years ago

Kintawesar commented 4 years ago

Environment Details (include every applicable attribute)

Steps to reproduce (Include if Applicable)

sdl2_image/2.0.5@bincrafters/stable: Calling build() /bin/sh: cmake: command not found

ERROR: sdl2_image/2.0.5@bincrafters/stable: Error in build() method, line 105 cmake.configure(build_dir='build') ConanException: Error 127 while executing cd 'build' && cmake -G "Unix Makefiles"

CMake Error at build/conan.cmake:402 (message): Conan install failed='1' Call Stack (most recent call first): build/conan.cmake:497 (conan_cmake_install) cmake/Conan.cmake:16 (conan_cmake_run) CMakeLists.txt:76 (run_conan)

Logs (Executed commands with output) (Include/Attach if Applicable)

Also, attach full log build.log

jgsogo commented 4 years ago

Hi, @Kintawesar

A quick question: how are you running CMake? Can you share the command you are typing?

Thanks!

Kintawesar commented 4 years ago

Hi, @jgsogo thanks for answer! I am using QtCreater IDE for run and build cmake and it's prints these command:

Running /usr/local/Cellar/cmake/3.17.3/bin/cmake /Users/kirillprohorenkov/Documents/Projects/cpp_starter_project '-GCodeBlocks - Unix Makefiles' -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_C_COMPILER:STRING=/usr/bin/clang -DCMAKE_PREFIX_PATH:STRING= -DCPP_STARTER_USE_SDL:BOOL=ON -DENABLE_TESTING:BOOL=OFF in /Users/kirillprohorenkov/Documents/Projects/cpp_starter_project/build

and get an error.

But after your message I've tried to run cmake by hand like this:

cd build && cmake /Users/kirillprohorenkov/Documents/Projects/cpp_starter_project '-GCodeBlocks - Unix Makefiles' -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_C_COMPILER:STRING=/usr/bin/clang -DCMAKE_PREFIX_PATH:STRING= -DCPP_STARTER_USE_SDL:BOOL=ON -DENABLE_TESTING:BOOL=OFF  ../

And to my suprise conan found cmake and built the library.

jgsogo commented 4 years ago

It seems QtCreator is removing cmake from the path when calling from inside the IDE. I've read some issues on Internet about QtCreator and CMake, it looks like the IDE can define its own version of CMake and maybe that's the reason why it removes it from the PATH: to have control over the version used.

I think you will get more help in some related QtCreator forum.

Does execute_process(COMMAND cmake --version) works in a CMakeLists.txt file when called from QtCreator? Maybe, then the extra python subprocess being called (and cmake from another subprocess inside python) is the problem. Please, report back, but I'm not sure if we can add something to those calls to keep cmake in the PATH.

Kintawesar commented 4 years ago

Yes, it's looks like QtCreator removes cmake from PATH. I've tried to perform execute_process(COMMAND cmake --version) in CMakeLists.txt

and it is prints nothing.

So I think to ask this in QtCreator forum is a good idea, I will do it. Interesting, does similar problem exist in other IDE, CLion for instance?

jgsogo commented 4 years ago

If you open an issue somewhere in the QtCreator forums, can you post the URL here? It may help someone with the same issue if they arrive here in the future.

This is something to check for other CMake-based IDEs, probably we should add a note with the findings to the cmake-conan project.

Thanks!

Kintawesar commented 4 years ago

Sure, here is the link to qt forum https://forum.qt.io/topic/115601/qtcreator-and-call-conan-inside-the-ide-cmake-command-not-found

unfortunately, only one workaround I was able to find - clear build folder and run cmake by hand as I mentioned above