cmake_minimum_required(VERSION 3.30)

project(FESA VERSION 0.1.0 LANGUAGES CXX)

if(NOT MSVC)
    message(FATAL_ERROR "FESA requires the Microsoft Visual C++ compiler (MSVC v145).")
endif()

if(NOT CMAKE_VS_PLATFORM_TOOLSET STREQUAL "v145")
    message(
        FATAL_ERROR
        "FESA requires the v145 platform toolset; configured toolset is "
        "'${CMAKE_VS_PLATFORM_TOOLSET}'."
    )
endif()

if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
    message(FATAL_ERROR "FESA requires the x64 generator platform.")
endif()

if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
    message(FATAL_ERROR "FESA requires a 64-bit target.")
endif()

include(CTest)
include(cmake/FesaDependencies.cmake)

add_library(fesa_core STATIC
    src/fesa/core/version.cpp
    src/fesa/fem/dof_manager.cpp
    src/fesa/fem/gauss_rule.cpp
    src/fesa/fem/line2_shape.cpp
    src/fesa/io/abaqus/parser.cpp
    src/fesa/io/abaqus/semantic_mapper.cpp
    src/fesa/model/domain.cpp
    src/fesa/model/domain_builder.cpp
)

target_include_directories(fesa_core
    PUBLIC
        "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

target_compile_features(fesa_core PUBLIC cxx_std_20)
target_compile_options(fesa_core PRIVATE /W4 /permissive- /EHsc)

add_executable(fesa
    src/fesa/cli/main.cpp
)

target_link_libraries(fesa PRIVATE fesa_core)
target_compile_features(fesa PRIVATE cxx_std_20)
target_compile_options(fesa PRIVATE /W4 /permissive- /EHsc)

if(BUILD_TESTING)
    add_subdirectory(tests)
endif()
