Skip to content
Permalink
Browse files

add a simple pvfmmConfig.cmake

  • Loading branch information
wenyan4work committed Mar 1, 2020
1 parent cf5db03 commit 6fa94a26ef64cc8cd3719d669e8b8029cd0dec8e
Showing with 27 additions and 4 deletions.
  1. +19 −4 CMakeLists.txt
  2. +8 −0 cmake/pvfmmConfig.cmake.in
@@ -69,8 +69,6 @@ endif()

configure_file(pvfmm_config.h.in pvfmm_config.h @ONLY)

enable_testing()

# part 1, core library
file(GLOB pvfmm_SRC "src/*.cpp")

@@ -83,7 +81,6 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
${CMAKE_BINARY_DIR} ${DEP_INC})
target_link_libraries(pvfmm PUBLIC ${DEP_LIB} OpenMP::OpenMP_CXX MPI::MPI_CXX)
target_compile_options(pvfmm PUBLIC ${OpenMP_CXX_FLAGS})

# static lib
add_library(pvfmmStatic STATIC ${pvfmm_SRC})
@@ -95,7 +92,25 @@ target_include_directories(
${CMAKE_BINARY_DIR} ${DEP_INC})
target_link_libraries(pvfmmStatic PUBLIC ${DEP_LIB} OpenMP::OpenMP_CXX
MPI::MPI_CXX)
target_compile_options(pvfmmStatic PUBLIC ${OpenMP_CXX_FLAGS})

# Config.cmake files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/pvfmmConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)

get_target_property(PVFMM_SHARED_NAME pvfmm OUTPUT_NAME)
get_target_property(PVFMM_STATIC_NAME pvfmmStatic OUTPUT_NAME)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/pvfmmConfig.cmake.in
${CMAKE_BINARY_DIR}/pvfmmConfig.cmake INSTALL_DESTINATION
${CMAKE_INSTALL_PREFIX}/share/pvfmm)

install(FILES ${CMAKE_BINARY_DIR}/pvfmmConfig.cmake
${CMAKE_BINARY_DIR}/pvfmmConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pvfmm)

# install core library and headers
include(GNUInstallDirs)
@@ -0,0 +1,8 @@
set(PVFMM_SHARED "@PVFMM_SHARED_NAME@")
set(PVFMM_STATIC "@PVFMM_STATIC_NAME@")
set(PVFMM_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
set(PVFMM_DEP_LIB "@DEP_LIB@")
set(PVFMM_DEP_INCLUDE_DIR "@DEP_INC@")
# TODO: not working yet
# set(PVFMM_COMPILE_FLAGS "@PVFMM_COMPILE_FLAGS@")
# set(PVFMM_COMPILE_OPTIONS "@PVFMM_COMPILE_OPTIONS@")

0 comments on commit 6fa94a2

Please sign in to comment.
You can’t perform that action at this time.