diff options
author | Eric <eric@efcs.ca> | 2016-08-29 12:43:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-29 12:43:30 -0600 |
commit | 6e259170011cd2fbac069b9d4ff83b42445a96cc (patch) | |
tree | c0f9b1477eed7e15d0f31d40a1505961e27cee08 /CMakeLists.txt | |
parent | 49bbff2c66c7be2192a779eb4a158e91f62ce489 (diff) | |
download | google-benchmark-6e259170011cd2fbac069b9d4ff83b42445a96cc.tar.gz |
Add -DBENCHMARK_USE_LIBCXX:BOOL=<value> option. (#280)
* Add BENCHMARK_USE_LIBCXX option.
* Add comments
* re-add zero null pointer warning
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a1251e7..1ef8300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ endforeach() 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_USE_LIBCXX "Build and test using libc++ as the standard library." OFF) # Make sure we can import out CMake functions list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -78,8 +79,10 @@ else() add_cxx_compiler_flag(-pedantic-errors) add_cxx_compiler_flag(-Wshorten-64-to-32) add_cxx_compiler_flag(-Wfloat-equal) - add_cxx_compiler_flag(-Wzero-as-null-pointer-constant) 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) add_cxx_compiler_flag(-Wstrict-aliasing) endif() @@ -126,6 +129,24 @@ else() add_cxx_compiler_flag(--coverage COVERAGE) 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 cxx_feature_check(STD_REGEX) cxx_feature_check(GNU_POSIX_REGEX) |