if(NOT DEFINED STRUCTIVE_SOURCE_DIR OR NOT DEFINED STRUCTIVE_BINARY_DIR) message(FATAL_ERROR "STRUCTIVE_SOURCE_DIR and STRUCTIVE_BINARY_DIR are required") endif() set(prefix "${STRUCTIVE_BINARY_DIR}/install_consumer_prefix") set(consumer_binary "${STRUCTIVE_BINARY_DIR}/install_consumer_build") file(REMOVE_RECURSE "${prefix}" "${consumer_binary}") set(build_command "${CMAKE_COMMAND}" --build "${STRUCTIVE_BINARY_DIR}" --target structive_property_extensions) if(DEFINED STRUCTIVE_CONFIG AND NOT STRUCTIVE_CONFIG STREQUAL "") list(APPEND build_command --config "${STRUCTIVE_CONFIG}") endif() execute_process(COMMAND ${build_command} RESULT_VARIABLE build_result) if(NOT build_result EQUAL 0) message(FATAL_ERROR "Failed to build Structive before install consumer test") endif() set(install_command "${CMAKE_COMMAND}" --install "${STRUCTIVE_BINARY_DIR}" --prefix "${prefix}") if(DEFINED STRUCTIVE_CONFIG AND NOT STRUCTIVE_CONFIG STREQUAL "") list(APPEND install_command --config "${STRUCTIVE_CONFIG}") endif() execute_process(COMMAND ${install_command} RESULT_VARIABLE install_result) if(NOT install_result EQUAL 0) message(FATAL_ERROR "Failed to install Structive") endif() foreach(path IN ITEMS "${prefix}/share/Structive/RELEASE.md" "${prefix}/share/Structive/THIRD_PARTY_NOTICES.md") if(NOT EXISTS "${path}") message(FATAL_ERROR "Structive install is missing release metadata: ${path}") endif() endforeach() set(configure_command "${CMAKE_COMMAND}" -S "${STRUCTIVE_SOURCE_DIR}/install_consumer" -B "${consumer_binary}" "-DCMAKE_PREFIX_PATH=${prefix}") if(DEFINED STRUCTIVE_GENERATOR AND NOT STRUCTIVE_GENERATOR STREQUAL "") list(APPEND configure_command -G "${STRUCTIVE_GENERATOR}") endif() if(DEFINED STRUCTIVE_GENERATOR_PLATFORM AND NOT STRUCTIVE_GENERATOR_PLATFORM STREQUAL "") list(APPEND configure_command -A "${STRUCTIVE_GENERATOR_PLATFORM}") endif() if(DEFINED STRUCTIVE_GENERATOR_TOOLSET AND NOT STRUCTIVE_GENERATOR_TOOLSET STREQUAL "") list(APPEND configure_command -T "${STRUCTIVE_GENERATOR_TOOLSET}") endif() execute_process(COMMAND ${configure_command} RESULT_VARIABLE configure_result) if(NOT configure_result EQUAL 0) message(FATAL_ERROR "Failed to configure Structive install consumer") endif() set(consumer_build_command "${CMAKE_COMMAND}" --build "${consumer_binary}") if(DEFINED STRUCTIVE_CONFIG AND NOT STRUCTIVE_CONFIG STREQUAL "") list(APPEND consumer_build_command --config "${STRUCTIVE_CONFIG}") endif() execute_process(COMMAND ${consumer_build_command} RESULT_VARIABLE consumer_build_result) if(NOT consumer_build_result EQUAL 0) message(FATAL_ERROR "Failed to build Structive install consumer") endif() set(ctest_command "${CMAKE_CTEST_COMMAND}" --test-dir "${consumer_binary}" --output-on-failure) if(DEFINED STRUCTIVE_CONFIG AND NOT STRUCTIVE_CONFIG STREQUAL "") list(APPEND ctest_command -C "${STRUCTIVE_CONFIG}") endif() execute_process(COMMAND ${ctest_command} RESULT_VARIABLE test_result) if(NOT test_result EQUAL 0) message(FATAL_ERROR "Structive install consumer failed") endif()