cmake_minimum_required(VERSION 3.10)
project(MyExperiment)

# Set the path to your XGBoost and FASTERFILTER libraries
set(XGBOOST_PATH ${CMAKE_SOURCE_DIR}/../thirdparty/xgboost)
set(FASTERFILTER_PATH ${CMAKE_SOURCE_DIR}/../thirdparty/fastfilter_cpp)

# Include XGBoost headers
include_directories(${XGBOOST_PATH}/include)

# Include FASTERFILTER headers
include_directories(${FASTERFILTER_PATH}/src)
include_directories(${FASTERFILTER_PATH}/src/bloom)

# Set compiler flags for optimization
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG -std=c++17 -fno-strict-aliasing -Wall")

# Check architecture and set additional flags
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()

# Add the executable for the experiment
## Preprocess
add_executable(csv2bin ${CMAKE_SOURCE_DIR}/preprocess/csv2bin.cpp)
## XGBoost
add_executable(train_xgboost ${CMAKE_SOURCE_DIR}/xgboost/train_xgboost.cpp)
target_link_libraries(train_xgboost ${XGBOOST_PATH}/lib/libxgboost.so)
## Bloom filter
add_executable(construct_bloom ${CMAKE_SOURCE_DIR}/bloom/construct_bloom.cpp)
add_executable(test_bloom ${CMAKE_SOURCE_DIR}/bloom/test_bloom.cpp)
## PLBF
add_executable(construct_plbf ${CMAKE_SOURCE_DIR}/plbf/construct_plbf.cpp)
add_executable(test_plbf ${CMAKE_SOURCE_DIR}/plbf/test_plbf.cpp)
target_link_libraries(construct_plbf ${XGBOOST_PATH}/lib/libxgboost.so)
target_link_libraries(test_plbf ${XGBOOST_PATH}/lib/libxgboost.so)
## DisjointAdaBF
add_executable(construct_disjointadabf ${CMAKE_SOURCE_DIR}/disjointadabf/construct_disjointadabf.cpp)
add_executable(test_disjointadabf ${CMAKE_SOURCE_DIR}/disjointadabf/test_disjointadabf.cpp)
target_link_libraries(construct_disjointadabf ${XGBOOST_PATH}/lib/libxgboost.so)
target_link_libraries(test_disjointadabf ${XGBOOST_PATH}/lib/libxgboost.so)
## SandwichedLBF
add_executable(construct_sandwichedlbf ${CMAKE_SOURCE_DIR}/sandwichedlbf/construct_sandwichedlbf.cpp)
add_executable(test_sandwichedlbf ${CMAKE_SOURCE_DIR}/sandwichedlbf/test_sandwichedlbf.cpp)
target_link_libraries(construct_sandwichedlbf ${XGBOOST_PATH}/lib/libxgboost.so)
target_link_libraries(test_sandwichedlbf ${XGBOOST_PATH}/lib/libxgboost.so)
## CLBF
add_executable(construct_clbf ${CMAKE_SOURCE_DIR}/clbf/construct_clbf.cpp)
add_executable(test_clbf ${CMAKE_SOURCE_DIR}/clbf/test_clbf.cpp)
target_link_libraries(construct_clbf ${XGBOOST_PATH}/lib/libxgboost.so)
target_link_libraries(test_clbf ${XGBOOST_PATH}/lib/libxgboost.so)

## HABF
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__SSE4_2__")
set(HABF_PATH ${CMAKE_SOURCE_DIR}/../thirdparty/HashAdaptiveBF)
include_directories(${HABF_PATH})
include_directories(${HABF_PATH}/util)
include_directories(${HABF_PATH}/util/cityhash)
include_directories(${HABF_PATH}/util/murmurhash)
set(HABF_SOURCES
    ${HABF_PATH}/util/hashutil.cpp
    ${HABF_PATH}/util/cityhash/city.cc
    ${HABF_PATH}/util/murmurhash/MurMurHash.cpp
)
add_executable(construct_and_test_habf ${CMAKE_SOURCE_DIR}/habf/construct_and_test_habf.cpp)
target_sources(construct_and_test_habf PRIVATE ${HABF_SOURCES})
