memo: CMake | Misc

Build

add_executalbe() is for building a executable program. While add_library() is for building a library.


Both the source files and header files need to be added to executable target.


(2023-11-16)

Ccache

Speed up recompilation. Docs

Usage refer to parallel101/course

1
2
3
4
5
6
7
8
9
cmake_minimum_required(VERSION 3.15)
project(hellocmake)

find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
    message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PROGRAM})
endif()