Skip to content

jeffamstutz/cmake_project_commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

CMake Project Commands

Add CMake commands for project-centric builds.

Modern CMake relies on target_* commands for constructing targets with the correct property visibilities. One common structure is to define a project() for each target and always use ${PROJECT_NAME} as the target name for the target commands. In this approach, ${PROJECT_NAME} gets repeated over and over again.

CMake functions can easily deal with this repetition. Simply include cmake_project_commands.cmake to your build and use the provided commands. For each target_ command in base CMake, there is an equivalent project_ version that just assumes the target is the current value of ${PROJECT_NAME}.

For example, the following CMake:

project(myProject)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraires(${PROJECT_NAME} PRIVATE otherProject)

...would instead become:

project(myProject)
project_add_executable(main.cpp)
project_link_libraires(PRIVATE otherProject)

About

Missing CMake commands for project-centric builds

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages