As a start, we create a top-level CMakeLists.txt in the root directory of the source code repository where we set the minimum CMake version, the project name, and supported languages, in this case C:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(vim LANGUAGES C)
Before adding any targets or sources, we can already set the default build type. In this case, we default to the Release configuration, which will turn on certain compiler optimizations:
if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)endif()
We also use portable install directory variables, as defined for GNU software:
include(GNUInstallDirs)set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) ...