cmake: minor improvement for MSCG

This commit is contained in:
Christoph Junghans
2018-05-17 20:01:33 -06:00
parent 68dd7d4f2b
commit 9e82c86fbd

View File

@ -397,6 +397,7 @@ if(PKG_KIM)
endif()
if(PKG_MSCG)
find_package(GSL REQUIRED)
option(DOWNLOAD_MSCG "Download latte (instead of using the system's one)" OFF)
if(DOWNLOAD_MSCG)
include(ExternalProject)
@ -404,14 +405,16 @@ if(PKG_MSCG)
set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a")
endif()
ExternalProject_Add(mscg_build
URL https://github.com//uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
URL_MD5 8c45e269ee13f60b303edd7823866a91
SOURCE_SUBDIR src/CMake
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} ${EXTRA_MSCG_OPTS}
BUILD_COMMAND make mscg INSTALL_COMMAND ""
)
ExternalProject_get_property(mscg_build INSTALL_DIR)
set(MSCG_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libmscg.a)
set(MSCG_INCLUDE_DIRS ${INSTALL_DIR}/include/mscg)
ExternalProject_get_property(mscg_build BINARY_DIR)
set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a)
ExternalProject_get_property(mscg_build SOURCE_DIR)
set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src)
list(APPEND LAMMPS_DEPS mscg_build)
if(NOT LAPACK_FOUND)
add_dependencies(mscg_build linalg)
@ -422,7 +425,7 @@ if(PKG_MSCG)
message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
endif()
endif()
list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES})
list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES})
include_directories(${MSCG_INCLUDE_DIRS})
endif()