From a7479824158e62b45246f1b7426d74ce9820e38f Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Fri, 19 Feb 2021 09:34:02 -0500 Subject: [PATCH] Add `nvbench::main` CMake target. Linking to this instead of `nvbench::nvbench` will automatically include the `NVBENCH_MAIN` macro. --- nvbench/CMakeLists.txt | 5 +++++ nvbench/main.cu | 6 ++++++ testing/CMakeLists.txt | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 nvbench/main.cu diff --git a/nvbench/CMakeLists.txt b/nvbench/CMakeLists.txt index f8f72dd..2502ae9 100644 --- a/nvbench/CMakeLists.txt +++ b/nvbench/CMakeLists.txt @@ -24,8 +24,13 @@ set(srcs ) add_library(nvbench STATIC ${srcs}) +add_library(nvbench::nvbench ALIAS nvbench) # TODO generator expressions for installed paths target_include_directories(nvbench PUBLIC "${nvbench_SOURCE_DIR}") target_link_libraries(nvbench PRIVATE fmt::fmt) target_compile_features(nvbench PUBLIC cuda_std_17) + +add_library(nvbench_main OBJECT main.cu) +add_library(nvbench::main ALIAS nvbench_main) +target_link_libraries(nvbench_main PUBLIC nvbench) diff --git a/nvbench/main.cu b/nvbench/main.cu new file mode 100644 index 0000000..33943b9 --- /dev/null +++ b/nvbench/main.cu @@ -0,0 +1,6 @@ +// Provided as a CMake OBJECT library named nvbench::main so users don't have +// to add `NVBENCH_MAIN` to every benchmark executable. + +#include + +NVBENCH_MAIN diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 364b64c..3692da1 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -23,7 +23,7 @@ foreach(test_src IN LISTS test_srcs) string(PREPEND test_name "nvbench.test.") add_executable(${test_name} "${test_src}") target_include_directories(${test_name} PRIVATE "${CMAKE_CURRENT_LIST_DIR}") - target_link_libraries(${test_name} PRIVATE nvbench fmt) + target_link_libraries(${test_name} PRIVATE nvbench::nvbench fmt) set_target_properties(${test_name} PROPERTIES COMPILE_FEATURES cuda_std_17) add_test(NAME ${test_name} COMMAND "$") endforeach()