check C++11 capability in CMakeLists.txt for h2olog
@@ -35,10 +35,6 @@ SET(LIBRARY_VERSION_PATCH "0")
SET(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}${VERSION_PRERELEASE}")
SET(LIBRARY_SOVERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}")
-SET(CMAKE_CXX_STANDARD 11)
-SET(CMAKE_CXX_STANDARD_REQUIRED ON)
-SET(CMAKE_CXX_EXTENSIONS OFF)
-
INCLUDE(GNUInstallDirs)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CMakePushCheckState)
@@ -869,12 +865,20 @@ IF (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND PKG_CONFIG_FOUND)
)
SET(REQUIRED_KERNEL_VERSION "4.9.0")
- IF (KERNEL_VERSION VERSION_GREATER REQUIRED_KERNEL_VERSION OR KERNEL_VERSION VERSION_EQUAL REQUIRED_KERNEL_VERSION)
+ IF (NOT (KERNEL_VERSION VERSION_LESS REQUIRED_KERNEL_VERSION))
SET(HAVE_BPF_SUPPORTED_KERNEL ON)
MESSAGE(STATUS "Checking Linux kernel version ${KERNEL_VERSION} >= ${REQUIRED_KERNEL_VERSION} for h2olog - OK")
ENDIF ()
- IF (WITH_DTRACE AND LIBBCC_FOUND AND HAVE_BPF_SUPPORTED_KERNEL)
+ IF (NOT (CMAKE_VERSION VERSION_LESS "3.8"))
+ CMAKE_POLICY(SET CMP0057 NEW)
+ IF ("cxx_std_11" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
+ MESSAGE(STATUS "C++11 OK")
+ SET(CXX_11 ON)
+ ENDIF ()
+ ENDIF ()
+
+ IF (WITH_DTRACE AND LIBBCC_FOUND AND HAVE_BPF_SUPPORTED_KERNEL AND CXX_11)
SET(WITH_H2OLOG_DEFAULT ON)
ENDIF ()
ENDIF ()
@@ -910,6 +914,12 @@ IF (WITH_H2OLOG)
ADD_EXECUTABLE(h2olog ${H2OLOG_SOURCE_FILES})
+ SET_PROPERTY(TARGET h2olog
+ PROPERTY CXX_STANDARD 11
+ PROPERTY CXX_STANDARD_REQUIRED ON
+ PROPERTY CXX_EXTENSIONS OFF
+ )
+
TARGET_LINK_LIBRARIES(h2olog "${LIBBCC_LIBRARIES}")
TARGET_INCLUDE_DIRECTORIES(h2olog
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/h2olog"
