опциональная генерация примеров

This commit is contained in:
2024-12-10 17:59:11 +03:00
parent 6e7ebd4027
commit d4f3383358
3 changed files with 5 additions and 13 deletions

View File

@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.20)
project({{ project_name_cmake }})
option({{ project_name | replace(" ", "_") | upper }}_BUILD_TESTS "Build {{ project_name }} tests" OFF)
option({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES "Build {{ project_name }} examples" OFF)
{% if len(examples_names) > 0 %}option({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES "Build {{ project_name }} examples" OFF)
{% endif %}
set(CMAKE_CXX_STANDARD 20)
set(default_build_type "Release")
@@ -31,11 +31,11 @@ add_library(${PROJECT_NAME} STATIC
target_include_directories(${PROJECT_NAME} PUBLIC include/)
if ({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES)
{% if len(examples_names) > 0 %}if ({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES)
message("Build examples enabled")
{% for ex in examples_names %} add_subdirectory(examples/{{ ex | replace(" ", "-") | lower }})
{% endfor %}endif()
{% endif %}
if ({{ project_name | replace(" ", "_") | upper }}_BUILD_TESTS)
message("Build tests enabled")
add_subdirectory(tests)