add tests whether simple examples for coupling to the LAMMPS library can run

This commit is contained in:
Axel Kohlmeyer
2022-10-29 03:46:52 -04:00
parent 83dcf24092
commit c157b2dea2
4 changed files with 62 additions and 15 deletions

View File

@ -1,17 +1,44 @@
cmake_minimum_required(VERSION 3.10)
project(simple CXX)
set(LAMMPS_SRC_DIRECTORY "" CACHE PATH "Path for lammps source")
if(NOT LAMMPS_SRC_DIRECTORY STREQUAL "" AND EXISTS ${LAMMPS_SRC_DIRECTORY}/cmake/CMakeLists.txt)
option(BUILD_LIB "Build LAMMPS library" ON)
add_subdirectory(${LAMMPS_SRC_DIRECTORY}/cmake lammps)
else()
# enforce out-of-source build
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds are not allowed. You must create and use a build directory. "
"Please remove CMakeCache.txt and CMakeFiles first.")
endif()
project(couple-simple VERSION 1.0 LANGUAGES C CXX)
# by default, install into $HOME/.local (not /usr/local),
# so that no root access (and sudo) is needed
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE)
endif()
# ugly hacks for MSVC which by default always reports an old C++ standard in the __cplusplus macro
# and prints lots of pointless warnings about "unsafe" functions
if(MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
if(LAMMPS_EXCEPTIONS)
add_compile_options(/EHsc)
endif()
endif()
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
find_package(MPI QUIET)
# do not include the (obsolete) MPI C++ bindings which makes
# for leaner object files and avoids namespace conflicts
set(MPI_CXX_SKIP_MPICXX TRUE)
##########################
# build within LAMMPS build system
if(NOT LAMMPS_SOURCE_DIR)
find_package(LAMMPS REQUIRED)
endif()
add_executable(simpleCC simple.cpp)
target_link_libraries(simpleCC LAMMPS::lammps)
enable_language(C)
add_executable(simpleC simple.c)
target_link_libraries(simpleC LAMMPS::lammps)