You don’t execute a
CMakeLists.txt. It is read by
cmake (the root
CMaksLists.txt file), which is called by CLion. However, CLion only passes the root
CMaksLists.txt file to
cmake. Even if you call cmake yourself you would only pass this root
If you want to define targets (or anything) in other
CMaksLists.txt files located in other folders, then you must add
add_subdirectory(folder_name_that_contains_another_CMakeLists_file) to your root
CMaksLists.txt file. Only then targets in these other
CMaksLists.txt files will appear in CLion.
Note that a few things should appear in the root
CMaksLists.txt file, but not in the other ones. Particularly, the two lines below should only be in the root file
cmake_minimum_required(VERSION 3.14) # Choose the minimum cmake version project(name_of_your_project)
CLICK HERE to find out more related problems solutions.