Skip to content

Commit

Permalink
Handle RawHash2 installation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed Jul 23, 2024
1 parent 1962e01 commit c677cb8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
project(RawHash2)
project(RawHash2Root)

add_subdirectory(src)
4 changes: 2 additions & 2 deletions cmake/SetupHDF5.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

function(add_hdf5_to_target TARGET_NAME)
if(NOHDF5)
Expand All @@ -7,7 +7,7 @@ function(add_hdf5_to_target TARGET_NAME)
if(HDF5_COMPILE)
add_dependencies(${TARGET_NAME} hdf5_build)
endif()
link_imported_library(${TARGET_NAME} hdf5 ${HDF5_DIR})
target_link_libraries(${TARGET_NAME} PRIVATE hdf5)
endif()
endfunction()

Expand Down
6 changes: 3 additions & 3 deletions cmake/SetupPOD5.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

function(add_zstd_to_target TARGET_NAME)
set(ZSTD_DIR ${EXTERNAL_PROJECTS_BUILD_DIR}/zstd)
add_dependencies(${TARGET_NAME} zstd_build)
link_imported_library(${TARGET_NAME} zstd ${ZSTD_DIR})
target_link_libraries(${TARGET_NAME} PRIVATE zstd)
endfunction()

function(setup_zstd)
Expand Down Expand Up @@ -100,7 +100,7 @@ endfunction()


# not working because of improper design, PARENT_SCOPE should not be used, rather define targets properly
# include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
# include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

# set(ZSTD_DIR ${EXTERNAL_PROJECTS_BUILD_DIR}/zstd)

Expand Down
2 changes: 1 addition & 1 deletion cmake/SetupRUClient.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

function(add_ruclient_to_target TARGET_NAME)
if(RUCLIENT_ENABLED)
Expand Down
4 changes: 2 additions & 2 deletions cmake/SetupSLOW5.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

function(add_slow5_to_target TARGET_NAME)
if(NOSLOW5)
Expand All @@ -7,7 +7,7 @@ function(add_slow5_to_target TARGET_NAME)
if(SLOW5_COMPILE)
add_dependencies(${TARGET_NAME} slow5_build)
endif()
link_imported_library(${TARGET_NAME} slow5 ${SLOW5_DIR})
target_link_libraries(${TARGET_NAME} PRIVATE slow5)
endif()
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion cmake/SetupTFLite.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/Util.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)

function(add_tflite_to_target TARGET_NAME)
target_link_libraries(${TARGET_NAME} PRIVATE tensorflow-lite)
Expand Down
18 changes: 9 additions & 9 deletions cmake/Util.cmake → cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ function(override_cached name value)
endfunction()


function(link_imported_library TARGET_NAME LIB_NAME LIB_DIR)
set_target_properties(${LIB_NAME} PROPERTIES
IMPORTED_LOCATION ${LIB_DIR}/lib/lib${LIB_NAME}.so
INTERFACE_INCLUDE_DIRECTORIES ${LIB_DIR}/include
)
target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_NAME})
endfunction()


function(define_imported_library LIB_NAME LIB_DIR)
add_library(${LIB_NAME} SHARED IMPORTED)
set_target_properties(${LIB_NAME} PROPERTIES
IMPORTED_LOCATION ${LIB_DIR}/lib/lib${LIB_NAME}.so
INTERFACE_INCLUDE_DIRECTORIES ${LIB_DIR}/include)
file(MAKE_DIRECTORY ${LIB_DIR}/include)
# Can't install(TARGETS ...) for external projects
# Also some .so are symlinks, so install all
install(DIRECTORY ${LIB_DIR}/lib/ DESTINATION lib
FILES_MATCHING PATTERN "*.so*")
install(DIRECTORY ${LIB_DIR}/include/
DESTINATION include/${PROJECT_NAME})
endfunction()


Expand Down
12 changes: 11 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(RawHash2Src)
project(RawHash2)

# option(USE_CCACHE "Use ccache to speed up rebuilds" ON)
# option(USE_MOLD "Use mold linker for faster linking" ON)
Expand Down Expand Up @@ -48,5 +48,15 @@ setup_rawhashlike_target(rawhash2)
add_library(rawhash2_wrapper SHARED rawhash_wrapper.cpp rawhash_wrapper.hpp)
setup_rawhashlike_target(rawhash2_wrapper)

file(GLOB_RECURSE HEADER_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.hpp)
set_property(TARGET rawhash2_wrapper PROPERTY PUBLIC_HEADER ${HEADER_FILES})
set_target_properties(rawhash2_wrapper PROPERTIES INSTALL_RPATH $ORIGIN)

add_executable(rawhash2_usinglib wrapper_example.cpp)
target_link_libraries(rawhash2_usinglib PRIVATE rawhash2_wrapper)
set_target_properties(rawhash2_usinglib PROPERTIES INSTALL_RPATH $ORIGIN/../lib)

install(TARGETS rawhash2_wrapper rawhash2_usinglib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME})

0 comments on commit c677cb8

Please sign in to comment.