cmake_minimum_required(VERSION 3.15)
project("jsonrpccxx issie"
  VERSION 0.1
  LANGUAGES CXX)


include(FetchContent)

find_package(Threads REQUIRED)

# --

FetchContent_Declare(jsonrpccxx
  GIT_REPOSITORY https://github.com/jsonrpcx/json-rpc-cxx )

FetchContent_GetProperties(jsonrpccxx)
if(NOT jsoncprcxx_POPULATED)
  FetchContent_Populate(jsonrpccxx)
  add_subdirectory(${jsonrpccxx_SOURCE_DIR} ${jsonrpccxx_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# --

FetchContent_Declare(json
  GIT_REPOSITORY https://github.com/nlohmann/json.git
  GIT_TAG v3.7.3)

FetchContent_GetProperties(json)
if(NOT json_POPULATED)
  FetchContent_Populate(json)
  add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# --

FetchContent_Declare(cpphttplib
  GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git)

FetchContent_GetProperties(cpphttplib)
if(NOT cpphttplib_POPULATED)
  FetchContent_Populate(cpphttplib)
  add_subdirectory(${cpphttplib_SOURCE_DIR} ${cpphttplib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# --


# Configure the language standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Warning options for the compiler
string(
  APPEND _warning_opts
  "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-Wall;-Wextra;-Weffc++;-Werror;>"
  "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wthread-safety;-Wpedantic;>"
  "$<$<CXX_COMPILER_ID:GNU>:-pedantic;-pedantic-errors;>"
  )

add_compile_options("${_warning_opts}")


add_subdirectory(src)
