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

FIND_PACKAGE(Threads REQUIRED)

IF(NOT TARGET Catch2)
  add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
  include(libs/Catch2/contrib/Catch.cmake)
  ENDIF()
  
  add_compile_definitions(LOGURU_WITH_STREAMS SQLITE_THREADSAFE=2)
  IF(NOT TARGET loguru)
   add_subdirectory(libs/loguru EXCLUDE_FROM_ALL)
  ENDIF()
  
  IF (NOT TARGET CLI11)
  set(CLI11_TESTING OFF CACHE BOOL "disable testing")
  add_subdirectory(libs/CLI11 EXCLUDE_FROM_ALL)
  ENDIF()
  
  IF (NOT TARGET yaml-cpp)
  set(YAML_CPP_BUILD_TESTS OFF CACHE INTERNAL "")
  set(YAML_CPP_BUILD_TOOLS OFF CACHE INTERNAL "")
  set(YAML_CPP_BUILD_CONTRIB OFF CACHE INTERNAL "")
  set(YAML_CPP_INSTALL OFF CACHE INTERNAL "")
  add_subdirectory(libs/yaml-cpp EXCLUDE_FROM_ALL)
ENDIF()
# FIND_PACKAGE(yaml-cpp REQUIRED)

  
  IF (NOT TARGET curlcpp)
  #   set(CLI11_TESTING OFF CACHE BOOL "disable testing")
    add_subdirectory(libs/curlcpp EXCLUDE_FROM_ALL)
  ENDIF()
  
  # IF (NOT TARGET rest-client)
  #   set(BUILD_SHARED_LIBS OFF CACHE BOOL "disable testing")
  #   add_subdirectory(libs/rest-client EXCLUDE_FROM_ALL)
  # ENDIF()
  
  
  # build with CC=clang-15 CXX=clang++-15 cmake -D CMAKE_BUILD_TYPE=DEBUG ..
  
  
  add_library(kubecontrol STATIC
  include/kubecontrol/kubecontrol.hpp
  src/kubecontrol/kubecontrol.cpp

    )


target_link_libraries(kubecontrol
yaml-cpp
curlcpp
loguru
pthread
)
target_include_directories(kubecontrol PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  src)


 

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

IF (${TEST_KUBECONTROL_LIBRARY})
  
  

  add_executable(test_kubecontrol tests/test_kubecontrol.cpp)
  target_link_libraries(test_kubecontrol Catch2::Catch2 kubecontrol loguru)
  catch_discover_tests(test_kubecontrol)


  
  
ENDIF()
