Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set project name in CMake

📅 2014-Jul-08 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake ⬩ 📚 Archive

To set the name of the project:

project(foobar)

To use the project name that you set, use ${PROJECT_NAME} variable. For example, to set the name of the executable produced:

# Produces executable named "foobar"
add_executable(
    ${PROJECT_NAME}
    src/main.cpp
    src/helper.cpp
    )

Tried with: CMake 2.8.12.2 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧