cmake_minimum_required(VERSION 2.6)
project(stmpct)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")

include(FindEmscripten)

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)

set(BUILD_CPP_LIBRARY 1)
if (EMSCRIPTEN_FOUND)
  set(BUILD_JS_LIBRARY 1)
else()
  set(BUILD_JS_LIBRARY 0)
endif()

set(CPACK_PACKAGE_NAME "streaming_percentiles")
set(CPACK_PACKAGE_VENDOR "Steven Engelhardt")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Implementations of various streaming percentile algorithms")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
if (BUILD_CPP_LIBRARY)
  list(APPEND CPACK_COMPONENTS_ALL cpp)
endif()
if (BUILD_JS_LIBRARY)
  list(APPEND CPACK_COMPONENTS_ALL js)
endif()
if (WIN32)
  # Default generator on Win32 is MSI; we prefer ZIP
  set(CPACK_GENERATOR "ZIP")
endif()
include(CPack)

enable_testing()

if (BUILD_CPP_LIBRARY)
  add_subdirectory(cpp)
endif()
if (BUILD_JS_LIBRARY)
  add_subdirectory(js)
endif()
