cmake_minimum_required(VERSION 3.25)

project(osc VERSION 0.9.0 LANGUAGES CXX C)

option(BUILD_TESTING            "Build test suites"                                     ON)
option(OSC_BUILD_DOCS           "Build OpenSim Creator's documentation"                 OFF)
option(OSC_CONFIGURE_PACKAGING  "Configure the build to support installation/packaging" ON)
option(OSC_STRICT_ABI_CHECKS    "Run binary compatibility tests"                        OFF)
set   (OSC_VENV "" CACHE PATH   "Path to a Python virtual environment (.venv) the build must use for anything Python-related")

if(OSC_VENV)
    # If applicable, ensure `Python_EXECUTABLE` points to the provided venv.
    include(third_party/opynsim/cmake/opynsim_set_python_executable_to_venv.cmake)
    opyn_set_python_executable_to_venv(${OSC_VENV})
endif()

if(BUILD_TESTING)
    # This has to be done at the top-level, so that `ctest --show-only` works for
    # all test suites. It is how IDEs typically detect tests.
    #
    # `include(CTest)` isn't used because we don't want extra targets (e.g. `Continuous`).
    enable_testing()
endif()

# IMPORTANT: OpenSim Creator is just OPynSim, but packaged and documented as a standalone
#            desktop application. Contribute to https://github.com/opynsim/opynsim if you're
#            interested in developing it.
#
# Note: by now cache variables should be set by the caller (e.g. in CMakePresets.json)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/opynsim)

if(OSC_BUILD_DOCS)
    add_subdirectory(docs)
endif()
if(OSC_CONFIGURE_PACKAGING)
    add_subdirectory(packaging)
endif()
if (BUILD_TESTING)
    add_subdirectory(tests)
endif()
