From 80fd56bb2aa2f7e0025ea50ee3e66719ad6c077c Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 27 Oct 2016 10:29:05 +0200 Subject: [PATCH] Detect libcpp --- .travis.yml | 3 +-- CMakeLists.txt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84e040e..fd3ae48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,11 +32,10 @@ matrix: - os: osx install: - - brew tap homebrew/python - brew tap homebrew/science - brew update - brew install swig octave guile || echo "nope" script: - mkdir build && pushd build - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_CXX_FLAGS="-std=c++11" -DWITH_CXX=ON -DPYTHON_EXECUTABLE=/usr/bin/python .. + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DWITH_CXX=ON -DPYTHON_EXECUTABLE=/usr/bin/python .. - make install && make tests && ctest --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d6029..11910eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ if (WITH_CXX) set (NLOPT_SUFFIX _cxx) endif () -if (WITH_CXX OR BUILD_PYTHON) +if (WITH_CXX OR BUILD_PYTHON OR BUILD_GUILE OR BUILD_OCTAVE) enable_language (CXX) endif () @@ -70,6 +70,8 @@ include (CheckIncludeFiles) include (CheckFunctionExists) include (CheckTypeSize) include (CheckCCompilerFlag) +include (CheckCXXSymbolExists) +include (CheckCXXCompilerFlag) #============================================================================== # COMPILATION CHECKINGS and CONFIGURATION GENERATION @@ -132,6 +134,16 @@ if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE) endforeach() endif () +if (WITH_CXX OR BUILD_PYTHON OR BUILD_GUILE OR BUILD_OCTAVE) + check_cxx_symbol_exists (_LIBCPP_VERSION string SYSTEM_HAS_LIBCPP) + if (SYSTEM_HAS_LIBCPP) + check_cxx_compiler_flag ("-std=c++11" SUPPORTS_STDCXX11) + if (SUPPORTS_STDCXX11) + set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + endif () + endif () +endif () + #============================================================================== # version #============================================================================== -- 2.30.2