Can I pull in LAMMPS as an external dependency using CMake? – #3 by akohlmey – LAMMPS Development

Hi LAMMPS developers,

Is there any way for me to find_package(LAMMPS) in a CMakeLists.txt and get back the path to the LAMMPS shared library and header files?

Currently, I can run find_package(LAMMPS REQUIRED) without errors (as long as I’ve run make install and the prefix folder is in my $PATH), but it only sets $LAMMPS_FOUND. $LAMMPS_LIBRARY, $LAMMPS_INCLUDE_DIR, etc, are all empty. For example, the following CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project(chromatin C CXX Fortran)
find_package(LAMMPS REQUIRED)
if (${LAMMPS_FOUND})
    message("Found LAMMPS")
    message("${LAMMPS_INCLUDE_DIR}")
    message("${LAMMPS_INCLUDES}")
    message("${LAMMPS_LIBRARY}")
    message("${LAMMPS_LIBS}")
    message("${LAMMPS_LIBRARIES}")
    message("${LAMMPS_VERSION_STRING}")
endif(${LAMMPS_FOUND})

Produces the following output:

[...]
-- Found MPI: TRUE (found version "3.1") found components: CXX 
Found LAMMPS






-- Configuring done
[...]

I can provide the whole CMakeLists.txt, output, logs, etc, but it’ll have to be in a pastebin as I can’t upload files.

Thanks!

Misc info:

  • OS: Pop!_OS 21.04
  • CMake version: 3.18.4
  • LAMMPS version: current master branch

Read more here: Source link