From a6ad799a4d26c4ed54bb1a90c1ae664e0767e6f6 Mon Sep 17 00:00:00 2001 From: Geoff Romer Date: Thu, 2 Apr 2015 09:15:49 -0700 Subject: [PATCH] Configure 'benchmark' cmake target so that when other targets depend on it, they get the appropriate include directories and link libraries automatically. --- src/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eebed294..29e10f4d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,10 +18,12 @@ else() endif() add_library(benchmark ${SOURCE_FILES} ${RE_FILES}) +find_package(Threads REQUIRED) -# Link threading if building a shared library. +# Link threading if building a shared library, otherwise let client do it. if (BUILD_SHARED_LIBS) - find_package(Threads REQUIRED) + target_link_libraries(benchmark PRIVATE ${CMAKE_THREAD_LIBS_INIT}) +else() target_link_libraries(benchmark ${CMAKE_THREAD_LIBS_INIT}) endif() @@ -36,6 +38,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_link_libraries(benchmark Shlwapi) endif() +target_include_directories(benchmark PUBLIC ${PROJECT_SOURCE_DIR}/include) + # Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable) install( TARGETS benchmark