forked from lijiext/lammps
USER-PLUMED.cmake: use imported targets
This commit is contained in:
parent
a4a4562b03
commit
9e563da3eb
|
@ -5,13 +5,12 @@ if(PKG_USER-PLUMED)
|
|||
validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
|
||||
string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
|
||||
|
||||
set(PLUMED_LINK_LIBS "")
|
||||
set(PLUMED_LINK_LIBS)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
find_package(LAPACK REQUIRED)
|
||||
find_package(BLAS REQUIRED)
|
||||
find_package(GSL REQUIRED)
|
||||
list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
|
||||
list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} GSL::gsl)
|
||||
list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} GSL::gsl)
|
||||
find_package(ZLIB QUIET)
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND PLUMED_LINK_LIBS ZLIB::ZLIB)
|
||||
|
@ -70,31 +69,34 @@ if(PKG_USER-PLUMED)
|
|||
BUILD_BYPRODUCTS ${PLUMED_BUILD_BYPRODUCTS}
|
||||
)
|
||||
ExternalProject_get_property(plumed_build INSTALL_DIR)
|
||||
set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
|
||||
add_dependencies(lammps plumed_build)
|
||||
add_library(LAMMPS::PLUMED UNKNOWN IMPORTED)
|
||||
add_dependencies(LAMMPS::PLUMED plumed_build)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
target_compile_definitions(lammps PRIVATE -D__PLUMED_WRAPPER_CXX=1)
|
||||
target_link_libraries(lammps PRIVATE ${PLUMED_INSTALL_DIR}/lib/libplumed.a ${PLUMED_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_WRAPPER_CXX=1")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed.a INTERFACE_LINK_LIBRARIES "${PLUMED_LINK_LIBS};${CMAKE_DL_LIBS}")
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
target_link_libraries(lammps PRIVATE ${PLUMED_INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} ${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_DL_LIBS})
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX};${CMAKE_DL_LIBS}")
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
target_compile_definitions(lammps PRIVATE -D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
target_link_libraries(lammps PRIVATE ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS})
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_HAS_DLOPEN=1;__PLUMED_DEFAULT_KERNEL=${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumedWrapper.a INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(PLUMED REQUIRED plumed)
|
||||
add_library(LAMMPS::PLUMED INTERFACE IMPORTED)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
target_compile_definitions(lammps PRIVATE -D__PLUMED_WRAPPER_CXX=1)
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_WRAPPER_CXX=1")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
target_compile_definitions(lammps PRIVATE -D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_HAS_DLOPEN=1;__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE ${PLUMED_LOAD})
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
|
||||
endif()
|
||||
target_include_directories(lammps PRIVATE ${PLUMED_INCLUDE_DIRS})
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue