# SPDX-License-Identifier: MPL-2.0
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
# not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
# The benchmarks' driver (docs/benchmarks.md): LUNOPT's sparse SQP and IPOPT on a CUTEst problem loaded at run time.
# Never in a package: each problem's library links CUTEst (LGPL-3.0), built by run.py on the user's machine; IPOPT
# (EPL-2.0) is the user's own installation, its C interface's header used for the types and its library loaded at run
# time (--ipopt).
set(LUNOPT_IPOPT_ROOT "$ENV{CONDA_PREFIX}" CACHE PATH "Where IPOPT 3.13 or later is installed (empty: the system's)")
find_path(LUNOPT_IPOPT_INCLUDE IpStdCInterface.h HINTS "${LUNOPT_IPOPT_ROOT}/include" PATH_SUFFIXES coin-or coin
          REQUIRED)
find_library(LUNOPT_IPOPT_LIBRARY ipopt HINTS "${LUNOPT_IPOPT_ROOT}/lib" REQUIRED)

add_executable(lunopt_cutest lunopt_cutest.cpp)
target_link_libraries(lunopt_cutest PRIVATE lunopt::lunopt ${CMAKE_DL_LIBS})
target_include_directories(lunopt_cutest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(lunopt_cutest SYSTEM PRIVATE "${LUNOPT_IPOPT_INCLUDE}")
target_compile_features(lunopt_cutest PRIVATE cxx_std_23)
target_compile_definitions(lunopt_cutest PRIVATE LUNOPT_VERSION="${PROJECT_VERSION}"
                                                 LUNOPT_IPOPT_LIBRARY="${LUNOPT_IPOPT_LIBRARY}")
target_compile_options(lunopt_cutest PRIVATE -Wall -Wextra)

# Another solver, from outside this repository (extra.hpp): a CMake file of its own that adds it to lunopt_cutest.
set(LUNOPT_BENCH_EXTRA_CMAKE "" CACHE FILEPATH "A CMake file that adds another solver to the driver (extra.hpp)")
if(LUNOPT_BENCH_EXTRA_CMAKE)
    include("${LUNOPT_BENCH_EXTRA_CMAKE}")
endif()
