project(lsreaderdist)
cmake_minimum_required(VERSION 2.6)

option(EXAMPLE_C "Build example of c" TRUE)
option(EXAMPLE_CXX "Build example of c++" TRUE)
option(EXAMPLE_LSDA_C "Build example of lsda c" FALSE)
option(EXAMPLE_LSDA_CXX "Build example of lsda cxx" FALSE)

include(./Macros.cmake)

add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D__CONFIG_DATA_PATH__)

if(MSVC)
    set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1")
endif(MSVC)

set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
    set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
    STRING "Choose the type of build." FORCE
    )
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
    )
else()
    message(STATUS "Current build type: '${CMAKE_BUILD_TYPE}'")
endif()

if(EXAMPLE_C)
    add_subdirectory(./lsreadercdist)
endif(EXAMPLE_C)
if(EXAMPLE_CXX)
    add_subdirectory(./lsreadercxxdist)
endif(EXAMPLE_CXX)
if(EXAMPLE_LSDA_C)
    add_subdirectory(./lsda/c)
endif()
if(EXAMPLE_LSDA_CXX)
    add_subdirectory(./lsda/cxx)
endif()

set(TEST_DATA_PATH_D3P ${CMAKE_SOURCE_DIR}/example_data/d3plot)
set(TEST_DATA_PATH_BINOUT ${CMAKE_SOURCE_DIR}/example_data/binout)
set(TEST_DATA_PATH_FEMZIP ${CMAKE_SOURCE_DIR}/example_data/z805L4plot)
set(TEST_OUTPUT_CXX ${CMAKE_SOURCE_DIR}/example_data/output_CXX)
set(TEST_OUTPUT_C ${CMAKE_SOURCE_DIR}/example_data/output_C)
set(TEST_LSDA_C ${CMAKE_SOURCE_DIR}/example_data/output_LSDA_C)
set(TEST_LSDA_CXX ${CMAKE_SOURCE_DIR}/example_data/output_LSDA_CXX)
set(TEST_LSDA_CONFIG ${CMAKE_SOURCE_DIR}/lsda/config.json)

message(STATUS "OUTPUT_CXX: '${TEST_OUTPUT_CXX}'")
message(STATUS "OUTPUT_C: '${TEST_OUTPUT_C}'")

configure_file(
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_SOURCE_DIR}/config.h"
)

