img

ทูลสำหรับช่วยในการ Build, Test และ Pack โปรแกรมที่เขียนด้วยภาษา C และ C++

CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.

https://cmake.org

Gitlab - Kitware

Install

brew install cmake

Project Layout

project_folder:
  hello.c
  CMakeList.txt

CMakeList.txt

cmake_minimum_required(VERSION 3.0.0)
project(c-basic VERSION 0.1.0)
add_executable(hello hello.c)

Compile

cmake --build path/to/build/folder --config Debug --target all -- -j 10

cmake will create hello executable in path/to/build/folder

Run

./path/to/build/folder/hello
> Hello, world!