Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
6e259170
Commit
6e259170
authored
Aug 29, 2016
by
Eric
Committed by
GitHub
Aug 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -DBENCHMARK_USE_LIBCXX:BOOL=<value> option. (#280)
* Add BENCHMARK_USE_LIBCXX option. * Add comments * re-add zero null pointer warning
parent
49bbff2c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
5 deletions
+39
-5
CMakeLists.txt
CMakeLists.txt
+22
-1
CXXFeatureCheck.cmake
cmake/CXXFeatureCheck.cmake
+3
-1
CMakeLists.txt
src/CMakeLists.txt
+6
-2
CMakeLists.txt
test/CMakeLists.txt
+8
-1
No files found.
CMakeLists.txt
View file @
6e259170
...
@@ -12,6 +12,7 @@ endforeach()
...
@@ -12,6 +12,7 @@ endforeach()
option
(
BENCHMARK_ENABLE_TESTING
"Enable testing of the benchmark library."
ON
)
option
(
BENCHMARK_ENABLE_TESTING
"Enable testing of the benchmark library."
ON
)
option
(
BENCHMARK_ENABLE_LTO
"Enable link time optimisation of the benchmark library."
OFF
)
option
(
BENCHMARK_ENABLE_LTO
"Enable link time optimisation of the benchmark library."
OFF
)
option
(
BENCHMARK_USE_LIBCXX
"Build and test using libc++ as the standard library."
OFF
)
# Make sure we can import out CMake functions
# Make sure we can import out CMake functions
list
(
APPEND CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
list
(
APPEND CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
...
@@ -78,8 +79,10 @@ else()
...
@@ -78,8 +79,10 @@ else()
add_cxx_compiler_flag
(
-pedantic-errors
)
add_cxx_compiler_flag
(
-pedantic-errors
)
add_cxx_compiler_flag
(
-Wshorten-64-to-32
)
add_cxx_compiler_flag
(
-Wshorten-64-to-32
)
add_cxx_compiler_flag
(
-Wfloat-equal
)
add_cxx_compiler_flag
(
-Wfloat-equal
)
add_cxx_compiler_flag
(
-Wzero-as-null-pointer-constant
)
add_cxx_compiler_flag
(
-fstrict-aliasing
)
add_cxx_compiler_flag
(
-fstrict-aliasing
)
if
(
NOT BENCHMARK_USE_LIBCXX
)
add_cxx_compiler_flag
(
-Wzero-as-null-pointer-constant
)
endif
()
if
(
HAVE_CXX_FLAG_FSTRICT_ALIASING
)
if
(
HAVE_CXX_FLAG_FSTRICT_ALIASING
)
add_cxx_compiler_flag
(
-Wstrict-aliasing
)
add_cxx_compiler_flag
(
-Wstrict-aliasing
)
endif
()
endif
()
...
@@ -126,6 +129,24 @@ else()
...
@@ -126,6 +129,24 @@ else()
add_cxx_compiler_flag
(
--coverage COVERAGE
)
add_cxx_compiler_flag
(
--coverage COVERAGE
)
endif
()
endif
()
if
(
BENCHMARK_USE_LIBCXX
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang"
)
add_cxx_compiler_flag
(
-stdlib=libc++
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Intel"
)
add_cxx_compiler_flag
(
-nostdinc++
)
message
(
"libc++ header path must be manually specified using CMAKE_CXX_FLAGS"
)
# Adding -nodefaultlibs directly to CMAKE_<TYPE>_LINKER_FLAGS will break
# configuration checks such as 'find_package(Threads)'
list
(
APPEND BENCHMARK_CXX_LINKER_FLAGS -nodefaultlibs
)
# -lc++ cannot be added directly to CMAKE_<TYPE>_LINKER_FLAGS because
# linker flags appear before all linker inputs and -lc++ must appear after.
list
(
APPEND BENCHMARK_CXX_LIBRARIES c++
)
else
()
message
(
FATAL
"-DBENCHMARK_USE_LIBCXX:BOOL=ON is not supported for compiler"
)
endif
()
endif
(
BENCHMARK_USE_LIBCXX
)
# C++ feature checks
# C++ feature checks
cxx_feature_check
(
STD_REGEX
)
cxx_feature_check
(
STD_REGEX
)
cxx_feature_check
(
GNU_POSIX_REGEX
)
cxx_feature_check
(
GNU_POSIX_REGEX
)
...
...
cmake/CXXFeatureCheck.cmake
View file @
6e259170
...
@@ -26,7 +26,9 @@ function(cxx_feature_check FILE)
...
@@ -26,7 +26,9 @@ function(cxx_feature_check FILE)
endif
()
endif
()
message
(
"-- Performing Test
${
FEATURE
}
"
)
message
(
"-- Performing Test
${
FEATURE
}
"
)
try_run
(
RUN_
${
FEATURE
}
COMPILE_
${
FEATURE
}
try_run
(
RUN_
${
FEATURE
}
COMPILE_
${
FEATURE
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/
${
FILE
}
.cpp
)
${
CMAKE_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/
${
FILE
}
.cpp
CMAKE_FLAGS
${
BENCHMARK_CXX_LINKER_FLAGS
}
LINK_LIBRARIES
${
BENCHMARK_CXX_LIBRARIES
}
)
if
(
RUN_
${
FEATURE
}
EQUAL 0
)
if
(
RUN_
${
FEATURE
}
EQUAL 0
)
message
(
"-- Performing Test
${
FEATURE
}
-- success"
)
message
(
"-- Performing Test
${
FEATURE
}
-- success"
)
set
(
HAVE_
${
VAR
}
1 CACHE INTERNAL
"Feature test for
${
FILE
}
"
PARENT_SCOPE
)
set
(
HAVE_
${
VAR
}
1 CACHE INTERNAL
"Feature test for
${
FILE
}
"
PARENT_SCOPE
)
...
...
src/CMakeLists.txt
View file @
6e259170
# Allow the source files to find headers in src/
# Allow the source files to find headers in src/
include_directories
(
${
PROJECT_SOURCE_DIR
}
/src
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/src
)
if
(
DEFINED BENCHMARK_CXX_LINKER_FLAGS
)
list
(
APPEND CMAKE_SHARED_LINKER_FLAGS
${
BENCHMARK_CXX_LINKER_FLAGS
}
)
list
(
APPEND CMAKE_MODULE_LINKER_FLAGS
${
BENCHMARK_CXX_LINKER_FLAGS
}
)
endif
()
# Define the source files
# Define the source files
set
(
SOURCE_FILES
"benchmark.cc"
"colorprint.cc"
"commandlineflags.cc"
set
(
SOURCE_FILES
"benchmark.cc"
"colorprint.cc"
"commandlineflags.cc"
"console_reporter.cc"
"csv_reporter.cc"
"json_reporter.cc"
"console_reporter.cc"
"csv_reporter.cc"
"json_reporter.cc"
...
@@ -19,7 +24,6 @@ endif()
...
@@ -19,7 +24,6 @@ endif()
add_library
(
benchmark
${
SOURCE_FILES
}
${
RE_FILES
}
)
add_library
(
benchmark
${
SOURCE_FILES
}
${
RE_FILES
}
)
set_target_properties
(
benchmark PROPERTIES
set_target_properties
(
benchmark PROPERTIES
OUTPUT_NAME
"benchmark"
OUTPUT_NAME
"benchmark"
VERSION
${
GENERIC_LIB_VERSION
}
VERSION
${
GENERIC_LIB_VERSION
}
...
@@ -27,7 +31,7 @@ set_target_properties(benchmark PROPERTIES
...
@@ -27,7 +31,7 @@ set_target_properties(benchmark PROPERTIES
)
)
# Link threads.
# Link threads.
target_link_libraries
(
benchmark
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
benchmark
${
BENCHMARK_CXX_LIBRARIES
}
${
CMAKE_THREAD_LIBS_INIT
}
)
# We need extra libraries on Windows
# We need extra libraries on Windows
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
)
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
)
...
...
test/CMakeLists.txt
View file @
6e259170
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
# NOTE: These flags must be added after find_package(Threads REQUIRED) otherwise
# they will break the configuration check.
if
(
DEFINED BENCHMARK_CXX_LINKER_FLAGS
)
list
(
APPEND CMAKE_EXE_LINKER_FLAGS
${
BENCHMARK_CXX_LINKER_FLAGS
}
)
endif
()
add_library
(
output_test_helper STATIC output_test_helper.cc
)
add_library
(
output_test_helper STATIC output_test_helper.cc
)
macro
(
compile_benchmark_test name
)
macro
(
compile_benchmark_test name
)
...
@@ -12,7 +18,8 @@ endmacro(compile_benchmark_test)
...
@@ -12,7 +18,8 @@ endmacro(compile_benchmark_test)
macro
(
compile_output_test name
)
macro
(
compile_output_test name
)
add_executable
(
${
name
}
"
${
name
}
.cc"
)
add_executable
(
${
name
}
"
${
name
}
.cc"
)
target_link_libraries
(
${
name
}
output_test_helper benchmark
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
${
name
}
output_test_helper benchmark
${
BENCHMARK_CXX_LIBRARIES
}
${
CMAKE_THREAD_LIBS_INIT
}
)
endmacro
(
compile_output_test
)
endmacro
(
compile_output_test
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment