From ec4c283cc0bd0a2f272939d0b50bb6652c268104 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 19 Mar 2021 11:08:50 +0100 Subject: [PATCH] build: range-v3 dependency added to CMake config file for clang + libc++ --- src/mp-unitsConfig.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/mp-unitsConfig.cmake b/src/mp-unitsConfig.cmake index 9dcca1ab..314dbda5 100644 --- a/src/mp-unitsConfig.cmake +++ b/src/mp-unitsConfig.cmake @@ -20,8 +20,35 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +function(__check_libcxx_in_use variable) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(CHECK_START "Checking if libc++ is being used") + list(APPEND CMAKE_MESSAGE_INDENT " ") + + include(CheckSymbolExists) + check_symbol_exists(_LIBCPP_VERSION "ciso646" ${variable}) + set(${variable} ${${variable}} PARENT_SCOPE) + + list(POP_BACK CMAKE_MESSAGE_INDENT) + if(UNITS_LIBCXX) + message(CHECK_PASS "found") + else() + message(CHECK_FAIL "not found") + endif() + endif() +endfunction() + include(CMakeFindDependencyMacro) find_dependency(fmt) find_dependency(gsl-lite) +# add range-v3 dependency only for clang + libc++ +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + __check_libcxx_in_use(__units_libcxx) + if(__units_libcxx) + find_dependency(range-v3) + endif() + unset(__units_libcxx) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/mp-unitsTargets.cmake")