Skip to content

Commit

Permalink
Merge branch 'release-v0.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
cartoonist committed Apr 8, 2021
2 parents 0794330 + 327f750 commit 558de30
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 22 deletions.
63 changes: 41 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
cmake_minimum_required(VERSION 3.10)
project(kseq++ VERSION 0.2.2 LANGUAGES CXX)
project(kseq++ VERSION 0.2.3 LANGUAGES CXX)

# Include external modules
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Finding dependencies.
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
find_package(Threads REQUIRED)

# Force CMake to use `-I` instead of `-isystem`
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)

# Defining the configure header file
configure_file(include/kseq++/config.hpp.in ${PROJECT_SOURCE_DIR}/include/kseq++/config.hpp @ONLY)
# Setting header files
file(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/include/kseq++/*.h")
# Creating an INTERFACE library
add_library(kseq++ INTERFACE)
# Defining target sources
target_sources(kseq++ INTERFACE "$<BUILD_INTERFACE:${HEADER_FILES}>")
# Defining include directories
target_include_directories(kseq++
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
INTERFACE ZLIB::ZLIB
INTERFACE BZip2::BZip2
INTERFACE Threads::Threads)
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>;$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/ZLIB::ZLIB>;$<INSTALL_INTERFACE:ZLIB::ZLIB>
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/BZip2::BZip2>;$<INSTALL_INTERFACE:BZip2::BZip2>
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Threads::Threads>;$<INSTALL_INTERFACE:Threads::Threads>)
# Defining link libraries
target_link_libraries(kseq++
INTERFACE ZLIB::ZLIB
INTERFACE BZip2::BZip2
INTERFACE Threads::Threads)
INTERFACE $<BUILD_INTERFACE:ZLIB::ZLIB>;$<INSTALL_INTERFACE:ZLIB::ZLIB>
INTERFACE $<BUILD_INTERFACE:BZip2::BZip2>;$<INSTALL_INTERFACE:BZip2::BZip2>
INTERFACE $<BUILD_INTERFACE:Threads::Threads>;$<INSTALL_INTERFACE:Threads::Threads>)
# Use C++17
target_compile_features(kseq++ INTERFACE cxx_std_11)
# Defining `kseq++::kseq++` alias
add_library(kseq++::kseq++ ALIAS kseq++)
# Generating the configure header file
configure_file(include/kseq++/config.hpp.in ${PROJECT_SOURCE_DIR}/include/kseq++/config.hpp @ONLY)
# Generating pkgconfig file
configure_file(kseq++.pc.in ${PROJECT_SOURCE_DIR}/kseq++.pc @ONLY)
# Setting header files
file(GLOB HEADER_FILES RELATIVE "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/include/kseq++/*.h")
list(TRANSFORM HEADER_FILES PREPEND "${PROJECT_SOURCE_DIR}/include/" OUTPUT_VARIABLE BUILD_HEADER_FILES)
list(TRANSFORM HEADER_FILES PREPEND "${CMAKE_INSTALL_FULL_INCLUDEDIR}/" OUTPUT_VARIABLE INSTALL_HEADER_FILES)
# Defining target sources
target_sources(kseq++
INTERFACE "$<BUILD_INTERFACE:${BUILD_HEADER_FILES}>;$<INSTALL_INTERFACE:${INSTALL_HEADER_FILES}>")
# Defining `kseq++::kseq++` alias
add_library(kseq++::kseq++ ALIAS kseq++)
# Install targets
install(DIRECTORY include/kseq++ DESTINATION include PATTERN "*.hpp.in" EXCLUDE)
install(FILES kseq++.pc DESTINATION lib/pkgconfig)
install(DIRECTORY include/kseq++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PATTERN "*.hpp.in" EXCLUDE)
install(FILES kseq++.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Exporting targets
install(TARGETS kseq++ EXPORT kseq++-targets)
install(EXPORT kseq++-targets NAMESPACE kseq++:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kseq++)
# Creating the package configuration file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/kseq++-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/kseq++-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kseq++)
# Generating the version file for the configuration file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/kseq++-config-version.cmake"
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
COMPATIBILITY AnyNewerVersion)
# Install generated configuration files
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kseq++-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/kseq++-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kseq++)
15 changes: 15 additions & 0 deletions cmake/kseq++-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(ZLIB REQUIRED)
find_dependency(BZip2 REQUIRED)
find_dependency(Threads REQUIRED)

if(NOT TARGET kseq++::kseq++)
include("${CMAKE_CURRENT_LIST_DIR}/kseq++-targets.cmake")
endif()

check_required_components(kseq++)

include("${CMAKE_CURRENT_LIST_DIR}/kseq++-config-version.cmake")
message(STATUS "Found kseq++ (version ${PACKAGE_VERSION})")

0 comments on commit 558de30

Please sign in to comment.