diff --git a/CMakeLists.txt b/CMakeLists.txt index b243a19a..2952871f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.10) project(minimap2 VERSION 2.24.0 LANGUAGES C) enable_testing() -option(ONT_MM2_EXE "Build minimap2 exe" ON) +option(ONT_MM2_EXE "Build minimap2 exe" OFF) +option(ONT_MM2_LIB "Build minimap2 lib" ON) # set default build type to release if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) @@ -75,22 +76,29 @@ set(MM2_SOURCES ) if(ONT_MM2_EXE) - add_executable(minimap2 ${MM2_SOURCES} src/3rdparty/minimap2/main.c) - get_target_property(MM2_BIN_DIR minimap2 SOURCE_DIR) + add_executable(minimap2_exe ${MM2_SOURCES} src/3rdparty/minimap2/main.c) + list(APPEND TARGETS minimap2_exe) + set_target_properties(minimap2_exe PROPERTIES OUTPUT_NAME minimap2) add_test( NAME minimap2_version_test - WORKING_DIRECTORY ${MM2_BIN_DIR} - COMMAND minimap2 -V + COMMAND minimap2_exe -V ) -else() +endif() +if(ONT_MM2_LIB) add_library(minimap2 ${MM2_SOURCES}) + list(APPEND TARGETS minimap2) endif() include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/minimap2) -target_link_libraries(minimap2 ${ZLIB_LIBRARIES}) -if(NOT WIN32) - target_link_libraries(minimap2 m Threads::Threads) -else() - target_link_libraries(minimap2 pthreadVC3) -endif() +foreach(TARGET IN LISTS TARGETS) + target_link_libraries(${TARGET} ${ZLIB_LIBRARIES}) + + if(NOT WIN32) + target_link_libraries(${TARGET} m Threads::Threads) + else() + target_link_libraries(${TARGET} pthreadVC3) + endif() +endforeach() + +install(TARGETS ${TARGETS}) diff --git a/README.md b/README.md index 6c81a736..a893853e 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,4 @@ $ ctest -C Release --test-dir cmake-build --output-on-failure | CMake | Description | Default | |:-------------------------|:------------------------------------------------|---------| | ONT_MM2_EXE | Build the minimap2 executable | ON | +| ONT_MM2_LIB | Build the minimap2 library | OFF |