# Generate Protobuf C++ source files from proto spec using protobuf compiler
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ProvisionerTpm2.proto)

# CMake file to control creation of TPM 2.0 Provisioner Library
add_library(TPM2_PROVISIONER_LIBRARY
        # Source Files
        CommandTpm2.cpp
        DeviceInfoCollector.cpp
        HirsRuntimeException.cpp
        Logger.cpp
        Process.cpp
        Properties.cpp
        RestfulClientProvisioner.cpp
        Tpm2ToolsUtils.cpp
        Utils.cpp

        # Header Files
        ${CMAKE_SOURCE_DIR}/include/CommandTpm2.h
        ${CMAKE_SOURCE_DIR}/include/DeviceInfoCollector.h
        ${CMAKE_SOURCE_DIR}/include/HirsRuntimeException.h
        ${CMAKE_SOURCE_DIR}/include/Logger.h
        ${CMAKE_SOURCE_DIR}/include/Process.h
        ${CMAKE_SOURCE_DIR}/include/Properties.h
        ${CMAKE_SOURCE_DIR}/include/RestfulClientProvisioner.h
        ${CMAKE_SOURCE_DIR}/include/Tpm2ToolsUtils.h
        ${CMAKE_SOURCE_DIR}/include/Tss.h
        ${CMAKE_SOURCE_DIR}/include/Utils.h
        ${CMAKE_SOURCE_DIR}/include/Version.h

        # Autogenerated Files
        ${PROTO_SRCS}
        ${PROTO_HDRS})

# Link necessary libraries from project's root CMake file
target_link_libraries(TPM2_PROVISIONER_LIBRARY
        ${REQUIRED_LIBS})

# Specify 3rd party include directories for IDEs
include_directories(${CPR_INCLUDE_DIRS})
# Includes protobuf libraries
include_directories(${PROTOBUF_INCLUDE_DIR})

# Need to add directory of generated protobuf files to include path
get_filename_component(PROTO_DIR ${PROTO_HDRS} DIRECTORY)
include_directories(${PROTO_DIR})
