CMakeLists.txt

Has to be spelled exactly: CMakeLists.txt

Refer to CMake for info on using CMake.

Notes

  • Even a blank CMakeList.txt will function but won't actually build anything.

Example

HelloWorld CMakeLists.txt Example

# Min versin cmake check
cmake_minimum_required(VERSION 3.0)

# Project name
project(HelloWorldProjectName)

# Add executable target ${PROJECT_NAME}.executable will be the
# name of the executable.
add_executable(${PROJECT_NAME}.executable hello_world_main.cpp)

Command to reproduce:

gt.sandbox.checkout.commit 65d00c5 \
&& cd "${GT_SANDBOX_REPO}/cpp/hello-world" \
&& cmd.run.announce "cmake -S . -B ./build && cd build && make && ./HelloWorldProjectName.executable"

Recorded output of command:

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vintrin/git_repos/glassthought-sandbox/cpp/hello-world/build
[100%] Built target HelloWorldProjectName.executable
Hello World!


Children
  1. CheckingFileExistence
  2. DereferencingVariableInCMakeFunction
  3. FunctionInCMak
  4. HelloWorldExample CMakeLists.txt

Backlinks