2015-03-07 01:35:00 +08:00
|
|
|
# Allow the source files to find headers in src/
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
2014-07-31 02:08:32 +08:00
|
|
|
|
2015-03-07 01:35:00 +08:00
|
|
|
# Define the source files
|
2015-03-28 04:27:15 +08:00
|
|
|
set(SOURCE_FILES "benchmark.cc" "colorprint.cc" "commandlineflags.cc"
|
|
|
|
"console_reporter.cc" "csv_reporter.cc" "json_reporter.cc"
|
|
|
|
"log.cc" "reporter.cc" "sleep.cc" "string_util.cc"
|
2015-03-18 12:23:43 +08:00
|
|
|
"sysinfo.cc" "walltime.cc")
|
2014-07-31 02:08:32 +08:00
|
|
|
# Determine the correct regular expression engine to use
|
|
|
|
if(HAVE_STD_REGEX)
|
|
|
|
set(RE_FILES "re_std.cc")
|
|
|
|
elseif(HAVE_GNU_POSIX_REGEX)
|
|
|
|
set(RE_FILES "re_posix.cc")
|
|
|
|
elseif(HAVE_POSIX_REGEX)
|
|
|
|
set(RE_FILES "re_posix.cc")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Failed to determine the source files for the regular expression backend")
|
|
|
|
endif()
|
2014-04-23 15:47:07 +08:00
|
|
|
|
2015-04-01 23:34:38 +08:00
|
|
|
add_library(benchmark ${SOURCE_FILES} ${RE_FILES})
|
|
|
|
|
2015-04-01 23:40:22 +08:00
|
|
|
# Link threading if building a shared library.
|
2015-04-01 23:34:38 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2015-03-07 01:35:00 +08:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(benchmark ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
|
2014-07-30 23:59:14 +08:00
|
|
|
set_target_properties(benchmark PROPERTIES
|
2015-03-07 01:35:00 +08:00
|
|
|
OUTPUT_NAME "benchmark"
|
2014-07-30 23:59:14 +08:00
|
|
|
VERSION ${GENERIC_LIB_VERSION}
|
|
|
|
SOVERSION ${GENERIC_LIB_SOVERSION}
|
2015-03-07 01:35:00 +08:00
|
|
|
)
|
2014-04-23 15:47:07 +08:00
|
|
|
|
2014-11-03 22:18:15 +08:00
|
|
|
# We need extra libraries on Windows
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
target_link_libraries(benchmark Shlwapi)
|
|
|
|
endif()
|
|
|
|
|
2014-04-23 15:47:07 +08:00
|
|
|
# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
|
|
|
|
install(
|
|
|
|
TARGETS benchmark
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
2015-04-01 17:57:08 +08:00
|
|
|
RUNTIME DESTINATION bin
|
2014-04-23 15:47:07 +08:00
|
|
|
COMPONENT library)
|
2015-03-07 01:35:00 +08:00
|
|
|
|
2014-04-23 15:47:07 +08:00
|
|
|
install(
|
|
|
|
DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
|
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING PATTERN "*.*h")
|