2022-02-17 15:01:34 +00:00
|
|
|
project("XrandR")
|
|
|
|
cmake_minimum_required(VERSION 3.18)
|
|
|
|
|
2022-04-15 22:10:36 +00:00
|
|
|
# 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.
|
|
|
|
|
2022-02-17 15:01:34 +00:00
|
|
|
find_package(ECM REQUIRED NO_MODULE)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
|
|
|
find_package(XCB REQUIRED)
|
2022-04-15 22:10:36 +00:00
|
|
|
|
|
|
|
# There are the definitions of the libraries needed to build the executable.
|
|
|
|
|
2022-02-17 15:01:34 +00:00
|
|
|
link_libraries(${XCB_LIBRARIES})
|
|
|
|
include_directories(${X11_INCLUDE_DIR})
|
|
|
|
|
2022-04-15 22:10:36 +00:00
|
|
|
# The `list(APPEND ...` command does, well, it takes an existing string and
|
|
|
|
# append new stuff to it.
|
|
|
|
|
2022-02-17 15:01:34 +00:00
|
|
|
list(APPEND CMAKE_CXX_FLAGS "${CXXMAKE_C_FLAGS} -std=c++17 -I../src/include/ -g")
|
|
|
|
|
2022-04-15 22:10:36 +00:00
|
|
|
# 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.
|
|
|
|
|
2022-02-17 15:01:34 +00:00
|
|
|
add_executable(xrandr src/xrandr.cpp)
|
|
|
|
|
2022-04-15 22:10:36 +00:00
|
|
|
# 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.
|
|
|
|
|
2022-02-17 15:01:34 +00:00
|
|
|
target_link_libraries(xrandr ${X11_XCB_LIBRARIES})
|
2022-04-15 22:10:36 +00:00
|
|
|
|
|
|
|
|