cmake_minimum_required(VERSION 2.8.4)
project(ble_toys C CXX)
find_package(PkgConfig)

# Use Clang by default: http://stackoverflow.com/a/7031553/245614
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")

IF(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE Debug CACHE STRING
      "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
      FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

# Boost
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)

add_definitions(-DBOOST_ALL_DYN_LINK)

find_package(Doxygen)
if (DOXYGEN_FOUND)
    set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
    set(doxyfile ${PROJECT_BINARY_DIR}/Doxyfile)
    set(doxy_html_index_file ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)

    configure_file(
        ${doxyfile_in}
        ${doxyfile} @ONLY)

    add_custom_command(
        OUTPUT ${doxy_html_index_file}
        COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
        MAIN_DEPENDENCY ${doxyfile} ${doxyfile_in}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        COMMENT "Generating documentation" VERBATIM)

  add_custom_target(doc DEPENDS ${doxy_html_index_file} )
endif(DOXYGEN_FOUND)

add_subdirectory(ble)
add_subdirectory(apps)
add_subdirectory(test)
enable_testing()