Setup targets from each directory, rather than the top-level.

This commit is contained in:
Chris Kennelly 2014-04-23 00:47:07 -07:00
parent 9b5ece6ece
commit e38fde6450
3 changed files with 20 additions and 16 deletions

View File

@ -30,19 +30,6 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
# Build the targets
FILE(GLOB SOURCE_FILES "src/*.cc")
add_library(benchmark STATIC ${SOURCE_FILES})
add_executable(benchmark_test test/benchmark_test.cc)
target_link_libraries(benchmark_test benchmark ${CMAKE_THREAD_LIBS_INIT})
# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
INSTALL(
TARGETS benchmark
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library)
INSTALL(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
DESTINATION include
FILES_MATCHING PATTERN "*.*h")
enable_testing()
add_subdirectory(src)
add_subdirectory(test)

14
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,14 @@
set(SOURCE_FILES "benchmark.cc" "colorprint.cc" "commandlineflags.cc" "sleep.cc" "sysinfo.cc" "walltime.cc")
add_library(benchmark STATIC ${SOURCE_FILES})
# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
install(
TARGETS benchmark
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library)
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
DESTINATION include
FILES_MATCHING PATTERN "*.*h")

3
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
# Demonstration executable
add_executable(benchmark_test benchmark_test.cc)
target_link_libraries(benchmark_test benchmark ${CMAKE_THREAD_LIBS_INIT})