Skip to content

Commit

Permalink
CPM fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
horta committed May 30, 2022
1 parent 9299ae0 commit 5992457
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 48 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ jobs:
if: matrix.os == 'windows-latest'
run: powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/horta/zlib.install/master/install.bat', 'install.bat')"; ./install.bat

- name: Install dependencies
shell: bash
run: if [ -f install-deps ]; then $SUDO ./install-deps; fi

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_SYSTEM_VERSION="10.0.19041.0"

Expand Down
81 changes: 41 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(bgen VERSION 4.1.5 LANGUAGES C)
set(PROJECT_DESCRIPTION "It fully supports the BGEN format specifications 1.2 and 1.3.")
project(
bgen
VERSION 4.1.6
LANGUAGES C)
set(PROJECT_DESCRIPTION
"It fully supports the BGEN format specifications 1.2 and 1.3.")

# Generate compile_commands.json file
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Set RPATH only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
Expand All @@ -17,9 +22,11 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(cmake/CPM.cmake)

cpmaddpackage(NAME elapsed GIT_TAG 3.0.5 GITHUB_REPOSITORY horta/elapsed)
cpmaddpackage(NAME athr GIT_TAG 4.0.1 GITHUB_REPOSITORY horta/almosthere)

find_package(elapsed REQUIRED)
find_package(athr REQUIRED)
find_package(ZLIB REQUIRED)
find_package(ZSTD REQUIRED)

Expand All @@ -37,8 +44,7 @@ add_library(
src/partition.c
src/bstring.c
src/zip/zlib.c
src/zip/zstd.c
)
src/zip/zstd.c)
add_library(BGEN::bgen ALIAS bgen)

if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
Expand Down Expand Up @@ -73,25 +79,27 @@ endif()

include(GenerateExportHeader)
generate_export_header(
bgen BASE_NAME BGEN
INCLUDE_GUARD_NAME BGEN_EXPORT_H
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/bgen/export.h
)
bgen
BASE_NAME
BGEN
INCLUDE_GUARD_NAME
BGEN_EXPORT_H
EXPORT_FILE_NAME
${CMAKE_CURRENT_BINARY_DIR}/bgen/export.h)

target_include_directories(
bgen
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set_target_properties(bgen PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(bgen PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
set_target_properties(bgen PROPERTIES C_STANDARD 99)
target_compile_definitions(bgen PRIVATE $<$<BOOL:${WIN32}>:_CRT_SECURE_NO_WARNINGS>)
target_compile_definitions(bgen PRIVATE $<$<BOOL:${WIN32}>:_CRT_NONSTDC_NO_DEPRECATE>)
target_compile_definitions(bgen
PRIVATE $<$<BOOL:${WIN32}>:_CRT_SECURE_NO_WARNINGS>)
target_compile_definitions(
bgen PRIVATE $<$<BOOL:${WIN32}>:_CRT_NONSTDC_NO_DEPRECATE>)
target_link_libraries(bgen PUBLIC ELAPSED::elapsed)
target_link_libraries(bgen PUBLIC ATHR::athr)
target_link_libraries(bgen PUBLIC ZLIB::ZLIB)
Expand All @@ -109,9 +117,9 @@ check_c_source_compiles(
static void f(char const* err, ...) __attribute__((format(printf, 1, 2)));
int main(void) {return 0;}
"
HAVE_ATTR_FORMAT
)
target_compile_definitions(bgen PRIVATE $<$<BOOL:${HAVE_ATTR_FORMAT}>:HAVE_ATTR_FORMAT>)
HAVE_ATTR_FORMAT)
target_compile_definitions(
bgen PRIVATE $<$<BOOL:${HAVE_ATTR_FORMAT}>:HAVE_ATTR_FORMAT>)

include(TestBigEndian)
test_big_endian(IS_BIG_ENDIAN)
Expand All @@ -120,35 +128,28 @@ if(IS_BIG_ENDIAN)
endif()

install(
TARGETS bgen EXPORT bgen-targets
TARGETS bgen
EXPORT bgen-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
PUBLIC_HEADER DESTINATION include)

install(DIRECTORY include/ DESTINATION include)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/bgen/export.h
DESTINATION include/bgen
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bgen/export.h
DESTINATION include/bgen)
install(
EXPORT bgen-targets
FILE bgen-targets.cmake
NAMESPACE BGEN::
DESTINATION lib/cmake/bgen
)
DESTINATION lib/cmake/bgen)
include(CMakePackageConfigHelpers)
configure_package_config_file(
bgen-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/bgen-config.cmake
bgen-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/bgen-config.cmake
INSTALL_DESTINATION lib/cmake/bgen
NO_SET_AND_CHECK_MACRO
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/bgen-config.cmake
DESTINATION lib/cmake/bgen
)
NO_SET_AND_CHECK_MACRO)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bgen-config.cmake
DESTINATION lib/cmake/bgen)

enable_testing()
add_subdirectory(test)
21 changes: 21 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(CPM_DOWNLOAD_VERSION 0.35.0)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()

include(${CPM_DOWNLOAD_LOCATION})
4 changes: 0 additions & 4 deletions install-deps

This file was deleted.

0 comments on commit 5992457

Please sign in to comment.