Add cmake for logging sample using a release (#1947)

This commit is contained in:
Amaury Chamayou 2020-12-03 14:30:32 +00:00 коммит произвёл GitHub
Родитель 313b208fac
Коммит a75945fd84
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 73 добавлений и 1 удалений

Просмотреть файл

@ -27,6 +27,10 @@ steps:
workingDirectory: build workingDirectory: build
displayName: Test installed CCF displayName: Test installed CCF
- script: |
./tests/test_install_build.sh
displayName: Test building a sample against installed CCF
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@1
inputs: inputs:
path: $(Build.ArtifactStagingDirectory)/$(pkgname) path: $(Build.ArtifactStagingDirectory)/$(pkgname)

Просмотреть файл

@ -37,6 +37,8 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/preproject.cmake
DESTINATION cmake DESTINATION cmake
) )
include(GNUInstallDirs)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/aft.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/aft.cmake)
@ -75,6 +77,8 @@ if("sgx" IN_LIST COMPILE_TARGETS)
PUBLIC PUBLIC
"$<BUILD_INTERFACE:${EVERCRYPT_INC}>" "$<BUILD_INTERFACE:${EVERCRYPT_INC}>"
$<BUILD_INTERFACE:${CCF_GENERATED_DIR}> $<BUILD_INTERFACE:${CCF_GENERATED_DIR}>
$<INSTALL_INTERFACE:include/ccf/>
$<INSTALL_INTERFACE:include/3rdparty/>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin/kremlib> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
@ -129,6 +133,8 @@ if("virtual" IN_LIST COMPILE_TARGETS)
PUBLIC PUBLIC
"$<BUILD_INTERFACE:${EVERCRYPT_INC}>" "$<BUILD_INTERFACE:${EVERCRYPT_INC}>"
$<BUILD_INTERFACE:${CCF_GENERATED_DIR}> $<BUILD_INTERFACE:${CCF_GENERATED_DIR}>
$<INSTALL_INTERFACE:include/ccf/>
$<INSTALL_INTERFACE:include/3rdparty/>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin>
$<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin/kremlib> $<INSTALL_INTERFACE:include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
@ -165,7 +171,11 @@ if("virtual" IN_LIST COMPILE_TARGETS)
add_dependencies(ccf ccf.virtual) add_dependencies(ccf ccf.virtual)
endif() endif()
install(EXPORT ccf DESTINATION cmake) install(
EXPORT ccf
DESTINATION cmake
FILE ccf-targets.cmake
)
# Install all 3rd-party library includes # Install all 3rd-party library includes
install( install(
@ -850,3 +860,20 @@ if(BUILD_TESTS)
--use-websockets --use-websockets
) )
endif() endif()
# Generate and install CMake export file for consumers using CMake
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccf-config.cmake.in
${CMAKE_BINARY_DIR}/cmake/ccf-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_BINDIR CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/cmake/ccf-config-version.cmake
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_BINARY_DIR}/cmake/ccf-config.cmake
${CMAKE_BINARY_DIR}/cmake/ccf-config-version.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)

Просмотреть файл

@ -0,0 +1,8 @@
@PACKAGE_INIT@
set(CCF_DIR "@CMAKE_INSTALL_PREFIX@")
include("${CCF_DIR}/cmake/ccf-targets.cmake")
include("${CCF_DIR}/cmake/preproject.cmake")
include("${CCF_DIR}/cmake/ccf_app.cmake")
include("${CCF_DIR}/cmake/tools.cmake")

Просмотреть файл

@ -0,0 +1,24 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
cmake_minimum_required(VERSION 3.13)
project(logging LANGUAGES C CXX)
find_package(ccf REQUIRED)
add_ccf_app(logging SRCS logging.cpp)
# Generate an ephemeral signing key
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/signing_key.pem
COMMAND openssl genrsa -out ${CMAKE_CURRENT_BINARY_DIR}/signing_key.pem -3
3072
)
add_custom_target(
signing_key ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/signing_key.pem
)
sign_app_library(
logging.enclave ${CMAKE_CURRENT_SOURCE_DIR}/oe_sign.conf
${CMAKE_CURRENT_BINARY_DIR}/signing_key.pem
)

9
tests/test_install_build.sh Executable file
Просмотреть файл

@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
set -ex
mkdir build_against_install
cd build_against_install
CC=$(which clang-8) CXX=$(which clang++-8) cmake -GNinja ../samples/apps/logging/
ninja