set(DECODER_NAME http)

aux_source_directory(${PROJECT_SOURCE_DIR}/deps/toml DEPS_SRC)

add_library(${DECODER_NAME}_test SHARED http_decoder_test_plug.cpp md5.c ${DEPS_SRC})
add_dependencies(${DECODER_NAME}_test ${DECODER_NAME})
target_link_libraries(${DECODER_NAME}_test cjson-static)
set_target_properties(${DECODER_NAME}_test PROPERTIES PREFIX "")

# add_library(${DECODER_NAME}_perf SHARED http_decoder_perf_plug.cpp)
# add_dependencies(${DECODER_NAME}_perf ${DECODER_NAME})
# set_target_properties(${DECODER_NAME}_perf PROPERTIES PREFIX "")

set(TEST_RUN_DIR ${CMAKE_BINARY_DIR}/testing)

include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/deps)
include_directories(/opt/tsg/stellar/include/)
include_directories(/opt/tsg/framework/include/)
include_directories(${CMAKE_BINARY_DIR}/vendor/llhttp/include)
include_directories(${CMAKE_BINARY_DIR}/vendor/cjson/src/cjson/include)
include_directories(${PROJECT_SOURCE_DIR}/decoders/http)
include_directories(${PROJECT_SOURCE_DIR}/include/stellar)

aux_source_directory(${PROJECT_SOURCE_DIR}/deps/mempool PERF_TEST_DEP_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/deps/toml PERF_TEST_DEP_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/src PERF_TEST_DEP_SRC)

add_executable(gtest_http http_decoder_gtest.cpp ${PROJECT_SOURCE_DIR}/decoders/http/http_decoder_utils.cpp)
target_link_libraries(gtest_http gtest stellar_devel)

add_executable(http_test_main plugin_test_main.cpp)
set_target_properties(http_test_main 
    PROPERTIES 
    LINK_OPTIONS 
    "-rdynamic" 
    )
set_target_properties(http_test_main 
    PROPERTIES 
    LINK_FLAGS  
    "-rdynamic" 
    )
set(LINK_FLAGS "-rdynamic")
target_link_libraries(http_test_main gtest cjson-static stellar_devel)

add_subdirectory(test_based_on_stellar)

include(GoogleTest)
gtest_discover_tests(gtest_http)
