diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2d259791f2..aefa9cd597 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -156,8 +156,7 @@ if(BUILD_MPI) endif() endif() else() - enable_language(C) - file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) + file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.cpp) add_library(mpi_stubs STATIC ${MPI_SOURCES}) set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE}) target_include_directories(mpi_stubs PUBLIC $) diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake index fb62763828..6ff4e322aa 100644 --- a/cmake/Modules/Packages/MESSAGE.cmake +++ b/cmake/Modules/Packages/MESSAGE.cmake @@ -2,9 +2,8 @@ if(LAMMPS_SIZES STREQUAL BIGBIG) message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG") endif() option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF) -file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) +file(GLOB_RECURSE cslib_SOURCES + ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) add_library(cslib STATIC ${cslib_SOURCES}) target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES}) diff --git a/src/STUBS/Makefile b/src/STUBS/Makefile index 3c3c3b46d9..c9b6fdb65a 100644 --- a/src/STUBS/Makefile +++ b/src/STUBS/Makefile @@ -11,13 +11,13 @@ SHELL = /bin/sh # Files -SRC = mpi.c +SRC = mpi.cpp INC = mpi.h # Definitions EXE = libmpi_stubs.a -OBJ = $(SRC:.c=.o) +OBJ = $(SRC:.cpp=.o) # System-specific settings @@ -36,7 +36,7 @@ clean: # Compilation rules -.c.o: +.cpp.o: $(CC) $(CCFLAGS) -c $< # Individual dependencies diff --git a/src/STUBS/Makefile.mingw32-cross b/src/STUBS/Makefile.mingw32-cross index 4144954ec7..2934bbd468 100644 --- a/src/STUBS/Makefile.mingw32-cross +++ b/src/STUBS/Makefile.mingw32-cross @@ -5,17 +5,17 @@ SHELL = /bin/sh # Files -SRC = mpi.c +SRC = mpi.cpp INC = mpi.h # Definitions EXE = libmpi_mingw32.a -OBJ = $(SRC:%.c=%_mingw32.o) +OBJ = $(SRC:%.cpp=%_mingw32.o) # System-specific settings -CC = i686-w64-mingw32-gcc +CC = i686-w64-mingw32-g++ CCFLAGS = -O2 -Wall -march=i686 -mtune=generic -mfpmath=387 -mpc64 -I. ARCHIVE = i686-w64-mingw32-ar ARCHFLAG = rs diff --git a/src/STUBS/Makefile.mingw64-cross b/src/STUBS/Makefile.mingw64-cross index 70b971f262..e62d5dcbe1 100644 --- a/src/STUBS/Makefile.mingw64-cross +++ b/src/STUBS/Makefile.mingw64-cross @@ -5,17 +5,17 @@ SHELL = /bin/sh # Files -SRC = mpi.c +SRC = mpi.cpp INC = mpi.h # Definitions EXE = libmpi_mingw64.a -OBJ = $(SRC:%.c=%_mingw64.o) +OBJ = $(SRC:%.cpp=%_mingw64.o) # System-specific settings -CC = x86_64-w64-mingw32-gcc +CC = x86_64-w64-mingw32-g++ CCFLAGS = -O2 -Wall -march=core2 -mtune=core2 -msse2 -mpc64 -I. ARCHIVE = x86_64-w64-mingw32-ar ARCHFLAG = rs diff --git a/src/STUBS/mpi.c b/src/STUBS/mpi.cpp similarity index 100% rename from src/STUBS/mpi.c rename to src/STUBS/mpi.cpp diff --git a/src/STUBS/mpi.h b/src/STUBS/mpi.h index 063dc542be..28e897960d 100644 --- a/src/STUBS/mpi.h +++ b/src/STUBS/mpi.h @@ -16,12 +16,17 @@ #include -/* use C bindings for MPI interface */ +/* We compile STUBS with C++ so the symbols embedded + * the serial shared library will not collide with any + * corresponding symbols from a real MPI library (which + * uses C bindings). As a consequence the header *must* + * enforce compiling with C++ only. */ -#ifdef __cplusplus -extern "C" { +#ifndef __cplusplus +#error "MPI STUBS must be compiled with a C++ compiler" #endif + /* Dummy defs for MPI stubs */ #define MPI_COMM_WORLD 0 @@ -176,8 +181,4 @@ int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls, MPI_Datatype recvtype, MPI_Comm comm); /* ---------------------------------------------------------------------- */ -#ifdef __cplusplus -} -#endif - #endif