Cmake compile targets

From wikinotes

add_executable

Compiles a single executable file.

add_executable(
    compiled_program
    source.cpp
    lib/source2.cpp
    lib/source3.cpp
)

If it were run on the commandline, this might translate to something like:

g++      source.cpp lib/source2.cpp lib/sourc3.cpp  -o compiled_program  # using compiler 'gcc'
clang++  source.cpp lib/source2.cpp lib/sourc3.cpp  -o compiled_program  # using compiler 'clang'
 
# something entirely different for VScode, eclipse, ... etc...

https://cmake.org/cmake/help/v3.11/command/add_executable.html

add_library

If compilation requires a static-library. (.dll, .a)

https://cmake.org/cmake/help/v3.11/command/add_library.html

https://cmake.org/cmake/help/v3.11/command/add_library.html

target_link_libraries

Compilation requires a shared library. (.so)

https://cmake.org/cmake/help/v3.11/command/target_link_libraries.html