include(gmxGetGmockTupleWorkaround)
get_gmock_tuple_workaround(GMOCK_COMPILE_DEFINITIONS)
-set(GMOCK_COMPILE_DEFINITIONS "_GNU_SOURCE=1;${GMOCK_COMPILE_DEFINITIONS}")
-set(GMOCK_COMPILE_DEFINITIONS ${GMOCK_COMPILE_DEFINITIONS} PARENT_SCOPE)
# GTest/GMock suggest linking with pthreads when available for thread safety
set(CMAKE_THREAD_PREFER_PTHREAD 1)
endif()
add_library(gmock STATIC ${UNITTEST_TARGET_OPTIONS} ${GMOCK_SOURCES} ${GTEST_SOURCES})
-set_property(TARGET gmock APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
+set_property(TARGET gmock APPEND PROPERTY COMPILE_DEFINITIONS
+ "_GNU_SOURCE=1;${GMOCK_COMPILE_DEFINITIONS}")
set(GMOCK_LIBRARIES gmock ${PTHREADS_LIBRARIES} PARENT_SCOPE)
set(GTEST_LIBRARIES ${GMOCK_LIBRARIES} PARENT_SCOPE)
set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS} PARENT_SCOPE)
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} PARENT_SCOPE)
+set(GMOCK_COMPILE_DEFINITIONS ${GMOCK_COMPILE_DEFINITIONS} PARENT_SCOPE)
*
* \inlibraryapi
*/
+//! \cond
#ifdef HAVE_CONFIG_H
#include "gmxpre-config.h"
#endif
+/* We use a few GNU functions for thread affinity and other low-level stuff.
+ * However, all such uses should be accompanied by #ifdefs and a feature test
+ * at CMake level, so that the actual uses will be compiled only when available.
+ * But since the define affects system headers, it should be defined before
+ * including any system headers, and this is a robust location to do that.
+ * If this were defined only in source files that needed it, it would clutter
+ * the list of includes somewhere close to the beginning and make automatic
+ * sorting of the includes more difficult.
+ */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
#ifdef GMX_FAHCORE
#define FULLINDIRECT 1
#define USE_FAH_XDR 1
#include "swindirect.h"
#endif
+//! \endcond
*/
#include "gmxpre.h"
+#include "gromacs/legacyheaders/gmx_cpuid.h"
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_SCHED_H
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-# endif
-# include <sched.h>
-#endif
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#ifdef GMX_NATIVE_WINDOWS
/* MSVC definition for __cpuid() */
#ifdef _MSC_VER
/* sysinfo functions */
#include <windows.h>
#endif
+#ifdef HAVE_SCHED_H
+ #include <sched.h>
+#endif
#ifdef HAVE_UNISTD_H
/* sysconf() definition */
#include <unistd.h>
#endif
-#include "gromacs/legacyheaders/gmx_cpuid.h"
-
-
/* For convenience, and to enable configure-time invocation, we keep all architectures
* in a single file, but to avoid repeated ifdefs we set the overall architecture here.
*/
#include "gmxpre.h"
-#include "config.h"
-
-#ifdef HAVE_SCHED_AFFINITY
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-# endif
-# include <sched.h>
-# include <sys/syscall.h>
-#endif
-
#include "gromacs/legacyheaders/gmx_thread_affinity.h"
+#include "config.h"
+
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_SCHED_AFFINITY
+# include <sched.h>
+# include <sys/syscall.h>
+#endif
+
#include "thread_mpi/threads.h"
#include "gromacs/legacyheaders/copyrite.h"