if(NOT (CMAKE_SYSTEM_NAME STREQUAL Emscripten))
  # Boost.Math is header-only
  # Required for statistics.hpp
  find_package(Boost REQUIRED CONFIG)
endif()

file(GLOB_RECURSE PSEMEK_UTIL_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/*.hpp")
file(GLOB_RECURSE PSEMEK_UTIL_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "source/*.cpp")

psemek_add_library(psemek-util ${PSEMEK_UTIL_HEADERS} ${PSEMEK_UTIL_SOURCES})
target_include_directories(psemek-util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(psemek-util PUBLIC ${CMAKE_THREAD_LIBS_INIT} Boost::boost)

if(PSEMEK_STACKTRACE)
	target_link_libraries(psemek-util PUBLIC libbacktrace)
	target_compile_definitions(psemek-util PUBLIC "-DBOOST_STACKTRACE_USE_BACKTRACE")
	if(APPLE)
		target_compile_definitions(psemek-util PUBLIC "-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED")
	endif()
endif()

psemek_glob_tests(psemek-util tests)

