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