From 57cf59a86930b37d0d408fc58b6f13b44c8a431a Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 3 Aug 2016 11:04:20 +0200 Subject: [PATCH] cmake: Add proper detection of sys/mman.h. Fixes #450 Signed-off-by: Jerry Jacobs --- CMakeLists.txt | 6 ++++++ include/stlink/mmap.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7846cb1..ca46074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ project(stlink C) cmake_minimum_required(VERSION 2.8.7) include(CheckCCompilerFlag) +include(CheckIncludeFile) find_package(PkgConfig) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") @@ -47,6 +48,11 @@ elseif() add_cflag_if_supported("-O2") endif() +CHECK_INCLUDE_FILE(sys/mman.h STLINK_HAVE_SYS_MMAN_H) +if (STLINK_HAVE_SYS_MMAN_H) + add_definitions(-DSTLINK_HAVE_SYS_MMAN_H) +endif() + set(STLINK_HEADERS include/stlink.h include/stlink/usb.h diff --git a/include/stlink/mmap.h b/include/stlink/mmap.h index 71de819..ab94fb7 100644 --- a/include/stlink/mmap.h +++ b/include/stlink/mmap.h @@ -1,7 +1,7 @@ #ifndef STLINK_MMAP_H #define STLINK_MMAP_H -#ifdef HAVE_SYS_MMAN_H +#ifdef STLINK_HAVE_SYS_MMAN_H #include #else