Skip to content

Commit

Permalink
wip better package
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Nov 11, 2024
1 parent b73aa47 commit 5998f04
Show file tree
Hide file tree
Showing 9 changed files with 2,575 additions and 24 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ include (CPM)
CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/cmake/package-lock.cmake)

# Use ccache if available. This speeds up the build process by caching files that have been compiled before.
CPMGetPackage (use_ccache)
include (use_ccache)
CPMGetPackage (seqan3)
CPMGetPackage (robin-hood)

# Add the application. This will include `src/CMakeLists.txt`.
add_subdirectory (src)

if (NEEDLE_TEST)
list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure;--no-tests=error") # Must be before `enable_testing ()`.
enable_testing ()
add_subdirectory (test EXCLUDE_FROM_ALL)
add_subdirectory (test)
endif ()

if (NEEDLE_DOCS)
Expand Down
10 changes: 9 additions & 1 deletion cmake/cpack_install.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@

# Only if creating the source package (`make package_source`).
if (CPACK_SOURCE_INSTALLED_DIRECTORIES)
file (COPY "@CPM_SOURCE_CACHE@" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file (COPY "@CPM_SOURCE_CACHE@" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN ".git" EXCLUDE PATTERN "cpm" EXCLUDE PATTERN "use_ccache" EXCLUDE)
if (EXISTS "@CPM_DOWNLOAD_LOCATION@")
file (READ "@CPM_DOWNLOAD_LOCATION@" FILE_CONTENTS)
string (REPLACE "find_package(Git REQUIRED)" "return()" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" "${FILE_CONTENTS}")
# configure_file ("@CPM_DOWNLOAD_LOCATION@" "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" COPYONLY)
configure_file ("@use_ccache_SOURCE_DIR@/ccache/CMakeLists.txt"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/use_ccache.cmake" COPYONLY)
endif ()
endif ()
11 changes: 0 additions & 11 deletions cmake/package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ CPMDeclarePackage (googletest
"CMAKE_CXX_STANDARD 20"
)

# robin-hood-hashing
set (NEEDLE_ROBIN_HOOD_VERSION 7697343363af4cc3f42cab17be49e6af9ab181e2)
CPMDeclarePackage (robin-hood
NAME robin-hood
GIT_TAG ${NEEDLE_ROBIN_HOOD_VERSION} # master
GITHUB_REPOSITORY martinus/robin-hood-hashing
SYSTEM TRUE
EXCLUDE_FROM_ALL TRUE
OPTIONS "CMAKE_MESSAGE_LOG_LEVEL WARNING"
)

# use_ccache
set (USE_CCACHE_VERSION d2a54ef555b6fc2d496a4c9506dbeb7cf899ce37)
CPMDeclarePackage (use_ccache
Expand Down
9 changes: 5 additions & 4 deletions cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ set (CPACK_PACKAGE_CHECKSUM "SHA256")
set (CPACK_RESOURCE_FILE_LICENSE "${needle_SOURCE_DIR}/LICENSE.md")
set (CPACK_RESOURCE_FILE_README "${needle_SOURCE_DIR}/README.md")

# Already being called on source package, i.e. CPM is already downloaded.
if (NOT CPM_DOWNLOAD_LOCATION)
set (CPM_DOWNLOAD_LOCATION "${needle_SOURCE_DIR}/cmake/CPM.cmake")
endif ()
include (CPM)
CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/package-lock.cmake)
include (use_ccache)

configure_file ("${needle_SOURCE_DIR}/cmake/cpack_install.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cpack_install.cmake"
@ONLY
Expand All @@ -51,5 +50,7 @@ list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.git($|/)")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.github/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.vscode/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/cmake/use_ccache.cmake")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/cmake/CPM.cmake")

include (CPack)
9 changes: 9 additions & 0 deletions cmake/use_ccache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required (VERSION 3.15...3.30)

# This file's only purpose is to be replaced with the content of the use_ccache CMakeLists.txt file
# when creating the source package.
CPMGetPackage (use_ccache)
Loading

0 comments on commit 5998f04

Please sign in to comment.