Files
Adminive/cmake/RunRealDrogonInstallConsumer.cmake
2026-08-08 22:39:18 +08:00

40 lines
2.1 KiB
CMake

if(NOT DEFINED ADMINIVE_BINARY_DIR)
message(FATAL_ERROR "ADMINIVE_BINARY_DIR is required")
endif()
if(NOT DEFINED ADMINIVE_CONFIG OR ADMINIVE_CONFIG STREQUAL "")
set(ADMINIVE_CONFIG Release)
endif()
if(NOT DEFINED Drogon_DIR OR Drogon_DIR STREQUAL "")
message(FATAL_ERROR "Drogon_DIR is required")
endif()
if(NOT DEFINED nlohmann_json_DIR OR nlohmann_json_DIR STREQUAL "")
message(FATAL_ERROR "nlohmann_json_DIR is required")
endif()
get_filename_component(adminive_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(adminive_source "${adminive_root}/install_consumer/real_drogon")
set(adminive_test_root "${ADMINIVE_BINARY_DIR}/real_drogon_install_consumer_test")
set(adminive_prefix "${adminive_test_root}/prefix")
set(adminive_binary "${adminive_test_root}/build")
file(REMOVE_RECURSE "${adminive_test_root}")
execute_process(COMMAND "${CMAKE_COMMAND}" --install "${ADMINIVE_BINARY_DIR}" --prefix "${adminive_prefix}" --config "${ADMINIVE_CONFIG}" RESULT_VARIABLE install_result)
if(NOT install_result EQUAL 0)
message(FATAL_ERROR "Adminive install failed: ${install_result}")
endif()
execute_process(COMMAND "${CMAKE_COMMAND}" -S "${adminive_source}" -B "${adminive_binary}" "-DCMAKE_PREFIX_PATH=${adminive_prefix}" "-DDrogon_DIR=${Drogon_DIR}" "-Dnlohmann_json_DIR=${nlohmann_json_DIR}" "-DCMAKE_BUILD_TYPE=${ADMINIVE_CONFIG}" RESULT_VARIABLE configure_result)
if(NOT configure_result EQUAL 0)
message(FATAL_ERROR "Real Drogon install consumer configure failed: ${configure_result}")
endif()
execute_process(COMMAND "${CMAKE_COMMAND}" --build "${adminive_binary}" --config "${ADMINIVE_CONFIG}" RESULT_VARIABLE build_result)
if(NOT build_result EQUAL 0)
message(FATAL_ERROR "Real Drogon install consumer build failed: ${build_result}")
endif()
if(WIN32)
set(adminive_consumer "${adminive_binary}/${ADMINIVE_CONFIG}/real_drogon_consumer.exe")
else()
set(adminive_consumer "${adminive_binary}/real_drogon_consumer")
endif()
execute_process(COMMAND "${adminive_consumer}" RESULT_VARIABLE run_result)
if(NOT run_result EQUAL 0)
message(FATAL_ERROR "Real Drogon install consumer run failed: ${run_result}")
endif()