1- #Allow the source files to find headers in src /
1+ # Allow the source files to find headers in src /
22include (GNUInstallDirs)
33include_directories (${PROJECT_SOURCE_DIR} /src)
44
5- if (DEFINED BENCHMARK_CXX_LINKER_FLAGS)
5+ if (DEFINED BENCHMARK_CXX_LINKER_FLAGS)
66 list (APPEND CMAKE_SHARED_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS} )
77 list (APPEND CMAKE_MODULE_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS} )
88endif ()
99
10- file (GLOB
11- SOURCE_FILES
12- *.cc
13- ${PROJECT_SOURCE_DIR} /include /benchmark/*.h
14- ${CMAKE_CURRENT_SOURCE_DIR} /*.h)
10+ file (GLOB SOURCE_FILES *.cc ${PROJECT_SOURCE_DIR} /include /benchmark/*.h
11+ ${CMAKE_CURRENT_SOURCE_DIR} /*.h)
1512file (GLOB BENCHMARK_MAIN "benchmark_main.cc" )
1613foreach (item ${BENCHMARK_MAIN} )
1714 list (REMOVE_ITEM SOURCE_FILES "${item} " )
1815endforeach ()
1916
2017add_library (benchmark ${SOURCE_FILES} )
2118add_library (benchmark::benchmark ALIAS benchmark)
22- set_target_properties (benchmark PROPERTIES
23- OUTPUT_NAME "benchmark"
24- VERSION ${GENERIC_LIB_VERSION}
25- SOVERSION ${GENERIC_LIB_SOVERSION}
26- )
27- target_include_directories (benchmark PUBLIC
28- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >
29- )
19+ set_target_properties (
20+ benchmark
21+ PROPERTIES OUTPUT_NAME "benchmark"
22+ VERSION ${GENERIC_LIB_VERSION}
23+ SOVERSION ${GENERIC_LIB_SOVERSION} )
24+ target_include_directories (
25+ benchmark PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >)
3026
3127set_property (
3228 SOURCE benchmark.cc
3329 APPEND
34- PROPERTY COMPILE_DEFINITIONS
35- BENCHMARK_VERSION="${VERSION} "
36- )
30+ PROPERTY COMPILE_DEFINITIONS BENCHMARK_VERSION="${VERSION} " )
3731
3832# libpfm, if available
39- if (PFM_FOUND)
33+ if (PFM_FOUND)
4034 target_link_libraries (benchmark PRIVATE PFM::libpfm)
4135 target_compile_definitions (benchmark PRIVATE -DHAVE_LIBPFM)
4236endif ()
@@ -55,7 +49,6 @@ if(HAVE_LIB_RT)
5549 target_link_libraries (benchmark PRIVATE rt)
5650endif (HAVE_LIB_RT)
5751
58-
5952# We need extra libraries on Windows
6053if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
6154 target_link_libraries (benchmark PRIVATE shlwapi)
@@ -67,24 +60,23 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
6760 set (BENCHMARK_PRIVATE_LINK_LIBRARIES -lkstat)
6861endif ()
6962
70- if (NOT BUILD_SHARED_LIBS )
63+ if (NOT BUILD_SHARED_LIBS )
7164 target_compile_definitions (benchmark PUBLIC -DBENCHMARK_STATIC_DEFINE)
7265endif ()
7366
7467# Benchmark main library
7568add_library (benchmark_main "benchmark_main.cc" )
7669add_library (benchmark::benchmark_main ALIAS benchmark_main)
77- set_target_properties (benchmark_main PROPERTIES
78- OUTPUT_NAME " benchmark_main"
79- VERSION ${GENERIC_LIB_VERSION}
80- SOVERSION ${GENERIC_LIB_SOVERSION }
81- DEFINE_SYMBOL benchmark_EXPORTS
82- )
70+ set_target_properties (
71+ benchmark_main
72+ PROPERTIES OUTPUT_NAME "benchmark_main"
73+ VERSION ${GENERIC_LIB_VERSION }
74+ SOVERSION ${GENERIC_LIB_SOVERSION}
75+ DEFINE_SYMBOL benchmark_EXPORTS )
8376target_link_libraries (benchmark_main PUBLIC benchmark::benchmark)
8477
85- add_subdirectory (${PROJECT_SOURCE_DIR} /../core codspeed)
86-
87- target_link_libraries (benchmark PRIVATE codspeed)
78+ # TODO: Find a way to not expose codspeed headers to downstream users
79+ target_link_libraries (benchmark PUBLIC codspeed)
8880
8981set (generated_dir "${PROJECT_BINARY_DIR} " )
9082
@@ -100,57 +92,57 @@ set(namespace "${PROJECT_NAME}::")
10092
10193include (CMakePackageConfigHelpers)
10294
103- configure_package_config_file (
104- ${PROJECT_SOURCE_DIR} /cmake/Config.cmake.in
105- ${project_config}
95+ configure_package_config_file(
96+ ${PROJECT_SOURCE_DIR} /cmake/Config.cmake.in ${project_config}
10697 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME}
107- NO_SET_AND_CHECK_MACRO
108- NO_CHECK_REQUIRED_COMPONENTS_MACRO
109- )
98+ NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
11099write_basic_package_version_file(
111- "${version_config} " VERSION ${GENERIC_LIB_VERSION} COMPATIBILITY SameMajorVersion
112- )
100+ "${version_config} "
101+ VERSION ${GENERIC_LIB_VERSION}
102+ COMPATIBILITY SameMajorVersion)
113103
114- configure_file ("${PROJECT_SOURCE_DIR} /cmake/benchmark.pc.in" "${pkg_config} " @ONLY)
115- configure_file ("${PROJECT_SOURCE_DIR} /cmake/benchmark_main.pc.in" "${pkg_config_main} " @ONLY)
104+ configure_file ("${PROJECT_SOURCE_DIR} /cmake/benchmark.pc.in" "${pkg_config} "
105+ @ONLY)
106+ configure_file ("${PROJECT_SOURCE_DIR} /cmake/benchmark_main.pc.in"
107+ "${pkg_config_main} " @ONLY)
116108
117- export (
109+ export (
118110 TARGETS ${targets_to_export}
119111 NAMESPACE "${namespace} "
120- FILE ${generated_dir} /${targets_export_name} .cmake
121- )
112+ FILE ${generated_dir} /${targets_export_name} .cmake)
122113
123- if (BENCHMARK_ENABLE_INSTALL)
124- # Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
114+ if (BENCHMARK_ENABLE_INSTALL)
115+ # Install target (will install the library to specified CMAKE_INSTALL_PREFIX
116+ # variable)
125117 install (
126118 TARGETS ${targets_to_export}
127119 EXPORT ${targets_export_name}
128120 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
129121 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
130122 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
131- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
123+ INCLUDES
124+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
132125
133126 install (
134127 DIRECTORY "${PROJECT_SOURCE_DIR} /include/benchmark"
135128 "${PROJECT_BINARY_DIR} /include/benchmark"
136129 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
137- FILES_MATCHING PATTERN "*.*h" )
130+ FILES_MATCHING
131+ PATTERN "*.*h" )
138132
139- install (
140- FILES "${project_config} " "${version_config} "
141- DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} " )
133+ install (FILES "${project_config} " "${version_config} "
134+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} " )
142135
143- install (
144- FILES "${pkg_config} " "${pkg_config_main} "
145- DESTINATION "${CMAKE_INSTALL_LIBDIR} /pkgconfig" )
136+ install (FILES "${pkg_config} " "${pkg_config_main} "
137+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /pkgconfig" )
146138
147139 install (
148- EXPORT "${targets_export_name} "
149- NAMESPACE "${namespace} "
150- DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} " )
140+ EXPORT "${targets_export_name} "
141+ NAMESPACE "${namespace} "
142+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} " )
151143endif ()
152144
153- if (BENCHMARK_ENABLE_DOXYGEN)
145+ if (BENCHMARK_ENABLE_DOXYGEN)
154146 find_package (Doxygen REQUIRED)
155147 set (DOXYGEN_QUIET YES )
156148 set (DOXYGEN_RECURSIVE YES )
@@ -164,22 +156,17 @@ if (BENCHMARK_ENABLE_DOXYGEN)
164156 set (DOXYGEN_BINARY_TOC YES )
165157 set (DOXYGEN_TOC_EXPAND YES )
166158 set (DOXYGEN_USE_MDFILE_AS_MAINPAGE "index.md" )
167- doxygen_add_docs(benchmark_doxygen
168- docs
169- include
170- src
171- ALL
159+ doxygen_add_docs(
160+ benchmark_doxygen docs include src ALL
172161 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
173162 COMMENT "Building documentation with Doxygen." )
174- if (BENCHMARK_ENABLE_INSTALL AND BENCHMARK_INSTALL_DOCS)
175- install (
176- DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /html/"
177- DESTINATION ${CMAKE_INSTALL_DOCDIR} )
163+ if (BENCHMARK_ENABLE_INSTALL AND BENCHMARK_INSTALL_DOCS)
164+ install (DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /html/"
165+ DESTINATION ${CMAKE_INSTALL_DOCDIR} )
178166 endif ()
179167else ()
180- if (BENCHMARK_ENABLE_INSTALL AND BENCHMARK_INSTALL_DOCS)
181- install (
182- DIRECTORY "${PROJECT_SOURCE_DIR} /docs/"
183- DESTINATION ${CMAKE_INSTALL_DOCDIR} )
168+ if (BENCHMARK_ENABLE_INSTALL AND BENCHMARK_INSTALL_DOCS)
169+ install (DIRECTORY "${PROJECT_SOURCE_DIR} /docs/"
170+ DESTINATION ${CMAKE_INSTALL_DOCDIR} )
184171 endif ()
185172endif ()
0 commit comments