From e34e9aca48336071ae01ffe8a891baf79339b6a8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 Jun 2022 15:45:52 -0400 Subject: [PATCH] improve consistency between CMake and GNU make build. Must explicitly link python when building a static mdi lib --- cmake/Modules/Packages/MDI.cmake | 3 ++- examples/mdi/README | 9 +++++---- lib/mdi/Makefile.g++ | 18 ------------------ lib/mdi/Makefile.gcc | 2 +- lib/mdi/Makefile.icc | 2 +- lib/mdi/Makefile.lammps.empty | 8 +++++--- lib/mdi/Makefile.mpi | 2 +- 7 files changed, 15 insertions(+), 29 deletions(-) delete mode 100644 lib/mdi/Makefile.g++ diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index 90188f91a8..1a14d5273a 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -44,7 +44,7 @@ if(DOWNLOAD_MDI) ExternalProject_Add(mdi_build URL ${MDI_URL} URL_MD5 ${MDI_MD5} - CMAKE_ARGS ${CMAKE_REQUEST_PIC} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -54,6 +54,7 @@ if(DOWNLOAD_MDI) -Dlanguage=C -Dlibtype=STATIC -Dmpi=${MDI_USE_MPI} + -Dplugins=ON -Dpython_plugins=${MDI_USE_PYTHON_PLUGINS} UPDATE_COMMAND "" INSTALL_COMMAND "" diff --git a/examples/mdi/README b/examples/mdi/README index 0b74fb9c48..c6267a7abb 100644 --- a/examples/mdi/README +++ b/examples/mdi/README @@ -2,10 +2,11 @@ These are examples that work the MDI package in LAMMPS which uses the MolSSI MDI library for coupling codes together and communicating between them with MDI messages. -In MDI lingo, one code is the driver and another code is the engine. -The 2 codes can be written in any language; C++ (LAMMPS) and Python -are illustrated here. The 2 codes can each be stand-alone codes, in -which case they can be run on different numbers of processors. The 2 +Within the MDI context, one code is the driver and another code is +the engine. The 2 codes can be written in any language; C++ (LAMMPS) +and Python are illustrated here. The 2 codes can each be stand-alone +codes, in which case they can be run on different numbers of processors. +The 2 codes can communicate either via TCP (sockets) or via MPI. For the TCP case, the driver and engine need to be launched separately, e.g. in 2 windows on your desktop machine. For the MPI case, a single diff --git a/lib/mdi/Makefile.g++ b/lib/mdi/Makefile.g++ deleted file mode 100644 index 41300f9992..0000000000 --- a/lib/mdi/Makefile.g++ +++ /dev/null @@ -1,18 +0,0 @@ -SHELL = /bin/sh - -# which file will be copied to Makefile.lammps - -EXTRAMAKE = Makefile.lammps.empty - -# ------ MAKE PROCEDURE ------ - -lib: $(OBJ) - mkdir -p build - cd build; cmake -Dlibtype=STATIC -Dlanguage=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ ../MDI_Library; make - @cp $(EXTRAMAKE) Makefile.lammps - -# ------ CLEAN ------ - -clean: - -rm *.o *.h $(LIB) - -rm -r build diff --git a/lib/mdi/Makefile.gcc b/lib/mdi/Makefile.gcc index 023c0e20df..3653f77a2f 100644 --- a/lib/mdi/Makefile.gcc +++ b/lib/mdi/Makefile.gcc @@ -8,7 +8,7 @@ EXTRAMAKE = Makefile.lammps.empty lib: $(OBJ) mkdir -p build - cd build; cmake -Dlibtype=STATIC -Dlanguage=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D CMAKE_C_COMPILER=gcc ../MDI_Library; make + cd build && cmake -D libtype=STATIC -D language=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D mpi=ON -D plugins=ON -D python_plugins=ON -D CMAKE_C_COMPILER=gcc ../MDI_Library && make @cp $(EXTRAMAKE) Makefile.lammps # ------ CLEAN ------ diff --git a/lib/mdi/Makefile.icc b/lib/mdi/Makefile.icc index 8c5049561b..615ebf9070 100644 --- a/lib/mdi/Makefile.icc +++ b/lib/mdi/Makefile.icc @@ -8,7 +8,7 @@ EXTRAMAKE = Makefile.lammps.empty lib: $(OBJ) mkdir -p build - cd build; cmake -Dlibtype=STATIC -Dlanguage=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc ../MDI_Library; make + cd build && cmake -D libtype=STATIC -D language=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D mpi=ON -D plugins=ON -D python_plugins=ON -D CMAKE_C_COMPILER=icc ../MDI_Library && make @cp $(EXTRAMAKE) Makefile.lammps # ------ CLEAN ------ diff --git a/lib/mdi/Makefile.lammps.empty b/lib/mdi/Makefile.lammps.empty index 3aabe162d2..01c8fe0b70 100644 --- a/lib/mdi/Makefile.lammps.empty +++ b/lib/mdi/Makefile.lammps.empty @@ -1,5 +1,7 @@ # Settings that the LAMMPS build will import when this package library is used -mdi_SYSINC = -mdi_SYSLIB = -mdi_SYSPATH = \ No newline at end of file +mdi_python_SYSLIB = $(shell which python3-config > /dev/null 2>&1 && python3-config --ldflags --embed > /dev/null 2>&1 && python3-config --ldflags --embed || (which python3-config > /dev/null 2>&1 && python3-config --ldflags || :) ) + +mdi_SYSINC = +mdi_SYSLIB = $(mdi_python_SYSLIB) +mdi_SYSPATH = diff --git a/lib/mdi/Makefile.mpi b/lib/mdi/Makefile.mpi index ce40bc9d4d..4274f3e0e8 100644 --- a/lib/mdi/Makefile.mpi +++ b/lib/mdi/Makefile.mpi @@ -8,7 +8,7 @@ EXTRAMAKE = Makefile.lammps.empty lib: $(OBJ) mkdir -p build - cd build; cmake -Dlibtype=STATIC -Dlanguage=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D CMAKE_C_COMPILER=mpicc -D CMAKE_CXX_COMPILER=mpicxx ../MDI_Library; make + cd build && cmake -D libtype=STATIC -D language=C -D CMAKE_POSITION_INDEPENDENT_CODE=yes -D mpi=ON -D plugins=ON -D python_plugins=ON -D CMAKE_C_COMPILER=mpicc ../MDI_Library && make @cp $(EXTRAMAKE) Makefile.lammps # ------ CLEAN ------