Added a lot of commentary into CMakeList.

This is just that I added a lot of comments to each new command in the CMakeList
file, because if I ever have to re-use this obscure and infrequently used skill,
I'll have a record written in my own words.
This commit is contained in:
Elf M. Sternberg 2022-04-15 15:10:36 -07:00
parent 0e6fb46b96
commit f821d87ba3
1 changed files with 29 additions and 1 deletions

View File

@ -1,15 +1,43 @@
project("XrandR") project("XrandR")
cmake_minimum_required(VERSION 3.18) cmake_minimum_required(VERSION 3.18)
# This is a small experiment in figuring out which compilers I want to use for
# the complition. There's no reason to use Clang over GCC, but I was curious how
# you specified that in the configuration.
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
# Packages are libraries that provide definitions for how to compile
# well-known packages. The XCB package is often installed someplace
# peculiar, and the ECM (Extra CMake Modules) package knows how to
# find it, but there are no modules to import from it, just the finder.
find_package(ECM REQUIRED NO_MODULE) find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(XCB REQUIRED) find_package(XCB REQUIRED)
# There are the definitions of the libraries needed to build the executable.
link_libraries(${XCB_LIBRARIES}) link_libraries(${XCB_LIBRARIES})
include_directories(${X11_INCLUDE_DIR}) include_directories(${X11_INCLUDE_DIR})
# The `list(APPEND ...` command does, well, it takes an existing string and
# append new stuff to it.
list(APPEND CMAKE_CXX_FLAGS "${CXXMAKE_C_FLAGS} -std=c++17 -I../src/include/ -g") list(APPEND CMAKE_CXX_FLAGS "${CXXMAKE_C_FLAGS} -std=c++17 -I../src/include/ -g")
# This is the final executable and the list of source files that are responsible
# for building that executable. There can be multiple executables, and it can be
# possible to describe which one you want from the command line.
add_executable(xrandr src/xrandr.cpp) add_executable(xrandr src/xrandr.cpp)
# Define the libraries that are necessary to link a binary. The link happens
# only if it's a target mentioned in `add_executable()` (TK: Are there others
# that provide executables?) Note that this has to come *after* the executable
# target is provided, or CMake will complain that the target hasn't been found.
target_link_libraries(xrandr ${X11_XCB_LIBRARIES}) target_link_libraries(xrandr ${X11_XCB_LIBRARIES})