Skip to content

Instantly share code, notes, and snippets.

@meehatpa
Created September 22, 2020 11:26
Show Gist options
  • Save meehatpa/f13aeb0bc9569ac42503e8bd669cfbd5 to your computer and use it in GitHub Desktop.
Save meehatpa/f13aeb0bc9569ac42503e8bd669cfbd5 to your computer and use it in GitHub Desktop.
Sample CMakeLists.txt to use add_custom_command
cmake_minimum_required(VERSION 3.16)
project(testcmake)
# Build only when gen.g gets modified
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/gen
COMMAND ${CMAKE_COMMAND} -E touch ${PROJECT_SOURCE_DIR}/gen
DEPENDS "${PROJECT_SOURCE_DIR}/gen.g"
)
add_custom_target(customtarget ALL DEPENDS gen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment