cmake_minimum_required(VERSION 3.10)

# set the project name
project(NotesTK)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)

set_property( GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_MODULE_PATH infra/cmake)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CODE_COVERAGE OFF CACHE BOOL "Toggle build code coverage")

if(MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
else()
    set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra")
    
    if (CODE_COVERAGE)
        if (CMAKE_COMPILER_IS_GNUCC)
            message(STATUS "Enabling code coverage")
            set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
            set(GCC_COVERAGE_LINK_FLAGS "-lgcov -fprofile-arcs")
            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
            set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
        endif()
    endif()
endif()

add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(plugins)
add_subdirectory(apps)
