Skip to content

Instantly share code, notes, and snippets.

@vladiant
Created June 6, 2021 11:55
Show Gist options
  • Save vladiant/665db795dd866f188f58e5c79dc7ff40 to your computer and use it in GitHub Desktop.
Save vladiant/665db795dd866f188f58e5c79dc7ff40 to your computer and use it in GitHub Desktop.
CMake check project or subproject
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# This is a typical pattern used by projects, to prevent
# their tests being built and run, if they are
# loaded as a sub-project
if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
else()
# turn NOT_SUBPROJECT off, in case it was already turned
# on in a parent scope:
set(NOT_SUBPROJECT OFF)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment