forked from lijiext/lammps
Simplify build system conflict checks
- removes redundant code for conflict checks - updates and expands original check to report fatal error instead of ignoring files - removes obsolete DetectAndRemovePackageHeader and RemovePackageHeader utility functions which are no longer needed - adds utility function DetectBuildSystemConflict, which loops over files and reports an error if they exist in the lammps src directory. - updates definition of LAMMPS_SOURCE_DIR, LAMMPS_LIB_SOURCE_DIR and LAMMPS_LIB_BINARY_DIR to be absolute paths. This improves instructions in error messages
This commit is contained in:
parent
62984c1de0
commit
e2c03f0596
|
@ -6,9 +6,10 @@ cmake_minimum_required(VERSION 2.8.12)
|
|||
|
||||
project(lammps CXX)
|
||||
set(SOVERSION 0)
|
||||
set(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
set(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
||||
set(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib)
|
||||
get_filename_component(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src ABSOLUTE)
|
||||
get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib ABSOLUTE)
|
||||
get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE)
|
||||
|
||||
|
||||
#To not conflict with old Makefile build system, we build everything here
|
||||
file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/*.cpp)
|
||||
|
@ -23,9 +24,6 @@ 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)
|
||||
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
|
||||
|
||||
file(GLOB SRC_FILES ${LAMMPS_SOURCE_DIR}/*.cpp)
|
||||
list(SORT SRC_FILES)
|
||||
|
||||
# check for files auto-generated by make-based buildsystem
|
||||
# this is fast, so check for it all the time
|
||||
message(STATUS "Running check for auto-generated files from make-based build system")
|
||||
|
@ -34,24 +32,16 @@ list(APPEND SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h)
|
|||
foreach(_SRC ${SRC_AUTOGEN_FILES})
|
||||
get_filename_component(FILENAME "${_SRC}" NAME)
|
||||
if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME})
|
||||
message(FATAL_ERROR "\nFound header file(s) generated by the make-based build system.\nPlease run 'make -C ${LAMMPS_SOURCE_DIR} purge' to remove")
|
||||
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()
|
||||
endforeach()
|
||||
|
||||
# check for files from packages installed by the make-based buildsystem
|
||||
# this is slow, so only run this check if there are new files
|
||||
if(NOT SRC_FILES STREQUAL SRC_FILES_CACHED)
|
||||
file(GLOB SRC_PKG_FILES ${LAMMPS_SOURCE_DIR}/*/*.cpp)
|
||||
message(STATUS "Running check for packages installed with 'make yes-<package>' (this may take a while)")
|
||||
foreach(_SRC ${SRC_PKG_FILES})
|
||||
get_filename_component(FILENAME "${_SRC}" NAME)
|
||||
if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME})
|
||||
message(FATAL_ERROR "\nFound package(s) installed by the make-based build system\nPlease run 'make -C ${LAMMPS_SOURCE_DIR} no-all purge' to uninstall")
|
||||
endif()
|
||||
endforeach()
|
||||
set(SRC_FILES_CACHED "${SRC_FILES}" CACHE INTERNAL "List of file in LAMMPS_SOURCE_DIR" FORCE)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# compiler tests
|
||||
# these need ot be done early (before further tests).
|
||||
|
@ -478,20 +468,11 @@ RegisterStyles(${LAMMPS_SOURCE_DIR})
|
|||
foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES})
|
||||
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}_HEADERS ${${PKG}_SOURCES_DIR}/*.h)
|
||||
|
||||
foreach(PKG_FILE in ${${PKG}_SOURCES})
|
||||
get_filename_component(FNAME ${PKG_FILE} NAME)
|
||||
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()
|
||||
# check for package files in src directory due to old make system
|
||||
DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS})
|
||||
|
||||
if(PKG_${PKG})
|
||||
# detects styles in package and adds them to global list
|
||||
|
@ -502,6 +483,17 @@ foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES})
|
|||
endif()
|
||||
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
|
||||
############################################
|
||||
|
|
|
@ -107,35 +107,6 @@ function(RegisterStyles search_path)
|
|||
FindStyleHeaders(${search_path} REGION_CLASS region_ REGION ) # region ) # domain
|
||||
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)
|
||||
FindStyleHeadersExt(${search_path} ANGLE_CLASS ${extension} ANGLE ${sources})
|
||||
FindStyleHeadersExt(${search_path} ATOM_CLASS ${extension} ATOM_VEC ${sources})
|
||||
|
@ -181,3 +152,25 @@ function(GenerateStyleHeaders output_path)
|
|||
GenerateStyleHeader(${output_path} READER reader ) # read_dump
|
||||
GenerateStyleHeader(${output_path} REGION region ) # domain
|
||||
endfunction(GenerateStyleHeaders)
|
||||
|
||||
function(DetectBuildSystemConflict lammps_src_dir)
|
||||
math(EXPR N "${ARGC}-1")
|
||||
|
||||
if(N GREATER 0)
|
||||
math(EXPR ARG_END "${ARGC}-1")
|
||||
|
||||
foreach(IDX RANGE 1 ${ARG_END})
|
||||
list(GET ARGV ${IDX} SRC_FILE)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue