cmake_minimum_required(VERSION 3.20)

project(FESA VERSION 0.1.0 LANGUAGES CXX)

file(GLOB_RECURSE FESA_CORE_SOURCES CONFIGURE_DEPENDS
  "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
)

add_library(fesa_core STATIC ${FESA_CORE_SOURCES})
target_include_directories(fesa_core PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_compile_features(fesa_core PUBLIC cxx_std_17)

enable_testing()

add_executable(fesa_tests tests/test_main.cpp)
target_link_libraries(fesa_tests PRIVATE fesa_core)
target_compile_definitions(fesa_tests PRIVATE FESA_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")

add_executable(fesa_core_module_tests tests/test_core_module_includes.cpp)
target_link_libraries(fesa_core_module_tests PRIVATE fesa_core)

add_executable(fesa_math_module_tests tests/test_math_module_includes.cpp)
target_link_libraries(fesa_math_module_tests PRIVATE fesa_core)

add_executable(fesa_io_module_tests tests/test_io_module_includes.cpp)
target_link_libraries(fesa_io_module_tests PRIVATE fesa_core)
target_compile_definitions(fesa_io_module_tests PRIVATE FESA_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")

if(MSVC)
  target_compile_options(fesa_core PRIVATE /W4 /permissive-)
  target_compile_options(fesa_tests PRIVATE /W4 /permissive-)
  target_compile_options(fesa_core_module_tests PRIVATE /W4 /permissive-)
  target_compile_options(fesa_math_module_tests PRIVATE /W4 /permissive-)
  target_compile_options(fesa_io_module_tests PRIVATE /W4 /permissive-)
else()
  target_compile_options(fesa_core PRIVATE -Wall -Wextra -Wpedantic)
  target_compile_options(fesa_tests PRIVATE -Wall -Wextra -Wpedantic)
  target_compile_options(fesa_core_module_tests PRIVATE -Wall -Wextra -Wpedantic)
  target_compile_options(fesa_math_module_tests PRIVATE -Wall -Wextra -Wpedantic)
  target_compile_options(fesa_io_module_tests PRIVATE -Wall -Wextra -Wpedantic)
endif()

add_test(NAME fesa_tests COMMAND fesa_tests)
add_test(NAME fesa_core_module_tests COMMAND fesa_core_module_tests)
add_test(NAME fesa_math_module_tests COMMAND fesa_math_module_tests)
add_test(NAME fesa_io_module_tests COMMAND fesa_io_module_tests)
