build with cmake - RawIron/learn-cpp GitHub Wiki
build
- run cmake from within the build directory
- generate the Makefile with cmake ..
- use make to build a target
cd build
cmake .. -DCMAKE_BUILD_TYPE=RELWITHDEBINFO
make collector
install
- configure CMAKE_INSTALL_PREFIX
cmake .. -DCMAKE_INSTALL_PREFIX=${PROJECT_HOME}/src/bin
- install all
make install
- only install the collector component
cmake -DCOMPONENT=collector -P ./cmake_install.cmake
run tests
choose a compiler
It can not be changed after the first cmake run. If you want to change the compiler again run rm -rf build to clean the build files.
CC=gcc CXX=g++ cmake ..
# or
CC=clang CXX=clang++ cmake ..
debug
cmake .. -DCMAKE_BUILD_TYPE=DEBUG
profile
static code analysis: lint etc.
print the compile commands
to see if the flags are correct
- the compiler flags
- the pre-processor flags (-D)
- the include flags (-I)
make VERBOSE=1 collector