# SPDX-License-Identifier: Apache-2.0
# Copyright 2025 C++ Best Practices Example

cmake_minimum_required(VERSION 3.16)

# Project definition with version
project(CppBestPracticesExample 
    VERSION 1.0.0
    DESCRIPTION "Example demonstrating C++ best practices"
    LANGUAGES CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Compiler-specific options
if(MSVC)
    add_compile_options(/W4 /WX)
else()
    add_compile_options(-Wall -Wextra -Wpedantic -Werror)
endif()

# Enable debug information in debug builds
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")

# Create executable
add_executable(cpp_best_practices_example
    example_cpp_best_practices.cpp
)

# Set target properties
set_target_properties(cpp_best_practices_example PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
)

# Enable testing
enable_testing()

# Create test executable
add_executable(test_resource_manager
    test_resource_manager.cpp
)

# Set target properties for test
set_target_properties(test_resource_manager PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
)

# Add tests
add_test(NAME run_example 
         COMMAND cpp_best_practices_example)

add_test(NAME run_unit_tests
         COMMAND test_resource_manager)