cmake_minimum_required(VERSION 3.20)
project(bitbybit_occt_history LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT OCCT_DIR)
  message(FATAL_ERROR "OCCT_DIR must point to an Emscripten OCCT build containing OpenCASCADEConfig.cmake")
endif()

find_package(OpenCASCADE REQUIRED CONFIG PATHS "${OCCT_DIR}" NO_DEFAULT_PATH)

add_executable(bitbybit_occt_history occt_history.cpp)
target_include_directories(bitbybit_occt_history PRIVATE "${OCCT_DIR}/include/opencascade")
target_link_libraries(bitbybit_occt_history PRIVATE TKDESTEP TKXSBase TKDE TKBO TKBRep TKTopAlgo TKPrim TKShHealing TKGeomAlgo TKGeomBase TKG3d TKG2d TKMath TKernel)
target_compile_options(bitbybit_occt_history PRIVATE -fexceptions -O2)
target_link_options(bitbybit_occt_history PRIVATE
  --bind
  -fexceptions
  -sMODULARIZE=1
  -sEXPORT_ES6=1
  -sENVIRONMENT=web,worker,node
  -sALLOW_MEMORY_GROWTH=1
  -sINITIAL_MEMORY=134217728
  -sMAXIMUM_MEMORY=2147483648
  -sNO_EXIT_RUNTIME=1
)
set_target_properties(bitbybit_occt_history PROPERTIES OUTPUT_NAME "bitbybit-occt-history")
