Compile linalg as library and track link dependencies for correct link order

This commit is contained in:
Richard Berger 2017-08-27 03:54:40 -04:00
parent 67ae2719a8
commit 76926b7fcf
1 changed files with 23 additions and 4 deletions

View File

@ -162,12 +162,23 @@ endif()
if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP)
find_package(LAPACK)
if(LAPACK_FOUND)
list(APPEND LAMMPS_LINK_LIBS ${LAPACK_LIBRARIES})
else()
if(NOT LAPACK_FOUND)
enable_language(Fortran)
file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/*.f)
list(APPEND LIB_SOURCES ${LAPACK_SOURCES})
if(BUILD_SHARED_PKG_LIBS)
add_library(linalg SHARED ${LAPACK_SOURCES})
set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION})
if(INSTALL_LIB)
install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library")
endif()
else()
add_library(linalg STATIC ${LAPACK_SOURCES})
endif()
target_compile_options(linalg PRIVATE -fno-second-underscore)
set(LAPACK_LIBRARIES linalg)
endif()
endif()
@ -368,6 +379,14 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD
endif()
endforeach()
if(ENABLE_USER-AWPMD)
target_link_libraries(awpmd ${LAPACK_LIBRARIES})
endif()
if(ENABLE_USER-ATC)
target_link_libraries(atc ${LAPACK_LIBRARIES})
endif()
if(ENABLE_USER-H5MD)
find_package(HDF5 REQUIRED)
target_link_libraries(h5md ${HDF5_LIBRARIES})