if (APPLE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else (APPLE)
  # for Ubuntu14.04, use c++11, if g++-4.9 is not installed.
  if (CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.9)
    find_program(GXX49 g++-4.9)
    if (NOT GXX49)
      message(STATUS "g++-4.9 is not found. if you want to enable c++14, please install g++-4.9")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      add_definitions("-DUSE_CXX11")
      set(USE_CXX11 1)
    else ()
      message(STATUS "g++-4.9 is found, using it for roscpp14")
      set(CMAKE_CXX_COMPILER g++-4.9)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
    endif()
  else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  endif()
endif (APPLE)
