![]() Which will do exactly the same thing as (1), but without the reliance on the current working directory.ĬMake puts all of its outputs in the build tree by default, so unless you are liberally using $ requires an out of source build." ![]() If your current directory is already the build folder.įor CMake 3.13 or later, use these options to set the source and build folders cmake -B/path/to/my/build/folder -S/path/to/my/source/folderįor older CMake, use some undocumented options to set the source and build folders: cmake -B/path/to/my/build/folder -H/path/to/my/source/folder Once you've created it, cmake remembers where the source folder is - so you can rerunĬmake on the build tree with cmake /path/to/my/build/folder Which will cause cmake to generate a build tree in /path/to/my/build/folder for the source tree in /path/to/my/source/folder. There are a couple of ways you can create an out of source build.ĭo what you were doing, run cd /path/to/my/build/folder It sounds like you want an out of source build. Except for very special circumstances, you should treat all those listed under "Variables that Provide Information" as read-only inside CMakeLists. If you look at CMake documentation, you'll see variables partitioned into semantic sections. And try to express them relative to CMAKE_BINARY_DIR, CMAKE_CURRENT_BINARY_DIR, PROJECT_BINARY_DIR etc. Once you have this working, you can look at where CMake puts things by default, and only if you're not satisfied with the default locations (such as the default value of EXECUTABLE_OUTPUT_PATH), modify only those you need. Then remove all the set() commands and do: cd Compile & rm -rf *Īs long as you're outside of the source directory when running CMake, it will not modify the source directory unless your CMakeList explicitly tells it to do so. Treat these as read-only.įirst remove the existing problematic cache file from the src directory: cd src You should definitely not modify CMAKE_BINARY_DIR or CMAKE_CACHEFILE_DIR. There's little need to set all the variables you're setting.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |