2.1.3. CMake build with library (documented)

Now, let’s document the CMakeLists.txt so that it’s readable.

 1CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
 2
 3# Top level project / solution.
 4PROJECT(greeting)
 5
 6# Create Enlglish library
 7ADD_LIBRARY(
 8    greeting_en_lib
 9    greeting_en.c
10)
11
12# Create French library
13ADD_LIBRARY(
14    greeting_fr_lib
15    greeting_fr.c
16)
17
18# Create Spanish library
19ADD_LIBRARY(
20    greeting_es_lib
21    greeting_es.c
22)
23
24# Declare English Executable
25ADD_EXECUTABLE(
26    greeting_en
27    main.c
28)
29# Ensure English Executable links to English Library.
30TARGET_LINK_LIBRARIES(greeting_en greeting_en_lib)
31
32# Declare French Executable
33ADD_EXECUTABLE(
34    greeting_fr
35    main.c
36)
37# Ensure French Executable links to French Library.
38TARGET_LINK_LIBRARIES(greeting_fr greeting_fr_lib)
39
40# Declare Spanish Executable
41ADD_EXECUTABLE(
42    greeting_es
43    main.c
44)
45# Ensure Spanish Executable links to Spanish Library.
46TARGET_LINK_LIBRARIES(greeting_es greeting_es_lib)

Rest all is same as CMake build with library