cmake_minimum_required(VERSION 3.20)

project(linuxSmartie
    VERSION 1.0
    LANGUAGES C
)

# Use C99
set(CMAKE_C_STANDARD 99)

# Collect sources
file(GLOB SOURCES
    src/*.c
)

# Define executable
add_executable(linuxSmartie ${SOURCES})

# Include directories
target_include_directories(linuxSmartie
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Compiler warnings
target_compile_options(linuxSmartie
        PRIVATE
        -O2
        -Wall
        -Wextra
        -Werror
        -Wshadow
        -Wformat=2          # replaces what -Wpedantic caught for printf
        -Wformat-security
        -fdiagnostics-color=always
)

find_package(ZLIB QUIET)

if(ZLIB_FOUND)
    target_link_libraries(linuxSmartie PRIVATE ZLIB::ZLIB)
    target_compile_definitions(linuxSmartie PRIVATE ENABLE_ZLIB)
else()
    message(STATUS "no zlib found, disabling saving logs to gz")
endif()
