forked from lijiext/lammps
Merge branch 'cmake-fix-check-for-installed' of https://github.com/akohlmey/lammps into collected-cmake-changes
This commit is contained in:
commit
9f1aabea50
|
@ -6,9 +6,10 @@ cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
project(lammps CXX)
|
project(lammps CXX)
|
||||||
set(SOVERSION 0)
|
set(SOVERSION 0)
|
||||||
set(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
get_filename_component(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src ABSOLUTE)
|
||||||
set(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib ABSOLUTE)
|
||||||
set(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib)
|
get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE)
|
||||||
|
|
||||||
|
|
||||||
#To not conflict with old Makefile build system, we build everything here
|
#To not conflict with old Makefile build system, we build everything here
|
||||||
file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/*.cpp)
|
file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/*.cpp)
|
||||||
|
@ -23,21 +24,23 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||||
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
|
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
|
||||||
|
|
||||||
file(GLOB SRC_FILES ${LAMMPS_SOURCE_DIR}/*.cpp)
|
# check for files auto-generated by make-based buildsystem
|
||||||
list(SORT SRC_FILES)
|
# this is fast, so check for it all the time
|
||||||
# check for files installed by make-based buildsystem
|
message(STATUS "Running check for auto-generated files from make-based build system")
|
||||||
# only run this time consuming check if there are new files
|
file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/style_*.h)
|
||||||
if(NOT SRC_FILES STREQUAL SRC_FILES_CACHED)
|
list(APPEND SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h)
|
||||||
file(GLOB SRC_PKG_FILES ${LAMMPS_SOURCE_DIR}/*/*.cpp)
|
foreach(_SRC ${SRC_AUTOGEN_FILES})
|
||||||
message(STATUS "Running check for installed package (this might take a while)")
|
|
||||||
foreach(_SRC SRC_PKG_FILES)
|
|
||||||
get_filename_component(FILENAME "${_SRC}" NAME)
|
get_filename_component(FILENAME "${_SRC}" NAME)
|
||||||
if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME})
|
if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME})
|
||||||
message(FATAL_ERROR "Found packages installed by the make-based buildsystem, please run 'make -C ${LAMMPS_SOURCE_DIR} no-all purge'")
|
message(FATAL_ERROR "\n########################################################################\n"
|
||||||
|
"Found header file(s) generated by the make-based build system\n"
|
||||||
|
"\n"
|
||||||
|
"Please run\n"
|
||||||
|
"make -C ${LAMMPS_SOURCE_DIR} purge\n"
|
||||||
|
"to remove\n"
|
||||||
|
"########################################################################")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set(SRC_FILES_CACHED "${SRC_FILES}" CACHE INTERNAL "List of file in LAMMPS_SOURCE_DIR" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# compiler tests
|
# compiler tests
|
||||||
|
@ -465,20 +468,11 @@ RegisterStyles(${LAMMPS_SOURCE_DIR})
|
||||||
foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES})
|
foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES})
|
||||||
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
|
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
|
||||||
|
|
||||||
# ignore PKG files which were manually installed in src folder
|
|
||||||
# headers are ignored during RegisterStyles
|
|
||||||
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/*.cpp)
|
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/*.cpp)
|
||||||
file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/*.h)
|
file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/*.h)
|
||||||
|
|
||||||
foreach(PKG_FILE in ${${PKG}_SOURCES})
|
# check for package files in src directory due to old make system
|
||||||
get_filename_component(FNAME ${PKG_FILE} NAME)
|
DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS})
|
||||||
list(REMOVE_ITEM LIB_SOURCES ${LAMMPS_SOURCE_DIR}/${FNAME})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(PKG_FILE in ${${PKG}_HEADERS})
|
|
||||||
get_filename_component(FNAME ${PKG_FILE} NAME)
|
|
||||||
DetectAndRemovePackageHeader(${LAMMPS_SOURCE_DIR}/${FNAME})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
if(PKG_${PKG})
|
if(PKG_${PKG})
|
||||||
# detects styles in package and adds them to global list
|
# detects styles in package and adds them to global list
|
||||||
|
@ -489,6 +483,17 @@ foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# dedicated check for entire contents of accelerator packages
|
||||||
|
foreach(PKG ${ACCEL_PACKAGES})
|
||||||
|
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
|
||||||
|
|
||||||
|
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/*.cpp)
|
||||||
|
file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/*.h)
|
||||||
|
|
||||||
|
# check for package files in src directory due to old make system
|
||||||
|
DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# add lib sources of (simple) enabled packages
|
# add lib sources of (simple) enabled packages
|
||||||
############################################
|
############################################
|
||||||
|
|
|
@ -45,14 +45,10 @@ function(FindStyleHeadersExt path style_class extension headers sources)
|
||||||
endfunction(FindStyleHeadersExt)
|
endfunction(FindStyleHeadersExt)
|
||||||
|
|
||||||
function(CreateStyleHeader path filename)
|
function(CreateStyleHeader path filename)
|
||||||
math(EXPR N "${ARGC}-2")
|
|
||||||
|
|
||||||
set(temp "")
|
set(temp "")
|
||||||
if(N GREATER 0)
|
if(ARGC GREATER 2)
|
||||||
math(EXPR ARG_END "${ARGC}-1")
|
list(REMOVE_AT ARGV 0 1)
|
||||||
|
foreach(FNAME ${ARGV})
|
||||||
foreach(IDX RANGE 2 ${ARG_END})
|
|
||||||
list(GET ARGV ${IDX} FNAME)
|
|
||||||
get_filename_component(FNAME ${FNAME} NAME)
|
get_filename_component(FNAME ${FNAME} NAME)
|
||||||
set(temp "${temp}#include \"${FNAME}\"\n")
|
set(temp "${temp}#include \"${FNAME}\"\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -107,35 +103,6 @@ function(RegisterStyles search_path)
|
||||||
FindStyleHeaders(${search_path} REGION_CLASS region_ REGION ) # region ) # domain
|
FindStyleHeaders(${search_path} REGION_CLASS region_ REGION ) # region ) # domain
|
||||||
endfunction(RegisterStyles)
|
endfunction(RegisterStyles)
|
||||||
|
|
||||||
function(RemovePackageHeader headers pkg_header)
|
|
||||||
get_property(hlist GLOBAL PROPERTY ${headers})
|
|
||||||
list(REMOVE_ITEM hlist ${pkg_header})
|
|
||||||
set_property(GLOBAL PROPERTY ${headers} "${hlist}")
|
|
||||||
endfunction(RemovePackageHeader)
|
|
||||||
|
|
||||||
function(DetectAndRemovePackageHeader fname)
|
|
||||||
RemovePackageHeader(ANGLE ${fname})
|
|
||||||
RemovePackageHeader(ATOM_VEC ${fname})
|
|
||||||
RemovePackageHeader(BODY ${fname})
|
|
||||||
RemovePackageHeader(BOND ${fname})
|
|
||||||
RemovePackageHeader(COMMAND ${fname})
|
|
||||||
RemovePackageHeader(COMPUTE ${fname})
|
|
||||||
RemovePackageHeader(DIHEDRAL ${fname})
|
|
||||||
RemovePackageHeader(DUMP ${fname})
|
|
||||||
RemovePackageHeader(FIX ${fname})
|
|
||||||
RemovePackageHeader(IMPROPER ${fname})
|
|
||||||
RemovePackageHeader(INTEGRATE ${fname})
|
|
||||||
RemovePackageHeader(KSPACE ${fname})
|
|
||||||
RemovePackageHeader(MINIMIZE ${fname})
|
|
||||||
RemovePackageHeader(NBIN ${fname})
|
|
||||||
RemovePackageHeader(NPAIR ${fname})
|
|
||||||
RemovePackageHeader(NSTENCIL ${fname})
|
|
||||||
RemovePackageHeader(NTOPO ${fname})
|
|
||||||
RemovePackageHeader(PAIR ${fname})
|
|
||||||
RemovePackageHeader(READER ${fname})
|
|
||||||
RemovePackageHeader(REGION ${fname})
|
|
||||||
endfunction(DetectAndRemovePackageHeader)
|
|
||||||
|
|
||||||
function(RegisterStylesExt search_path extension sources)
|
function(RegisterStylesExt search_path extension sources)
|
||||||
FindStyleHeadersExt(${search_path} ANGLE_CLASS ${extension} ANGLE ${sources})
|
FindStyleHeadersExt(${search_path} ANGLE_CLASS ${extension} ANGLE ${sources})
|
||||||
FindStyleHeadersExt(${search_path} ATOM_CLASS ${extension} ATOM_VEC ${sources})
|
FindStyleHeadersExt(${search_path} ATOM_CLASS ${extension} ATOM_VEC ${sources})
|
||||||
|
@ -181,3 +148,21 @@ function(GenerateStyleHeaders output_path)
|
||||||
GenerateStyleHeader(${output_path} READER reader ) # read_dump
|
GenerateStyleHeader(${output_path} READER reader ) # read_dump
|
||||||
GenerateStyleHeader(${output_path} REGION region ) # domain
|
GenerateStyleHeader(${output_path} REGION region ) # domain
|
||||||
endfunction(GenerateStyleHeaders)
|
endfunction(GenerateStyleHeaders)
|
||||||
|
|
||||||
|
function(DetectBuildSystemConflict lammps_src_dir)
|
||||||
|
if(ARGC GREATER 1)
|
||||||
|
list(REMOVE_AT ARGV 0)
|
||||||
|
foreach(SRC_FILE ${ARGV})
|
||||||
|
get_filename_component(FILENAME ${SRC_FILE} NAME)
|
||||||
|
if(EXISTS ${lammps_src_dir}/${FILENAME})
|
||||||
|
message(FATAL_ERROR "\n########################################################################\n"
|
||||||
|
"Found package(s) installed by the make-based build system\n"
|
||||||
|
"\n"
|
||||||
|
"Please run\n"
|
||||||
|
"make -C ${lammps_src_dir} no-all purge\n"
|
||||||
|
"to uninstall\n"
|
||||||
|
"########################################################################")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endfunction(DetectBuildSystemConflict)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# auto-generated style files
|
# auto-generated style files
|
||||||
style_angle.h
|
style_angle.h
|
||||||
style_atom.h
|
style_atom.h
|
||||||
|
style_body.h
|
||||||
style_bond.h
|
style_bond.h
|
||||||
style_command.h
|
style_command.h
|
||||||
style_compute.h
|
style_compute.h
|
||||||
|
@ -12,6 +13,7 @@ style_integrate.h
|
||||||
style_kspace.h
|
style_kspace.h
|
||||||
style_minimize.h
|
style_minimize.h
|
||||||
style_pair.h
|
style_pair.h
|
||||||
|
style_reader.h
|
||||||
style_region.h
|
style_region.h
|
||||||
style_neigh_bin.h
|
style_neigh_bin.h
|
||||||
style_neigh_pair.h
|
style_neigh_pair.h
|
||||||
|
|
Loading…
Reference in New Issue