################################################################################
# CSG Parser
################################################################################
add_library(csg)

target_sources(csg PRIVATE
  src/csg/impl/parser.cpp
  src/csg/impl/levelset_3d.cpp
  src/csg/impl/levelset_2d.cpp
  src/csg/impl/csg.cpp
  )

target_include_directories(csg PRIVATE
  ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/PEGTL/include)

target_link_libraries(csg PRIVATE stdc++fs)

target_compile_features(csg PRIVATE cxx_std_17)

SET(catch2_dir ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/Catch2)

if(NOT EXISTS "${catch2_dir}/CMakeLists.txt")
  message(FATAL_ERROR "File ${catch2_dir}/CMakeLists.txt does not exist!  The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

add_subdirectory(${catch2_dir} ${CMAKE_CURRENT_BINARY_DIR}/catch_build)
list(APPEND CMAKE_MODULE_PATH "${catch2_dir}/contrib/")

include(CTest)
include(Catch)
