intel / cryptography-primitives

Apache License 2.0
319 stars 86 forks source link

Add support for including using add_subdirectory #7

Closed rockaport closed 4 years ago

rockaport commented 5 years ago

Apologies if this can already be accomplished, but I'm failing to include this project as a dependency by simply using add_subdirectory and include_directories. The main reason for this is I lazily compile for different architectures and i don't want to precompile dependencies.

If it was intentional for not allowing this to be included using add_subdirectory then you can disregard this.

I'm using the following directory structure as an example:

.
├── CMakeLists.txt
├── main.cpp
├── libs
└── third-party
    ├── benchmark
    ├── boringssl
    └── ipp-crypto

And simply adding the following to the CMakeLists.txt file the other dependencies work and link fine.

cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 17)

project(crypto_bench)

add_subdirectory(googletest)
add_subdirectory(benchmark)
include_directories(boringssl/include)
include_directories(benchmark/include)

# doesn't work
# include_directories(ipp-crypto/include)
# add_subdirectory(ipp-crypto)

# instead precompile to libs and use this
# link_directories(libs/lib)
# include_directories(libs/include)

add_executable(crypto_bench main.cpp)
target_link_libraries(${PROJECT_NAME} crypto benchmark_main)
# target_link_libraries(${PROJECT_NAME} ippcp crypto benchmark_main)
amatyuko-intc commented 5 years ago

Hi Andrew,

Thanks for bringing this use case up. Simple addition of include/ and source/ directories into CMakeLists.txt probably will not work as the library has many options to build it, and they have to be configured somehow. But your use case is perfectly valid and we will look into how to fix the problem.

Regards, Andrey

amatyuko-intc commented 4 years ago

We made some adjustments to the build system, so it is supported now. Please take a look at the minimal example in the build instructions, and let us know if you have any issues with it.

Regards, Andrey