From 1a251396d98c3225d9e7058e9b8e2c6768864004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Tschumperl=C3=A9?= <david.tschumperle@gmail.com> Date: Wed, 14 Nov 2018 15:24:16 +0100 Subject: [PATCH] Do not require -lpthread when compiling in minimal mode. --- CImg.h | 6 +++++- examples/Makefile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 668dcd8..73fc3b7 100644 --- a/CImg.h +++ b/CImg.h @@ -70,6 +70,9 @@ // Include standard C++ headers. // This is the minimal set of required headers to make CImg-based codes compile. +#ifdef _PTHREAD_H +#define cimg_use_pthread +#endif #include <cstdio> #include <cstdlib> #include <cstdarg> @@ -366,6 +369,7 @@ #include <X11/Xutil.h> #include <X11/keysym.h> #include <pthread.h> +#define cimg_use_pthread #ifdef cimg_use_xshm #include <sys/ipc.h> #include <sys/shm.h> @@ -3067,7 +3071,7 @@ namespace cimg_library_suffixed { void lock(const unsigned int n) { WaitForSingleObject(mutex[n],INFINITE); } void unlock(const unsigned int n) { ReleaseMutex(mutex[n]); } int trylock(const unsigned int) { return 0; } -#elif defined(_PTHREAD_H) +#elif cimg_use_pthread pthread_mutex_t mutex[32]; Mutex_info() { for (unsigned int i = 0; i<32; ++i) pthread_mutex_init(&mutex[i],0); } void lock(const unsigned int n) { pthread_mutex_lock(&mutex[n]); } diff --git a/examples/Makefile b/examples/Makefile index b844925..556e40d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -336,7 +336,7 @@ menu: all: $(FILES) clean: - rm -rf *.exe *.o *~ \#* $(FILES) $(EXTRA_FILES) + rm -rf *.exe *.o *.obj *~ \#* $(FILES) $(EXTRA_FILES) ifneq ($(EXE_PRE),) rm -f $(EXE_PRE)* endif -- GitLab