From 995da3f86421bf7149a966aed70fbde9fe764449 Mon Sep 17 00:00:00 2001 From: Olivier LDff Date: Mon, 16 Aug 2021 10:24:46 +0200 Subject: [PATCH] Create target "format" by default only if yaml-cpp is main cmake project --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b230b9e6d..f367eff67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ cmake_dependent_option(YAML_CPP_INSTALL cmake_dependent_option(YAML_MSVC_SHARED_RT "MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON "MSVC" OFF) +cmake_dependent_option(YAML_CPP_ENABLE_FORMAT + "Enable format target" ON + "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) set(yaml-cpp-type STATIC) set(yaml-cpp-label-postfix "static") @@ -165,7 +168,7 @@ if(YAML_CPP_BUILD_TOOLS) add_subdirectory(util) endif() -if (YAML_CPP_CLANG_FORMAT_EXE) +if (YAML_CPP_ENABLE_FORMAT AND YAML_CPP_CLANG_FORMAT_EXE) add_custom_target(format COMMAND clang-format --style=file -i $ COMMAND_EXPAND_LISTS