Skip to content

Commit

Permalink
Merge branch 'update-build-pipeline' into mgems-release-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaklin committed Jun 4, 2024
2 parents f35e4df + 0ce98ad commit 45c2c35
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 224 deletions.
310 changes: 188 additions & 122 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required (VERSION 2.8.12)
cmake_minimum_required (VERSION 3.11)
project (mGEMS)
include(FetchContent)

set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
Expand All @@ -24,161 +25,233 @@ endif()
## mGEMS executable
add_executable(mGEMS ${CMAKE_CURRENT_SOURCE_DIR}/src/mGEMS.cpp)

## Check supported compression types
find_package(BZip2)
if (BZIP2_FOUND)
include_directories(${BZIP2_INCLUDE_DIRS})
## mGEMS library
add_library(libmgems
${CMAKE_CURRENT_SOURCE_DIR}/src/bin_reads.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/extract_bin.cpp
)
set_target_properties(libmgems PROPERTIES OUTPUT_NAME mgems)

## Dependencies
### OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
target_link_libraries(mGEMS OpenMP::OpenMP_CXX)
target_link_libraries(libmgems OpenMP::OpenMP_CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_PARALLEL")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -D_GLIBCXX_PARALLEL")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -D_GLIBCXX_PARALLEL")
endif()

### Check supported compression types
#### zlib
if ((DEFINED ZLIB_LIBRARY AND DEFINED ZLIB_INCLUDE_DIR) AND (NOT DEFINED ZLIB_FOUND))
message(STATUS "zlib library provided in: " ${ZLIB_LIBRARY})
message(STATUS "zlib headers provided in: " ${ZLIB_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR})
target_link_libraries(mGEMS ${ZLIB_LIBRARY})
target_link_libraries(libmgems ${ZLIB_LIBRARY})
set(MGEMS_HAVE_ZLIB 1)
else()
find_package(ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
target_link_libraries(mGEMS ${ZLIB_LIBRARY})
target_link_libraries(libmgems ${ZLIB_LIBRARY})
set(MGEMS_HAVE_ZLIB 1)
else()
set(MGEMS_HAVE_ZLIB 0)
endif()
endif()

#### bzip2
if (DEFINED BZIP2_LIBRARIES AND DEFINED BZIP2_INCLUDE_DIR AND (NOT DEFINED BZIP2_FOUND))
message(STATUS "bzip2 library provided in: " ${BZIP2_LIBRARIES})
message(STATUS "bzip2 headers provided in: " ${BZIP2_INCLUDE_DIR})
include_directories(${BZIP2_INCLUDE_DIR})
target_link_libraries(mGEMS ${BZIP2_LIBRARIES})
endif()
find_package(LibLZMA)
if (LIBLZMA_FOUND)
include_directories(${LIBLZMA_INCLUDE_DIRS})
target_link_libraries(mGEMS ${LIBLZMA_LIBRARIES})
target_link_libraries(libmgems ${BZIP2_LIBRARIES})
set(MGEMS_HAVE_BZIP2 1)
else()
find_package(BZip2)
if (BZIP2_FOUND)
include_directories(${BZIP2_INCLUDE_DIR})
target_link_libraries(mGEMS ${BZIP2_LIBRARIES})
target_link_libraries(libmgems ${BZIP2_LIBRARIES})
set(MGEMS_HAVE_BZIP2 1)
else()
set(MGEMS_HAVE_BZIP2 0)
endif()
endif()
find_package(ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(mGEMS ${ZLIB_LIBRARIES})

#### lzma
if (DEFINED LIBLZMA_LIBRARY AND DEFINED LIBLZMA_INCLUDE_DIR AND (NOT DEFINED LIBLZMA_FOUND))
message(STATUS "liblzma library provided in: " ${LIBLZMA_LIBRARY})
message(STATUS "liblzma headers provided in: " ${LIBLZMA_INCLUDE_DIR})
include_directories(${LIBLZMA_INCLUDE_DIR})
target_link_libraries(mGEMS ${LIBLZMA_LIBRARY})
target_link_libraries(libmgems ${LIBLZMA_LIBRARY})
set(MGEMS_HAVE_LIBLZMA 1)
else()
find_package(LibLZMA)
if (LIBLZMA_FOUND)
include_directories(${LIBLZMA_INCLUDE_DIR})
target_link_libraries(mGEMS ${LIBLZMA_LIBRARY})
target_link_libraries(libmgems ${LIBLZMA_LIBRARY})
set(MGEMS_HAVE_LIBLZMA 1)
else()
set(MGEMS_HAVE_LIBLZMA 0)
endif()
endif()

## bxzstr
if (DEFINED CMAKE_BXZSTR_HEADERS)
message(STATUS "bxzstr headers provided in: ${CMAKE_BXZSTR_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-bxzstr.txt.in ${CMAKE_CURRENT_BINARY_DIR}/external/bxzstr-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/bxzstr-download )
if(result)
message(FATAL_ERROR "CMake step for bxzstr failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/bxzstr-download )
if(result)
message(FATAL_ERROR "Build step for bxzstr failed: ${result}")
endif()
set(CMAKE_BXZSTR_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/bxzstr/include)
FetchContent_Declare(bxzstr
GIT_REPOSITORY https://github.com/tmaklin/bxzstr.git
GIT_TAG v1.1.0
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/bxzstr"
BUILD_IN_SOURCE 0
CMAKE_ARGS -D ZSTD_FOUND=0
-D ZLIB_FOUND=${MGEMS_HAVE_ZLIB}
-D BZIP2_FOUND=${MGEMS_HAVE_BZIP2}
-D LIBLZMA_FOUND=${MGEMS_HAVE_LIBLZMA}
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(bxzstr)
set(CMAKE_BXZSTR_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/bxzstr/include)
endif()
include_directories(${CMAKE_BXZSTR_HEADERS})

## cxxargs
if (DEFINED CMAKE_CXXARGS_HEADERS)
message(STATUS "cxxargs headers provided in: ${CMAKE_CXXARGS_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-cxxargs.txt.in ${CMAKE_CURRENT_BINARY_DIR}/external/cxxargs-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/cxxargs-download )
if(result)
message(FATAL_ERROR "CMake step for cxxargs failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/cxxargs-download )
if(result)
message(FATAL_ERROR "Build step for cxxargs failed: ${result}")
endif()
set(CMAKE_CXXARGS_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/cxxargs/include)
FetchContent_Declare(cxxargs
GIT_REPOSITORY https://github.com/tmaklin/cxxargs.git
GIT_TAG v1.1.4
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/cxxargs"
BUILD_IN_SOURCE 0
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(cxxargs)
set(CMAKE_CXXARGS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/cxxargs/include)
endif()
include_directories("${CMAKE_CXXARGS_HEADERS}")

## Check dependencies and download them if not given
## cxxio
if (DEFINED CMAKE_CXXIO_HEADERS)
message(STATUS "cxxio headers provided in: ${CMAKE_CXXIO_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-cxxio.txt.in ${CMAKE_CURRENT_BINARY_DIR}/external/cxxio-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/cxxio-download )
if(result)
message(FATAL_ERROR "CMake step for cxxio failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/cxxio-download )
if(result)
message(FATAL_ERROR "Build step for cxxio failed: ${result}")
endif()
set(CMAKE_CXXIO_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/cxxio/include)
FetchContent_Declare(cxxio
GIT_REPOSITORY https://github.com/tmaklin/cxxio.git
GIT_TAG v0.1.0
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/cxxio"
BUILD_IN_SOURCE 0
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(cxxio)
set(CMAKE_CXXIO_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/cxxio/include)
endif()
include_directories("${CMAKE_CXXIO_HEADERS}")

## alignment-writer
if (DEFINED CMAKE_ALIGNMENT_WRITER_HEADERS)
if (DEFINED CMAKE_ALIGNMENT_WRITER_HEADERS AND DEFINED CMAKE_ALIGNMENT_WRITER_LIBRARY)
message(STATUS "alignment-writer headers provided in: ${CMAKE_ALIGNMENT_WRITER_HEADERS}")
message(STATUS "alignment-writer library provided in: ${CMAKE_ALIGNMENT_WRITER_LIBRARY}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-alignment-writer.txt.in ${CMAKE_BINARY_DIR}/external/alignment-writer-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/alignment-writer-download )
if(result)
message(FATAL_ERROR "CMake step for alignment-writer failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/alignment-writer-download )
if(result)
message(FATAL_ERROR "Build step for alignment-writer failed: ${result}")
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external/alignment-writer
${CMAKE_CURRENT_BINARY_DIR}/external/alignment-writer/build)
FetchContent_Declare(alignment-writer
GIT_REPOSITORY https://github.com/tmaklin/alignment-writer.git
GIT_TAG v0.5.0
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/alignment-writer"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/alignment-writer"
BUILD_IN_SOURCE 0
CMAKE_ARGS -D CMAKE_BXZSTR_HEADERS=${CMAKE_BXZSTR_HEADERS}
-D CMAKE_CXXARGS_HEADERS=${CMAKE_CXXARGS_HEADERS}
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-D "CMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
-D "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
-D "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
-D "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(alignment-writer)
add_dependencies(mGEMS libalignmentwriter)
set_target_properties(alignment-writer PROPERTIES EXCLUDE_FROM_ALL 1)
set(CMAKE_ALIGNMENT_WRITER_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/alignment-writer/include)
set(CMAKE_ALIGNMENT_WRITER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/alignment-writer/include)
set(CMAKE_ALIGNMENT_WRITER_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/lib/libalignment-writer.a)
endif()
include_directories(${CMAKE_ALIGNMENT_WRITER_HEADERS})
target_link_libraries(mGEMS ${CMAKE_ALIGNMENT_WRITER_LIBRARY})
target_link_libraries(libmgems ${CMAKE_ALIGNMENT_WRITER_LIBRARY})

## Check dependencies and download them if not given
## telescope
if (DEFINED CMAKE_TELESCOPE_HEADERS)
target_link_libraries(mGEMS libtelescope)
if (DEFINED CMAKE_TELESCOPE_LIBRARY AND DEFINED CMAKE_TELESCOPE_HEADERS)
message(STATUS "telescope headers provided in: ${CMAKE_TELESCOPE_HEADERS}")
message(STATUS "telescope library provided in: ${CMAKE_TELESCOPE_LIBRARY}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-telescope.txt.in ${CMAKE_CURRENT_BINARY_DIR}/external/telescope-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/telescope-download )
if(result)
message(FATAL_ERROR "CMake step for telescope failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/telescope-download )
if(result)
message(FATAL_ERROR "Build step for telescope failed: ${result}")
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external/telescope
${CMAKE_CURRENT_BINARY_DIR}/external/telescope/build)
FetchContent_Declare(telescope
GIT_REPOSITORY https://github.com/tmaklin/telescope.git
GIT_TAG v0.7.0-prerelease
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/telescope"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/telescope"
BUILD_IN_SOURCE 0
CMAKE_ARGS -D CMAKE_BXZSTR_HEADERS=${CMAKE_BXZSTR_HEADERS}
-D CMAKE_CXXARGS_HEADERS=${CMAKE_CXXARGS_HEADERS}
-D CMAKE_CXXIO_HEADERS=${CMAKE_CXXIO_HEADERS}
-D CMAKE_ALIGNMENT_WRITER_HEADERS=${CMAKE_ALIGNMENT_WRITER_HEADERS}
-D CMAKE_ALIGNMENT_WRITER_LIBRARY=${CMAKE_ALIGNMENT_WRITER_LIBRARY}
-D CMAKE_BITMAGIC_HEADERS=${CMAKE_CURRENT_SOURCE_DIR}/external/telescope/external/BitMagic-7.12.3/src
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-D "CMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
-D "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
-D "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
-D "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(telescope)
add_dependencies(mGEMS libalignmentwriter)
add_dependencies(telescope libalignmentwriter)
add_dependencies(mGEMS telescope)
set_target_properties(telescope PROPERTIES EXCLUDE_FROM_ALL 1)
target_link_libraries(mGEMS libtelescope libalignmentwriter)
set(CMAKE_TELESCOPE_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/telescope/include ${CMAKE_CURRENT_BINARY_DIR}/external/telescope/build/include)
if (NOT DEFINED CMAKE_BITMAGIC_HEADERS)
set(CMAKE_BITMAGIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/telescope/external/BitMagic-7.12.3/src)
endif()
set(CMAKE_TELESCOPE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/telescope/include)
set(CMAKE_TELESCOPE_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/lib/libtelescope.a)
set(CMAKE_BITMAGIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/telescope/external/BitMagic-7.12.3/src)
endif()

include_directories(${CMAKE_TELESCOPE_HEADERS} ${CMAKE_BITMAGIC_HEADERS})
target_link_libraries(mGEMS ${CMAKE_TELESCOPE_LIBRARY})
target_link_libraries(libmgems ${CMAKE_TELESCOPE_LIBRARY})

## seamat
if (DEFINED CMAKE_SEAMAT_HEADERS)
message(STATUS "seamat headers provided in: ${CMAKE_SEAMAT_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-seamat.txt.in ${CMAKE_BINARY_DIR}/external/seamat-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/seamat-download )
if(result)
message(FATAL_ERROR "CMake step for seamat failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/seamat-download )
if(result)
message(FATAL_ERROR "Build step for seamat failed: ${result}")
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external/seamat
${CMAKE_CURRENT_BINARY_DIR}/external/seamat/build)
target_link_libraries(mGEMS)
set(CMAKE_SEAMAT_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/seamat/include)
FetchContent_Declare(seamat
GIT_REPOSITORY https://github.com/tmaklin/seamat.git
GIT_TAG v0.2.2
PREFIX "external"
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/seamat"
BUILD_IN_SOURCE 0
CMAKE_ARGS -D CMAKE_BUILD_TESTS=0
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
)
FetchContent_MakeAvailable(seamat)
set(CMAKE_SEAMAT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/external/seamat/include ${CMAKE_CURRENT_BINARY_DIR}/_deps/seamat-build/include)
endif()
include_directories(${CMAKE_SEAMAT_HEADERS})

Expand All @@ -192,7 +265,7 @@ if(GIT_FOUND)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message( STATUS "mSWEEP-assembly plugin version: ${_BUILD_VERSION}")
message( STATUS "mGEMS version: ${_BUILD_VERSION}")
else()
message(STATUS "GIT not found, version numbering disabled")
set(_BUILD_VERSION "unknown")
Expand All @@ -204,12 +277,5 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.in ${CMAKE_CURRENT_

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

## mGEMS library
add_library(libmgems
${CMAKE_CURRENT_SOURCE_DIR}/src/bin_reads.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/extract_bin.cpp
)
set_target_properties(libmgems PROPERTIES OUTPUT_NAME mgems)

# Link libraries
target_link_libraries(mGEMS libmgems)
17 changes: 0 additions & 17 deletions config/CMakeLists-alignment-writer.txt.in

This file was deleted.

Loading

0 comments on commit 45c2c35

Please sign in to comment.