From 4aadb554a3dd1fb2af15a8f022446740e11ea939 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sat, 28 Mar 2020 08:43:13 -0600 Subject: [PATCH] cmake: replace incl. dir hack by even better hack --- cmake/CMakeLists.txt | 6 ++++++ examples/COUPLE/simple/CMakeLists.txt | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c06bee1ebe..f10392e700 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -612,6 +612,12 @@ if(BUILD_LIB) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_include_directories(lammps PUBLIC $) + option(LAMMPS_CREATE_IN_SOURCES_INCLUDE_DIR "include in-source lammps/ include dir" OFF) + if(LAMMPS_CREATE_IN_SOURCES_INCLUDE_DIR) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${LAMMPS_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps) + target_include_directories(lammps INTERFACE $) + endif() add_library(LAMMPS::lammps ALIAS lammps) install(FILES ${LAMMPS_CXX_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc @ONLY) diff --git a/examples/COUPLE/simple/CMakeLists.txt b/examples/COUPLE/simple/CMakeLists.txt index c5b6b96edd..f4cf680f61 100644 --- a/examples/COUPLE/simple/CMakeLists.txt +++ b/examples/COUPLE/simple/CMakeLists.txt @@ -4,10 +4,8 @@ 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) + option(LAMMPS_CREATE_IN_SOURCES_INCLUDE_DIR "include in-source lammps/ include dir" ON) add_subdirectory(${LAMMPS_SRC_DIRECTORY}/cmake lammps) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${LAMMPS_SRC_DIRECTORY}/src ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps) - target_include_directories(lammps INTERFACE $) else() find_package(LAMMPS REQUIRED) endif()