From beb0d92c114c3e5aa981563b9a991d5ac68aef31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 28 Nov 2019 20:02:20 +0100 Subject: [PATCH] cmake: Add evmc::evmc_cpp INTERFACE library for evmc.hpp --- CHANGELOG.md | 2 ++ CMakeLists.txt | 1 - examples/CMakeLists.txt | 6 +++--- examples/example_precompiles_vm/CMakeLists.txt | 4 ++-- examples/example_vm/CMakeLists.txt | 4 ++-- lib/CMakeLists.txt | 9 +++++++++ lib/loader/CMakeLists.txt | 5 +---- lib/mocked_host/CMakeLists.txt | 4 +--- test/unittests/CMakeLists.txt | 2 +- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7de124..eaa6259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning]. - In the Rust bindings added more type aliases (`MessageKind`, `MessageFlags`, `StatusCode`, `StorageStatus`, `Revision`). [#206](https://github.com/ethereum/evmc/pull/206) +- In CMake the `evmc::evmc_cpp` target has been added which represents the C++ EVMC API. + [#470](https://github.com/ethereum/evmc/pull/470) ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 842ca7b..e02bf80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,6 @@ configure_package_config_file( ) if(EVMC_INSTALL) - install(TARGETS evmc EXPORT evmcTargets) install(DIRECTORY include/evmc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install( diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5377b75..dc083bc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,11 +8,11 @@ add_subdirectory(example_vm) add_subdirectory(example_precompiles_vm) add_library(evmc-example-host STATIC example_host.cpp) -target_link_libraries(evmc-example-host PRIVATE evmc) +target_link_libraries(evmc-example-host PRIVATE evmc::evmc_cpp) add_executable(evmc-example-static example.c) -target_link_libraries(evmc-example-static PRIVATE evmc-example-host evmc::example-vm-static evmc) +target_link_libraries(evmc-example-static PRIVATE evmc-example-host evmc::example-vm-static evmc::evmc) target_compile_definitions(evmc-example-static PRIVATE STATICALLY_LINKED_EXAMPLE) add_executable(evmc-example example.c) -target_link_libraries(evmc-example PRIVATE evmc-example-host evmc evmc::loader) +target_link_libraries(evmc-example PRIVATE evmc-example-host evmc::loader) diff --git a/examples/example_precompiles_vm/CMakeLists.txt b/examples/example_precompiles_vm/CMakeLists.txt index ec21321..ae092de 100644 --- a/examples/example_precompiles_vm/CMakeLists.txt +++ b/examples/example_precompiles_vm/CMakeLists.txt @@ -4,11 +4,11 @@ add_library(example-precompiles-vm SHARED example_precompiles_vm.cpp example_precompiles_vm.h) add_library(evmc::example-precompiles-vm ALIAS example-precompiles-vm) -target_link_libraries(example-precompiles-vm PRIVATE evmc) +target_link_libraries(example-precompiles-vm PRIVATE evmc::evmc) add_library(example-precompiles-vm-static STATIC example_precompiles_vm.cpp example_precompiles_vm.h) add_library(evmc::example-precompiles-vm-static ALIAS example-precompiles-vm-static) -target_link_libraries(example-precompiles-vm-static PRIVATE evmc) +target_link_libraries(example-precompiles-vm-static PRIVATE evmc::evmc) set_source_files_properties(example_precompiles_vm.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}") diff --git a/examples/example_vm/CMakeLists.txt b/examples/example_vm/CMakeLists.txt index 023f7ae..f30c18a 100644 --- a/examples/example_vm/CMakeLists.txt +++ b/examples/example_vm/CMakeLists.txt @@ -4,11 +4,11 @@ add_library(example-vm SHARED example_vm.c example_vm.h) add_library(evmc::example-vm ALIAS example-vm) -target_link_libraries(example-vm PRIVATE evmc) +target_link_libraries(example-vm PRIVATE evmc::evmc) add_library(example-vm-static STATIC example_vm.c example_vm.h) add_library(evmc::example-vm-static ALIAS example-vm-static) -target_link_libraries(example-vm-static PRIVATE evmc) +target_link_libraries(example-vm-static PRIVATE evmc::evmc) set_source_files_properties(example_vm.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 82c9b02..20fc63d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -6,6 +6,15 @@ add_library(evmc INTERFACE) add_library(evmc::evmc ALIAS evmc) target_include_directories(evmc INTERFACE $$) +add_library(evmc_cpp INTERFACE) +add_library(evmc::evmc_cpp ALIAS evmc_cpp) +target_include_directories(evmc_cpp INTERFACE $$) +target_link_libraries(evmc_cpp INTERFACE evmc::evmc) + add_subdirectory(instructions) add_subdirectory(loader) add_subdirectory(mocked_host) + +if(EVMC_INSTALL) + install(TARGETS evmc evmc_cpp EXPORT evmcTargets) +endif() diff --git a/lib/loader/CMakeLists.txt b/lib/loader/CMakeLists.txt index 60340c1..1fca2ca 100644 --- a/lib/loader/CMakeLists.txt +++ b/lib/loader/CMakeLists.txt @@ -13,10 +13,7 @@ set_target_properties(loader PROPERTIES OUTPUT_NAME evmc-loader POSITION_INDEPENDENT_CODE TRUE ) -target_include_directories(loader PUBLIC - $$ -) -target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS}) +target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS} PUBLIC evmc::evmc) if(EVMC_INSTALL) install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/lib/mocked_host/CMakeLists.txt b/lib/mocked_host/CMakeLists.txt index c3b8b6c..58e1229 100644 --- a/lib/mocked_host/CMakeLists.txt +++ b/lib/mocked_host/CMakeLists.txt @@ -6,9 +6,7 @@ add_library(mocked_host INTERFACE) target_sources(mocked_host INTERFACE $) add_library(evmc::mocked_host ALIAS mocked_host) -target_include_directories(mocked_host INTERFACE - $$ -) +target_link_libraries(mocked_host INTERFACE evmc::evmc_cpp) if(EVMC_INSTALL) install(TARGETS mocked_host EXPORT evmcTargets) diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index 6e11f24..359d619 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -11,7 +11,7 @@ find_package(GTest CONFIG REQUIRED) set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_DEFINITIONS GTEST_HAS_TR1_TUPLE=0) add_library(loader-mocked STATIC ${PROJECT_SOURCE_DIR}/lib/loader/loader.c) -target_link_libraries(loader-mocked PRIVATE evmc) +target_link_libraries(loader-mocked PRIVATE evmc::evmc) target_compile_definitions(loader-mocked PRIVATE EVMC_LOADER_MOCK=1) add_executable(