From f1532bd31c7b9ad54248e9af8d6d9484efdf129e Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Mon, 7 Dec 2015 18:24:43 +0100 Subject: [PATCH] updated cmake snippet in documentation --- docs/cmake.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/cmake.rst b/docs/cmake.rst index a3277c085..41f58fff5 100644 --- a/docs/cmake.rst +++ b/docs/cmake.rst @@ -29,14 +29,21 @@ and that the pybind11 repository is located in a subdirectory named :file:`pybin set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6) find_package(PythonLibs ${EXAMPLE_PYTHON_VERSION} REQUIRED) - if (UNIX) - # Enable C++11 mode + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + # Enable C++11 mode on C++ / Clang set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Enable link time optimization and set the default symbol # visibility to hidden (very important to obtain small binaries) if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -flto") + # Default symbol visibility + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + + # Check for Link Time Optimization support + CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) + if (HAS_LTO_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + endif() endif() endif()