cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
project (SimCore VERSION 0.1.0 LANGUAGES CXX C)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
include(defaultOptions)

IF(NOT TARGET Catch2)
  add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
  include(libs/Catch2/contrib/Catch.cmake)
ENDIF()

IF(NOT TARGET crossguid)
set(CROSSGUID_TESTS OFF CACHE INTERNAL "")

add_subdirectory(libs/crossguid EXCLUDE_FROM_ALL)
ENDIF()

IF(NOT TARGET eigen)
set(EIGEN_BUILD_DOC OFF CACHE INTERNAL "")
add_subdirectory(libs/eigen EXCLUDE_FROM_ALL)
ENDIF()

IF(NOT TARGET GeographicLib)
#   configure_file(${PROJECT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
  add_subdirectory(libs/geographiclib EXCLUDE_FROM_ALL)
ENDIF()

IF(NOT TARGET whisper-com)
add_subdirectory(libs/whisper-com EXCLUDE_FROM_ALL)
ENDIF()

protobuf_generate_cpp(PROTO_PATH  include/SimCore/Messages/Protos CPP_PATH include/SimCore/Messages/Protos HPP_PATH include/SimCore/Messages/Protos)



add_library(SimCore STATIC
 
    include/SimCore/Messages/Track.hpp
    src/SimCore/Messages/Track.cpp

    include/SimCore/Messages/RadarTrack.hpp
    src/SimCore/Messages/RadarTrack.cpp

    include/SimCore/Messages/ESMTrack.hpp
    src/SimCore/Messages/ESMTrack.cpp

    include/SimCore/Messages/SensorTrack.hpp
    src/SimCore/Messages/SensorTrack.cpp

    include/SimCore/Messages/SimTrack.hpp
    src/SimCore/Messages/SimTrack.cpp
    include/SimCore/Messages/Protos/SimTrack.pb.cc  

    include/SimCore/Messages/Emission.hpp
    src/SimCore/Messages/Emission.cpp

    

    include/SimCore/Messages/Protos/Track.pb.cc  
    include/SimCore/Messages/Protos/GeocentricPosition.pb.cc  
    include/SimCore/Messages/Protos/Identifier.pb.cc  

    include/SimCore/Messages/Protos/RadarTrack.pb.cc  
    include/SimCore/Messages/Protos/ESMTrack.pb.cc  
    include/SimCore/Messages/Protos/ESMData.pb.cc  


    include/SimCore/Messages/Protos/SensorTrack.pb.cc  

    include/SimCore/Messages/Protos/GroundTruthTrack.pb.cc  

    include/SimCore/Messages/GroundThruthTrack.hpp
    src/SimCore/Messages/GroundThruthTrack.cpp

    include/SimCore/data.hpp


    include/SimCore/Position.hpp
    src/SimCore/Position.cpp

    include/SimCore/Orientation.hpp
    src/SimCore/Orientation.cpp

    include/SimCore/EulerConversion.hpp
    src/SimCore/EulerConversion.cpp

    include/SimCore/SafeMap.hpp
    src/SimCore/SafeMap.cpp

    include/SimCore/Identifier.hpp
    src/SimCore/Identifier.cpp

    include/SimCore/IdentifierMaker.hpp
    src/SimCore/IdentifierMaker.cpp

    include/SimCore/UtilFunctions.hpp
    src/SimCore/UtilFunctions.cpp
  
    include/SimCore/Templates/Sensor.hpp
    src/SimCore/Templates/Sensor.cpp

    include/SimCore/Templates/Entity.hpp
    src/SimCore/Templates/Entity.cpp

    )


target_link_libraries(SimCore
whisper-com
loguru
libprotobuf
eigen
GeographicLib
crossguid
)
# add_dependencies(SimCore protoc)

target_include_directories(SimCore PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  src)


#   add_executable(main
  
#     src/main.cpp

    
#     )
    

#     target_link_libraries(main 
#     Gateway
#     CLI11
#     loguru
#     )
#     target_include_directories(main PUBLIC
#     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
#     $<INSTALL_INTERFACE:include>
#     src)
    

#
# Everything TEST related
#
option(TEST_SIMCORE_LIBRARY "Turn running of application template specific tests off" ON)

IF (${TEST_SIMCORE_LIBRARY})
  
  add_executable(test_PositionClass tests/test_PositionClass.cpp)
  target_link_libraries(test_PositionClass Catch2::Catch2 SimCore eigen loguru)
  catch_discover_tests(test_PositionClass)

  add_executable(test_OrientationClass tests/test_OrientationClass.cpp)
  target_link_libraries(test_OrientationClass Catch2::Catch2 SimCore eigen loguru)
  catch_discover_tests(test_OrientationClass)

  

  add_executable(test_GroundTruthTrackClass tests/test_GroundTruthTrackClass.cpp)
  target_link_libraries(test_GroundTruthTrackClass Catch2::Catch2 SimCore eigen loguru)
  catch_discover_tests(test_GroundTruthTrackClass)

  add_executable(test_SimTrack tests/test_SimTrack.cpp)
  target_link_libraries(test_SimTrack Catch2::Catch2 SimCore eigen loguru)
  catch_discover_tests(test_SimTrack)
  
  
  add_executable(test_RadarTrackClass tests/test_RadarTrackClass.cpp)
  target_link_libraries(test_RadarTrackClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_RadarTrackClass)
  
  add_executable(test_SafeMap tests/test_SafeMap.cpp)
  target_link_libraries(test_SafeMap Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_SafeMap)

  add_executable(test_IdentifierClass tests/test_IdentifierClass.cpp)
  target_link_libraries(test_IdentifierClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_IdentifierClass)


  add_executable(test_IdentifierList tests/test_IdentifierList.cpp)
  target_link_libraries(test_IdentifierList Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_IdentifierList)

  add_executable(test_UtilFunctions tests/test_UtilFunctions.cpp)
  target_link_libraries(test_UtilFunctions Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_UtilFunctions)

  add_executable(test_SensorClass tests/test_SensorClass.cpp)
  target_link_libraries(test_SensorClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_SensorClass)

  add_executable(test_EntityClass tests/test_EntityClass.cpp)
  target_link_libraries(test_EntityClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_EntityClass)

  add_executable(test_Trackstore tests/test_Trackstore.cpp)
  target_link_libraries(test_Trackstore Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_SensorClass)
 
  add_executable(test_DataClass tests/test_DataClass.cpp)
  target_link_libraries(test_DataClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_DataClass)

  add_executable(test_TrackClass tests/test_TrackClass.cpp)
  target_link_libraries(test_TrackClass Catch2::Catch2 SimCore loguru)
  catch_discover_tests(test_TrackClass)

ENDIF()
