We will use CMake to fill the definitions in config.h with sensible values for our platform and to compile our sample source file into an executable:
- First, we define the minimum CMake version, project name, and project language:
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)project(recipe-05 CXX)
- We then define the target executable, its source file, and include directories:
add_executable(processor-info "")target_sources(processor-info PRIVATE processor-info.cpp )target_include_directories(processor-info PRIVATE ${PROJECT_BINARY_DIR} )
- We then go on to query the host system information for a number of keys:
foreach(key IN ITEMS NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES TOTAL_VIRTUAL_MEMORY AVAILABLE_VIRTUAL_MEMORY ...