cmake_minimum_required(VERSION "3.1")
project(Or24DGE)

include_directories(src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Isrc -std=c++20")
set(CMAKE_MODULE_PATH ".;${CMAKE_MODULE_PATH}")

find_package(CapnProto REQUIRED)
find_package(gflags REQUIRED)
include_directories(${CAPNP_INCLUDE_DIRS})
add_definitions(${CAPNP_DEFINITIONS})
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS src/game.capnp)
cmake_path(GET CAPNP_HDRS PARENT_PATH PARENT_DIR)
include_directories(${PARENT_DIR})

# Basic infra
add_library(log                            src/log.cpp)
add_library(game                           src/game.cpp ${CAPNP_SRCS} ${CAPNP_HDRS})
target_link_libraries(game                 ${CAPNP_LIBRARIES})
add_library(payoff_matrix                  src/payoff_matrix.cpp)
add_library(sf_strategy                    src/sf_strategy.cpp)
add_library(treeplex                       src/treeplex.cpp)
add_library(treeplex_vector                src/treeplex_vector.cpp)

# Correlation infra
add_library(correlated_representation      src/correlated_representation)
add_library(vsf_correlated_representation  src/vsf_correlated_representation)
add_library(tf_decomposition               src/tf_decomposition)

# DGFs
add_library(treeplex_regularizer           src/treeplex_regularizer.cpp)
add_library(dilated_entropy_regularizer    src/dilated_entropy_regularizer.cpp)
add_library(global_entropy_regularizer     src/global_entropy_regularizer.cpp)
add_library(scaled_ext_regularizer         src/scaled_ext_regularizer.cpp)

# Optimization algorithms
add_library(egt                            src/egt.cpp)
add_library(mirror_prox                    src/mirror_prox.cpp)

# Solver executables
add_executable(nfcce                       src/nfcce.cpp)
add_executable(mirror_prox_solver          src/mirror_prox_solver.cpp)
add_executable(egt_solver                  src/egt_solver.cpp)

target_include_directories(nfcce PRIVATE ${GFLAGS_INCLUDE_DIR})
target_link_libraries(nfcce
    PRIVATE scaled_ext_regularizer
            game
            log
            correlated_representation
            vsf_correlated_representation
            tf_decomposition
            treeplex
            treeplex_vector
            payoff_matrix
            gflags
            sf_strategy
            ${CAPNP_LIBRARIES}
)
target_include_directories(mirror_prox_solver PRIVATE ${GFLAGS_INCLUDE_DIR})
target_link_libraries(mirror_prox_solver
    PRIVATE scaled_ext_regularizer
            game
            log
            treeplex
            treeplex_vector
            payoff_matrix
            gflags
            sf_strategy
            mirror_prox
            dilated_entropy_regularizer
            global_entropy_regularizer
            ${CAPNP_LIBRARIES}
)
target_include_directories(egt_solver PRIVATE ${GFLAGS_INCLUDE_DIR})
target_link_libraries(egt_solver
    PRIVATE scaled_ext_regularizer
            game
            log
            treeplex
            treeplex_vector
            payoff_matrix
            gflags
            sf_strategy
            egt
            dilated_entropy_regularizer
            global_entropy_regularizer
            ${CAPNP_LIBRARIES}
)
