Commit b3bc5fd8 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

Merge branch 'record-compile-flags' of https://github.com/akohlmey/lammps into...

Merge branch 'record-compile-flags' of https://github.com/akohlmey/lammps into collected-cmake-changes
parents ad3d049e 19f81e08
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -797,6 +797,21 @@ GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR})
include_directories(${LAMMPS_SOURCE_DIR})
include_directories(${LAMMPS_STYLE_HEADERS_DIR})

######################################
# Generate lmpinstalledpkgs.h
######################################
set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n")
set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] =  {\n")
foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES})
    if(PKG_${PKG})
        set(temp "${temp}  \"${PKG}\",\n")
    endif()
endforeach()
set(temp "${temp}  NULL\n};\n#endif\n\n")
message(STATUS "Generating lmpinstalledpkgs.h...")
file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${temp}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h")

###########################################
# Actually add executable and lib to build
############################################
+30 −6
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ class lammps(object):
    self.c_bigint = get_ctypes_int(self.extract_setting("bigint"))
    self.c_tagint = get_ctypes_int(self.extract_setting("tagint"))
    self.c_imageint = get_ctypes_int(self.extract_setting("imageint"))
    self._installed_packages = None

  # shut-down LAMMPS instance

@@ -562,13 +563,36 @@ class lammps(object):
                                 shrinkexceed)

  @property
  def uses_exceptions(self):
  def has_exceptions(self):
    """ Return whether the LAMMPS shared library was compiled with C++ exceptions handling enabled """
    try:
      if self.lib.lammps_has_error:
        return True
    except(AttributeError):
      return False
    return self.lib.lammps_config_has_exceptions() != 0

  @property
  def has_gzip_support(self):
    return self.lib.lammps_config_has_gzip_support() != 0

  @property
  def has_png_support(self):
    return self.lib.lammps_config_has_png_support() != 0

  @property
  def has_jpeg_support(self):
    return self.lib.lammps_config_has_jpeg_support() != 0

  @property
  def has_ffmpeg_support(self):
    return self.lib.lammps_config_has_ffmpeg_support() != 0

  @property
  def installed_packages(self):
    if self._installed_packages is None:
      self._installed_packages = []
      npackages = self.lib.lammps_config_package_count()
      sb = create_string_buffer(100)
      for idx in range(npackages):
        self.lib.lammps_config_package_name(idx, sb, 100)
        self._installed_packages.append(sb.value.decode())
    return self._installed_packages

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
/lmp_*

/style_*.h
/lmpinstalledpkgs.h

/*_gpu.h
/*_gpu.cpp
+18 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ OBJDIR = Obj_$@
OBJSHDIR = Obj_shared_$@

SRC =	$(wildcard *.cpp)
INC =	$(wildcard *.h)
INC =	$(filter-out lmpinstalledpkgs.h,$(wildcard *.h))
OBJ = 	$(SRC:.cpp=.o)

SRCLIB = $(filter-out main.cpp,$(SRC))
@@ -150,6 +150,21 @@ help:
	  for file in $$files; do head -1 $$file; done
	@echo ''


lmpinstalledpkgs.h: $(SRC) $(INC)
	@echo 'Gathering installed package information (may take a little while)'
	@echo '#ifndef LMP_INSTALLED_PKGS_H' >  lmpinstalledpkgs.tmp
	@echo '#define LMP_INSTALLED_PKGS_H' >> lmpinstalledpkgs.tmp
	@echo 'const char * LAMMPS_NS::LAMMPS::installed_packages[] = {' >> lmpinstalledpkgs.tmp
	@for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \
             [ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package \(.*\)"/"\1",/' >> lmpinstalledpkgs.tmp || :; done
	@echo ' NULL };' >> lmpinstalledpkgs.tmp
	@echo '#endif' >> lmpinstalledpkgs.tmp
	@if [ -f lmpinstalledpkgs.h ]; \
          then test "`diff --brief lmpinstalledpkgs.tmp lmpinstalledpkgs.h`" != "" && \
	        mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h || rm lmpinstalledpkgs.tmp ; \
        else mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h ; fi

# Build LAMMPS in one of 4 modes
# exe =   exe with static compile in Obj_machine (default)
# shexe = exe with shared compile in Obj_shared_machine
@@ -163,6 +178,8 @@ help:
	  -f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@
	@if [ ! -d $(objdir) ]; then mkdir $(objdir); fi
	@$(SHELL) Make.sh style
	@$(MAKE) $(MFLAGS) lmpinstalledpkgs.h
	@echo 'Compiling LAMMPS for machine $@'
	@if [ -f MAKE/MACHINES/Makefile.$@ ]; \
	  then cp MAKE/MACHINES/Makefile.$@ $(objdir)/Makefile; fi
	@if [ -f MAKE/OPTIONS/Makefile.$@ ]; \
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,12 @@ style_region.h
style_neigh_bin.h
style_neigh_pair.h
style_neigh_stencil.h
style_nbin.h
style_npair.h
style_nstencil.h
style_ntopo.h
# other auto-generated files
lmpinstalledpkgs.h
# deleted on 4 April 2018
pair_kim_version.h
# deleted on 15 December 2017
Loading