CMakeLists.txt is a build configuration file for CMake. There needs to be a CMakeLists.txt in the project root directory. Subdirectories can also contain CMakeLists.txt as long as the subdirectory is added in the root CMakeLists.txt.

A baseline CMakeLists.txt for a simple project is as follows:

cmake_minimum_required(VERSION 3.1.3) # cmake --version
project(ProjectName)
 
set (PROJNAME_VERSION_MAJOR 0)
set (PROJNAME_VERSION_MINOR 1)
set (PROJNAME_VERSION_PATCH 0)
set (PROJNAME_VERSION "${PROJNAME_VERSION_MAJOR}.${PROJNAME_VERSION_MINOR}.${PROJNAME_VERSION_PATCH}")
 
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
 
add_executable(projexec ${SOURCES} ${HEADERS})

For more complex projects that contain libraries, we need to create a CMakeLists.txt within each library directory with the following content:

file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
target_include_directories(libname PUBLIC ./include)
add_library(libname ${SOURCES} ${HEADERS})

And in the project root CMakeLists.txt:

# ...
add_executable(projexec ${SOURCES} ${HEADERS})
 
target_link_libraries(projexec libname)