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 if (DEFINED BENCHMARK_CXX_LINKER_FLAGS)
      5   list(APPEND CMAKE_SHARED_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS})
      6   list(APPEND CMAKE_MODULE_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS})
      7 endif()
      8 
      9 file(GLOB
     10   SOURCE_FILES
     11     *.cc
     12     ${PROJECT_SOURCE_DIR}/include/benchmark/*.h
     13     ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
     14 
     15 add_library(benchmark ${SOURCE_FILES})
     16 set_target_properties(benchmark PROPERTIES
     17   OUTPUT_NAME "benchmark"
     18   VERSION ${GENERIC_LIB_VERSION}
     19   SOVERSION ${GENERIC_LIB_SOVERSION}
     20 )
     21 
     22 # Link threads.
     23 target_link_libraries(benchmark  ${BENCHMARK_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
     24 
     25 # We need extra libraries on Windows
     26 if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
     27   target_link_libraries(benchmark Shlwapi)
     28 endif()
     29 
     30 # Expose public API
     31 target_include_directories(benchmark PUBLIC ${PROJECT_SOURCE_DIR}/include)
     32 
     33 # Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
     34 install(
     35   TARGETS benchmark
     36   ARCHIVE DESTINATION lib
     37   LIBRARY DESTINATION lib
     38   RUNTIME DESTINATION bin
     39   COMPONENT library)
     40 
     41 install(
     42   DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
     43   DESTINATION include
     44   FILES_MATCHING PATTERN "*.*h")
     45