Re: [CMake] Strange search order of CMakeCache.txt
On 5. Mar, 2010, at 14:19 , Marcel Loose wrote: Hi all, I just spent an hour debugging a very strange phenomenon running CMake on Mac OS-X, which in the end turned out to be trivial, but completely unexpected for me. The problem was caused by the fact that CMake had accidentally been run once from the source directory. When running CMake in an empty binary directory it seemed to somehow fail to set CMAKE_BINARY_DIR correctly. Cause of the problem turned out to be the order in which CMake searches for the CMakeCache.txt file: first in the directory containing the CMakeLists.txt file (CMAKE_SOURCE_DIR), then in the (binary) directory that CMake is being run from (CMAKE_BINARY_DIR). Wouldn't it be more logical to start in the binary directory and then look in the source directory? Or, probably even better, completely ignore the source directory when searching for the cache file. Best regards, Marcel Loose. It is not very intuitive (but very useful) that CMake first assumes the directory argument to be a binary tree, and only then looks for a CMakeLists.txt. E.g.: mkdir -p path/to/build-tree cd path/to/build-tree cmake path/to/source-tree # now want to change some setting, don't have to remember/type source-tree path ccmake . make On the other hand, it can be quite confusing behavior if an accidental CMakeCache.txt is present in the source tree... Perhaps CMake should add a safety check and emit a warning if a cache exists in the current working directory that references the same source tree as the cache in the directory specified on the command line... Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Strange search order of CMakeCache.txt
On Fri, 2010-03-05 at 14:27 +0100, Michael Wild wrote: On 5. Mar, 2010, at 14:19 , Marcel Loose wrote: Hi all, I just spent an hour debugging a very strange phenomenon running CMake on Mac OS-X, which in the end turned out to be trivial, but completely unexpected for me. The problem was caused by the fact that CMake had accidentally been run once from the source directory. When running CMake in an empty binary directory it seemed to somehow fail to set CMAKE_BINARY_DIR correctly. Cause of the problem turned out to be the order in which CMake searches for the CMakeCache.txt file: first in the directory containing the CMakeLists.txt file (CMAKE_SOURCE_DIR), then in the (binary) directory that CMake is being run from (CMAKE_BINARY_DIR). Wouldn't it be more logical to start in the binary directory and then look in the source directory? Or, probably even better, completely ignore the source directory when searching for the cache file. Best regards, Marcel Loose. It is not very intuitive (but very useful) that CMake first assumes the directory argument to be a binary tree, and only then looks for a CMakeLists.txt. E.g.: mkdir -p path/to/build-tree cd path/to/build-tree cmake path/to/source-tree # now want to change some setting, don't have to remember/type source-tree path ccmake . make On the other hand, it can be quite confusing behavior if an accidental CMakeCache.txt is present in the source tree... Perhaps CMake should add a safety check and emit a warning if a cache exists in the current working directory that references the same source tree as the cache in the directory specified on the command line... Michael Hi Michael, I never knew you could use path/to/build-tree as argument to cmake, but re-reading the docs reveals that feature. I would definitely like to get a warning when CMake finds a cache file in what it thinks should be the source directory. It would have saved me an hour of debugging. OTOH, now that I know of this strange behaviour, I might be able to tackle these kinds of problems quicker. Best regards, Marcel Loose. ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Strange search order of CMakeCache.txt
Marcel Loose wrote: I would definitely like to get a warning when CMake finds a cache file in what it thinks should be the source directory. It would have saved me an hour of debugging. OTOH, now that I know of this strange behaviour, I might be able to tackle these kinds of problems quicker. It does say where the build files were written as the last message that is printed out cmake ../src ... -- Configuring done -- Generating done -- Build files have been written to: C:/hoffman/My Builds/src If that is what they wanted (an in source build), CMake can not warn about it. -Bill ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Strange search order of CMakeCache.txt
I recently had to help out a CMake newbie, who had run CMake in the source directory. Then he re-read the instructions on build setup for our programs, and did it the right way -- i.e. he configured a build directory for an out of source build. Problem is, if you run CMake and configure the source directory, CMake will assume you want an in-source build, even if you try and configure an out-of-source build directory. So you get this mystifying behavior. # sourcedir is 'test', in same directory as test-build cd test # source dir cmake # whoops, configured in the source directory! cd ../test-build# come to senses, go to out-of-srouce build. cmake ../test # try configuring for out of source build make # now you get a Makefile not found error! In order to get rid of the problem you have to delete CMakeCache.txt in the source directory -- at a minimum -- before you can configure the out-of-source build. I ended up going through the source code trying to get rid of CMake droppings, which are numerous! ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Strange search order of CMakeCache.txt
2010/3/5 kent williams nkwmailingli...@gmail.com: I recently had to help out a CMake newbie, who had run CMake in the source directory. Then he re-read the instructions on build setup for our programs, and did it the right way -- i.e. he configured a build directory for an out of source build. Problem is, if you run CMake and configure the source directory, CMake will assume you want an in-source build, even if you try and configure an out-of-source build directory. So you get this mystifying behavior. [...] I run into this many time with users which are not CMake aware, thus I did file a bug report: http://public.kitware.com/Bug/view.php?id=6672 Anyone wanting to try a patch for this... -- Erk Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake