Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cmake target and config export for parmmg to support find package #137

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,14 @@ SET(CMAKE_MACOSX_RPATH 1)
#####
############################################################################
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
add_library( ParMmg INTERFACE )

IF ( LIBPARMMG_STATIC )
ADD_AND_INSTALL_LIBRARY ( lib${PROJECT_NAME}_a STATIC
"${pmmg_library_files}" ${PROJECT_NAME} )

target_link_libraries( ParMmg INTERFACE lib${PROJECT_NAME}_a )

IF ( DOWNLOAD_MMG )
Add_Dependencies(lib${PROJECT_NAME}_a Mmg)
ENDIF ( )
Expand All @@ -505,6 +508,8 @@ IF ( LIBPARMMG_SHARED )
ADD_AND_INSTALL_LIBRARY ( lib${PROJECT_NAME}_so SHARED
"${pmmg_library_files}" ${PROJECT_NAME} )

target_link_libraries( ParMmg INTERFACE lib${PROJECT_NAME}_so )

IF ( DOWNLOAD_MMG )
Add_Dependencies(lib${PROJECT_NAME}_so Mmg)
ENDIF ( )
Expand All @@ -515,6 +520,14 @@ IF ( LIBPARMMG_SHARED )

ENDIF()

add_library(ParMmg::ParMmg ALIAS ParMmg)
install(TARGETS ParMmg EXPORT ParMmgTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/parmmg
)

# parmmg header files needed for library
SET( pmmg_headers
${PMMG_SOURCE_DIR}/libparmmg.h
Expand All @@ -540,12 +553,45 @@ ELSE()
SET(LIBPARMMG_INTERNAL OFF )
ENDIF()

if ( BUILD_SHARED_LIBS )
set(LIBPARMMG lib${PROJECT_NAME}_so)
else()
set(LIBPARMMG lib${PROJECT_NAME}_a)
endif()

install(EXPORT ParMmgTargets
FILE ParMmgTargets.cmake
NAMESPACE ParMmg::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/parmmg
)


include(CMakePackageConfigHelpers)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ParMmgConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ParMmgConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/parmmg"
)

# Install ParMmgConfig.cmake and ParMmgConfigVersion.cmake
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/ParMmgConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/parmmg"
)

# Install ParMmgConfigVersion.cmake for version tracking
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ParMmgConfigVersion.cmake"
VERSION ${CMAKE_RELEASE_VERSION}
COMPATIBILITY AnyNewerVersion
)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/ParMmgConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/parmmg"
)

###############################################################################
#####
##### Compile PMMG executable
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/ParMmgConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

include("${CMAKE_CURRENT_LIST_DIR}/ParMmgTargets.cmake")
1 change: 0 additions & 1 deletion cmake/modules/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ MACRO ( ADD_AND_INSTALL_LIBRARY
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
Component lib
)
ENDMACRO ( )

Expand Down
Loading