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

CMake package config #412

Merged
merged 5 commits into from
Mar 12, 2021
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
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,36 @@ set(TARGET_LIBDFT "sleefdft")
# Check subdirectories
add_subdirectory("src")

# Install the CMake package config
include(CMakePackageConfigHelpers)

write_basic_package_version_file(
sleefConfigVersion.cmake
COMPATIBILITY SameMajorVersion
friendlyanon marked this conversation as resolved.
Show resolved Hide resolved
)

set(
SLEEF_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/sleef"
CACHE STRING "CMake package config location relative to the install prefix"
)

mark_as_advanced(SLEEF_INSTALL_CMAKEDIR)

install(
FILES
"${PROJECT_SOURCE_DIR}/sleefConfig.cmake"
"${PROJECT_BINARY_DIR}/sleefConfigVersion.cmake"
DESTINATION "${SLEEF_INSTALL_CMAKEDIR}"
COMPONENT sleef_Development
)

install(
EXPORT sleefTargets
NAMESPACE sleef::
DESTINATION "${SLEEF_INSTALL_CMAKEDIR}"
COMPONENT sleef_Development
)

# Extra messages at configuration time. By default is active, it can be
# turned off by invoking cmake with "-DSLEEF_SHOW_CONFIG=OFF".
if(SLEEF_SHOW_CONFIG)
Expand Down
1 change: 1 addition & 0 deletions sleefConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/sleefTargets.cmake")
31 changes: 26 additions & 5 deletions src/dft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,30 @@ set_target_properties(${TARGET_LIBDFT} PROPERTIES
)

# Install
install(TARGETS ${TARGET_LIBDFT}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
install(
TARGETS ${TARGET_LIBDFT}
EXPORT sleefTargets
PUBLIC_HEADER #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT sleef_Development
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Runtime
NAMELINK_SKIP
ARCHIVE #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
RUNTIME #
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
TARGETS ${TARGET_LIBDFT}
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
121 changes: 101 additions & 20 deletions src/libm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,31 @@ if(BUILD_INLINE_HEADERS)

#

add_custom_target(${TARGET_INLINE_HEADERS} ALL
add_custom_target(${TARGET_INLINE_HEADERS}_util ALL
DEPENDS
${INLINE_HEADER_FILES_GENERATED}
)
install(FILES ${INLINE_HEADER_FILES_GENERATED} DESTINATION include)

add_library("${TARGET_INLINE_HEADERS}" INTERFACE)
add_dependencies("${TARGET_INLINE_HEADERS}" "${TARGET_INLINE_HEADERS}_util")
target_include_directories(
"${TARGET_INLINE_HEADERS}"
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
)

# CMake 3.4 can't have PUBLIC_HEADER property on INTERFACE libraries
install(
FILES ${INLINE_HEADER_FILES_GENERATED}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
friendlyanon marked this conversation as resolved.
Show resolved Hide resolved
COMPONENT sleef_Development
)

install(
TARGETS "${TARGET_INLINE_HEADERS}"
EXPORT sleefTargets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif(SED_COMMAND)
endif(BUILD_INLINE_HEADERS)

Expand Down Expand Up @@ -966,7 +986,11 @@ if(CLANG_EXE_PATH AND SLEEF_ENABLE_LLVM_BITCODE)
)
add_dependencies(${TARGET_LLVM_BITCODE} ${TARGET_HEADERS})

install(FILES ${LLVM_BITCODE_OUTPUTS} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
FILES ${LLVM_BITCODE_OUTPUTS}
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
)
endif()

# --------------------------------------------------------------------
Expand All @@ -992,31 +1016,88 @@ if(COMPILER_SUPPORTS_BUILTIN_MATH)
endif()

if(BUILD_SCALAR_LIB)
install(TARGETS sleefscalar
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
)
install(
TARGETS sleefscalar
EXPORT sleefTargets
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Runtime
NAMELINK_SKIP
ARCHIVE #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
RUNTIME #
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
)

install(
TARGETS sleefscalar
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
endif()

# --------------------------------------------------------------------
# Install
# --------------------------------------------------------------------
# Install libsleef and sleef.h
install(TARGETS ${TARGET_LIBSLEEF}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
install(
TARGETS ${TARGET_LIBSLEEF}
EXPORT sleefTargets
PUBLIC_HEADER #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT sleef_Development
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Runtime
NAMELINK_SKIP
ARCHIVE #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
RUNTIME #
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
TARGETS ${TARGET_LIBSLEEF}
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
configure_file("sleef.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT sleef_Development
)

if(ENABLE_GNUABI)
install(TARGETS ${TARGET_LIBSLEEFGNUABI}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
)
install(
TARGETS ${TARGET_LIBSLEEFGNUABI}
EXPORT sleefTargets
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Runtime
NAMELINK_SKIP
ARCHIVE #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
RUNTIME #
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
)

install(
TARGETS ${TARGET_LIBSLEEF}
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
endif()
37 changes: 31 additions & 6 deletions src/quad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ if(BUILD_INLINE_HEADERS)
DEPENDS
${INLINE_HEADER_FILES_GENERATED}
)
install(FILES ${INLINE_HEADER_FILES_GENERATED} DESTINATION include)
install(
FILES ${INLINE_HEADER_FILES_GENERATED}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT sleef_Development
)
endif(SED_COMMAND)
endif(BUILD_INLINE_HEADERS)

Expand Down Expand Up @@ -485,9 +489,30 @@ endif(DEFINED QMKDISP_PARAMS_X2)
# Install
# --------------------------------------------------------------------
# Install libsleef and sleef.h
install(TARGETS sleefquad
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
install(
TARGETS sleefquad
EXPORT sleefTargets
PUBLIC_HEADER #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT sleef_Development
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Runtime
NAMELINK_SKIP
ARCHIVE #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
RUNTIME #
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
TARGETS sleefquad
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)