Private
Public Access
2
0

ioinit: Update to build/test C++ ioinit

Multiple changes necessary to enable this.  The main goal is to build
and run the C++ ioinit unit tests (which require c++11)

    * Updated mraa required CMake version to 2.8.11 (this is needed for
      the target_xxx_xxx CMake syntax.
    * Added function for adding the c++11 flag give a CMake target.
    * Updated unit tests for range of CMake versions (tested on 2.8.11,
      3.8.2, 3.9.6, and 3.12.0).
    * Added C++ unit test file (more needed here).)

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2018-07-26 15:37:10 -07:00
parent 9056556b7a
commit d24457f9a1
3 changed files with 81 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 2.8.11)
project (mraa C CXX)
FIND_PACKAGE (Threads REQUIRED)
@@ -74,6 +74,17 @@ foreach (flag ${MRAA_BOTH_WARNING_FLAGS} ${MRAA_CXX_WARNING_FLAGS})
endif ()
endforeach ()
# This function adds the c++11 flag to a c++ target (if supported)
function(use_cxx_11 targetname)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if (COMPILER_SUPPORTS_CXX11)
set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-std=c++11")
else()
message(FATAL_ERROR "Target '${targetname}' requires c++11 which is not supported by this compiler")
endif()
endfunction()
# Set CMAKE_INSTALL_LIBDIR if not defined
include(GNUInstallDirs)