aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-02-10 08:23:25 +0100
committerAndreas Schneider <asn@cryptomilk.org>2015-02-10 15:49:30 +0100
commit08860c880dddc65e26efd515214b1ab1e3ad25dd (patch)
treeb37343fb7f7e9519a57cb3c1795aa14bec06b223
parent4132396b15da65bd3b6d5a756a78ac57217bbb2d (diff)
downloadcmocka-08860c880dddc65e26efd515214b1ab1e3ad25dd.tar.gz
cmocka-08860c880dddc65e26efd515214b1ab1e3ad25dd.tar.xz
cmocka-08860c880dddc65e26efd515214b1ab1e3ad25dd.zip
cmocka: Allow include of cmocka_platform.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--doc/mainpage.dox12
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/cmocka.c14
3 files changed, 32 insertions, 0 deletions
diff --git a/doc/mainpage.dox b/doc/mainpage.dox
index 5d658e0..925bfd2 100644
--- a/doc/mainpage.dox
+++ b/doc/mainpage.dox
@@ -83,6 +83,18 @@ the mock object to return. CMocka provides and API to easily mock code.
<a href="https://lwn.net/Articles/558106/">Learn more ...</a>
+@section main-embedded Embedded platforms
+
+It is possible that some embedded platforms do not provide definitions for
+required types or that the guards to protect them are not defined. To address
+this issue you can create a header file name 'cmocka_platform.h' with the
+required types and definitions. After that point cmake to the include directory
+using:
+
+<pre>
+ cmake -DCMOCKA_PLATFORM_INCLUDE=/home/compiler/my/include_directory ..
+</pre>
+
@section main-threads Threading
cmocka is not fully thread safe and it is not the goal of it to be it. We have
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2b3c486..4ab084e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,10 @@
project(cmocka-library C)
+set(CMOCKA_PLATFORM_INCLUDE CACHE PATH "Path to include directory for cmocka_platform.h")
+
set(CMOCKA_PUBLIC_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/include
+ ${CMOCKA_PLATFORM_INCLUDE}
CACHE INTERNAL "cmocka public include directories"
)
@@ -43,6 +46,9 @@ include_directories(
)
add_definitions(-DHAVE_CONFIG_H=1)
+if (CMOCKA_PLATFORM_INCLUDE)
+ add_definitions(-DCMOCKA_PLATFORM_INCLUDE=1)
+endif()
add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS})
diff --git a/src/cmocka.c b/src/cmocka.c
index 068bbcb..5b37688 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -67,6 +67,20 @@ WINBASEAPI BOOL WINAPI IsDebuggerPresent(VOID);
#include <signal.h>
#endif /* _WIN32 */
+/*
+ * This allows to add a platform specific header file. Some embedded platforms
+ * sometimes miss certain types and definitions.
+ *
+ * Example:
+ *
+ * typedef unsigned long int uintptr_t
+ * #define _UINTPTR_T 1
+ * #define _UINTPTR_T_DEFINED 1
+ */
+#ifdef CMOCKA_PLATFORM_INCLUDE
+# include "cmocka_platform.h"
+#endif /* CMOCKA_PLATFORM_INCLUDE */
+
#include <cmocka_private.h>
#include <cmocka.h>