66 lines
1.7 KiB
CMake
66 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.22.1)
|
|
project(sandbox-test)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Find dependencies via vcpkg
|
|
find_package(Lua REQUIRED)
|
|
find_package(nlohmann_json CONFIG REQUIRED)
|
|
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
|
|
|
# Sandbox library (the code being tested)
|
|
add_library(mosis-sandbox STATIC
|
|
../src/main/cpp/sandbox/lua_sandbox.cpp
|
|
../src/main/cpp/sandbox/permission_gate.cpp
|
|
../src/main/cpp/sandbox/audit_log.cpp
|
|
../src/main/cpp/sandbox/rate_limiter.cpp
|
|
../src/main/cpp/sandbox/path_sandbox.cpp
|
|
../src/main/cpp/sandbox/timer_manager.cpp
|
|
../src/main/cpp/sandbox/json_api.cpp
|
|
../src/main/cpp/sandbox/crypto_api.cpp
|
|
../src/main/cpp/sandbox/virtual_fs.cpp
|
|
../src/main/cpp/sandbox/database_manager.cpp
|
|
)
|
|
target_include_directories(mosis-sandbox PUBLIC
|
|
../src/main/cpp/sandbox
|
|
${LUA_INCLUDE_DIR}
|
|
)
|
|
target_link_libraries(mosis-sandbox PUBLIC
|
|
${LUA_LIBRARIES}
|
|
nlohmann_json::nlohmann_json
|
|
unofficial::sqlite3::sqlite3
|
|
)
|
|
# Windows BCrypt for crypto API
|
|
if(WIN32)
|
|
target_link_libraries(mosis-sandbox PUBLIC bcrypt)
|
|
endif()
|
|
|
|
# Test executable
|
|
add_executable(sandbox-test
|
|
src/main.cpp
|
|
src/test_harness.cpp
|
|
)
|
|
|
|
target_include_directories(sandbox-test PRIVATE
|
|
src
|
|
../src/main/cpp/sandbox
|
|
)
|
|
|
|
target_link_libraries(sandbox-test PRIVATE
|
|
mosis-sandbox
|
|
nlohmann_json::nlohmann_json
|
|
)
|
|
|
|
# Copy test scripts to build directory
|
|
add_custom_command(TARGET sandbox-test POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts
|
|
$<TARGET_FILE_DIR:sandbox-test>/scripts
|
|
)
|
|
|
|
# Windows-specific
|
|
if(WIN32)
|
|
target_compile_definitions(sandbox-test PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
endif()
|