cmake_minimum_required(VERSION 3.16)
project(allowid VERSION 1.0.0 LANGUAGES C CXX)

find_package(CURL REQUIRED)

add_library(allowid src/allowid.c)
target_include_directories(allowid PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_link_libraries(allowid PUBLIC CURL::libcurl)
set_target_properties(allowid PROPERTIES C_STANDARD 99 PUBLIC_HEADER "include/allowid.h;include/allowid.hpp")
target_compile_definitions(allowid PRIVATE _POSIX_C_SOURCE=200809L _DEFAULT_SOURCE)

option(ALLOWID_EXAMPLES "Build the conformance programs" OFF)
if(ALLOWID_EXAMPLES)
  add_executable(conformance examples/conformance.c)
  target_link_libraries(conformance allowid)
  add_executable(conformance_cpp examples/conformance.cpp)
  target_link_libraries(conformance_cpp allowid)
  set_target_properties(conformance_cpp PROPERTIES CXX_STANDARD 17)
endif()

install(TARGETS allowid ARCHIVE DESTINATION lib LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include)
