Reputation: 27
It will only build if the CMakeLists.txt
file is in the project root. Why can't it reside in a src
subdirectory, for instance? Is there a way to change the settings so it will look there?
Upvotes: 1
Views: 3686
Reputation: 1937
By default, CLion considers the directory that includes top-level CMakeLists.txt file as a main project directory that includes all the sources. If you want to change it, you need to change CMake project root as written here: https://www.jetbrains.com/help/clion/changing-project-root-directory.html
Upvotes: 2
Reputation: 1323
That's how CMake hierarchy works, since you've created project, you should have root directory (${CMAKE_SOURCE_DIR}
variable) where placed you top-level CMake file, with project name and other project scope preferences. In case you want include additional sub directories with source code or sub projects, you should use add_subdirectory() function, it will include child CMake file to your project. Your sub directory may be placed only inside your project root directory. Look into official CMake example for better understanding.
Upvotes: 3