Configure 'benchmark' cmake target so that when other targets depend on it,

they get the appropriate include directories and link libraries automatically.
This commit is contained in:
Geoff Romer 2015-04-02 09:15:49 -07:00 committed by Dominic Hamon
parent 42d2b8d11a
commit a6ad799a4d

View file

@ -18,10 +18,12 @@ else()
endif()
add_library(benchmark ${SOURCE_FILES} ${RE_FILES})
# Link threading if building a shared library.
if (BUILD_SHARED_LIBS)
find_package(Threads REQUIRED)
# Link threading if building a shared library, otherwise let client do it.
if (BUILD_SHARED_LIBS)
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