Skip to content

Commit

Permalink
CMakeLists for library build
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Kramer committed Jan 11, 2024
1 parent 3f6e304 commit a9c92fe
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,44 @@ if(Protobuf_FOUND)
message(STATUS "Found Protocol Buffers: ${Protobuf_VERSION}")
endif()


FIND_PACKAGE(Boost COMPONENTS system filesystem program_options unit_test_framework iostreams date_time REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

# include("./vcpkg.cmake")
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)

include(${TBB_DIR}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_DIR} CONFIG_DIR TBB_DIR MAKE_ARGS arch=arm64 tbb_cpf=1)
find_package(TBB REQUIRED tbbmalloc tbbmalloc_proxy tbb_preview)

# FIND_PACKAGE(ZLIB COMPONENTS ZLIB REQUIRED)

# minimap2
add_custom_target(libminimap2.a
COMMAND make arm_neon=1 aarch64=1 libminimap2.a
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/minimap2_src/
)
add_custom_target(clean-minimap
COMMAND make clean
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/minimap2_src/
)
file(GLOB PANMAT_SRCS "src/align_from_seeds.c" "src/main.cpp" "src/PangenomeMAT.cpp" "src/PangenomeMAT.hpp" "src/minimap2_src/libminimap2.a" "src/kseq.h")
file(GLOB TEST_SRCS "src/align_from_seeds.c" "src/PangenomeMAT.cpp" "src/PangenomeMAT.hpp" "src/minimap2_src/libminimap2.a" "src/kseq.h" "src/test/*.cpp")

file(GLOB PANMAT_SRCS "src/main.cpp" "src/PangenomeMAT.cpp" "src/PangenomeMAT.hpp")
file(GLOB PANMAT_LIB_SRCS "src/PangenomeMAT.cpp" "src/PangenomeMAT.hpp")

# targets
add_executable(panmat-utils ${PANMAT_SRCS})
add_executable(tests ${TEST_SRCS})


protobuf_generate(LANGUAGE cpp
TARGET panmat-utils
PROTOS mutation_annotation_test_proto3_optional_new.proto)
protobuf_generate(LANGUAGE cpp
TARGET tests
PROTOS mutation_annotation_test_proto3_optional_new.proto)

add_dependencies(panmat-utils libminimap2.a)
add_dependencies(tests libminimap2.a)

set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/clean-minimap)

target_compile_options(panmat-utils PRIVATE -DTBB_SUPPRESS_DEPRECATED_MESSAGES)
target_compile_options(tests PRIVATE -DTBB_SUPPRESS_DEPRECATED_MESSAGES)
target_link_libraries(panmat-utils PRIVATE ${JSONCPP_LINK_LIBRARIES} ${spoa_DIR}/build/lib/libspoa.a stdc++ ${Boost_LIBRARIES} ${TBB_IMPORTED_TARGETS} protobuf::libprotobuf z)
target_include_directories(panmat-utils PUBLIC "${PROJECT_BINARY_DIR}" ${spoa_DIR}/include)


target_link_libraries(panmat-utils PRIVATE ${JSONCPP_LINK_LIBRARIES} ${spoa_DIR}/build/lib/libspoa.a stdc++ ${Boost_LIBRARIES} ${TBB_IMPORTED_TARGETS} protobuf::libprotobuf ${CMAKE_SOURCE_DIR}/src/minimap2_src/libminimap2.a z)
target_link_libraries(tests PRIVATE ${JSONCPP_LINK_LIBRARIES} ${spoa_DIR}/build/lib/libspoa.a stdc++ ${Boost_LIBRARIES} ${TBB_IMPORTED_TARGETS} protobuf::libprotobuf ${CMAKE_SOURCE_DIR}/src/minimap2_src/libminimap2.a z)

target_include_directories(panmat-utils PUBLIC "${PROJECT_BINARY_DIR}" ${spoa_DIR}/include)
add_library(libpanmat SHARED ${PANMAT_LIB_SRCS})
protobuf_generate(LANGUAGE cpp
TARGET libpanmat
PROTOS mutation_annotation_test_proto3_optional_new.proto)
target_link_libraries(libpanmat PRIVATE ${JSONCPP_LINK_LIBRARIES} ${spoa_DIR}/build/lib/libspoa.a stdc++ ${Boost_LIBRARIES} ${TBB_IMPORTED_TARGETS} protobuf::libprotobuf z)
target_include_directories(libpanmat PUBLIC "${PROJECT_BINARY_DIR}" ${spoa_DIR}/include)
set_target_properties(libpanmat PROPERTIES PUBLIC_HEADER src/PangenomeMAT.hpp)
export(TARGETS libpanmat FILE libpanmatConfig.cmake)

configure_file(src/PangenomeMAT.hpp include/PangenomeMAT.hpp COPYONLY)
install(TARGETS libpanmat
ARCHIVE DESTINATION "lib"
LIBRARY DESTINATION "lib"
PUBLIC_HEADER DESTINATION "include"
)

0 comments on commit a9c92fe

Please sign in to comment.