1# Allow the source files to find headers in src/
2include_directories(${PROJECT_SOURCE_DIR}/src)
3
4# Define the source files
5set(SOURCE_FILES "benchmark.cc" "colorprint.cc" "commandlineflags.cc"
6                 "console_reporter.cc" "csv_reporter.cc" "json_reporter.cc"
7                 "log.cc" "reporter.cc" "sleep.cc" "string_util.cc"
8                 "sysinfo.cc" "walltime.cc")
9# Determine the correct regular expression engine to use
10if(HAVE_STD_REGEX)
11  set(RE_FILES "re_std.cc")
12elseif(HAVE_GNU_POSIX_REGEX)
13  set(RE_FILES "re_posix.cc")
14elseif(HAVE_POSIX_REGEX)
15  set(RE_FILES "re_posix.cc")
16else()
17  message(FATAL_ERROR "Failed to determine the source files for the regular expression backend")
18endif()
19
20add_library(benchmark ${SOURCE_FILES} ${RE_FILES})
21
22
23set_target_properties(benchmark PROPERTIES
24  OUTPUT_NAME "benchmark"
25  VERSION ${GENERIC_LIB_VERSION}
26  SOVERSION ${GENERIC_LIB_SOVERSION}
27)
28
29# Link threads.
30target_link_libraries(benchmark ${CMAKE_THREAD_LIBS_INIT})
31
32# We need extra libraries on Windows
33if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
34  target_link_libraries(benchmark Shlwapi)
35endif()
36
37# Expose public API
38target_include_directories(benchmark PUBLIC ${PROJECT_SOURCE_DIR}/include)
39
40# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
41install(
42  TARGETS benchmark
43  ARCHIVE DESTINATION lib
44  LIBRARY DESTINATION lib
45  RUNTIME DESTINATION bin
46  COMPONENT library)
47
48install(
49  DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
50  DESTINATION include
51  FILES_MATCHING PATTERN "*.*h")
52