cmake: make incl. dir work under windows as well

This commit is contained in:
Christoph Junghans 2020-03-28 09:30:02 -06:00
parent 4aadb554a3
commit b331b2db10
1 changed files with 9 additions and 6 deletions

View File

@ -612,12 +612,15 @@ 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 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps)
foreach(_HEADER ${LAMMPS_CXX_HEADERS})
get_filename_component(_HEADER_FILE ${_HEADER} NAME)
set(_FULL_HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER_FILE})
add_custom_command(OUTPUT ${_FULL_HEADER_FILE} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_HEADER} ${_FULL_HEADER_FILE} DEPENDS ${_HEADER})
add_custom_target(${_HEADER_FILE} DEPENDS ${_FULL_HEADER_FILE})
add_dependencies(lammps ${_HEADER_FILE})
endforeach()
target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>)
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)