From bc12d3e3d6a9d664fd779b1e922e449bdb05cbae Mon Sep 17 00:00:00 2001 From: Jon Matteo Church Date: Thu, 28 Sep 2023 14:18:52 +0100 Subject: [PATCH 1/3] allow lib and exe to be built at the same time --- CMakeLists.txt | 30 ++++++++++++++++++++---------- README.md | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b243a19a..1d102816 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,31 @@ 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) + get_target_property(MM2_BIN_DIR minimap2-exe SOURCE_DIR) add_test( NAME minimap2_version_test WORKING_DIRECTORY ${MM2_BIN_DIR} COMMAND minimap2 -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 | From d3115b18bb91bebe3adfbdf9cf5143270c75b2af Mon Sep 17 00:00:00 2001 From: Jon Matteo Church Date: Thu, 28 Sep 2023 17:21:25 +0100 Subject: [PATCH 2/3] add verbose messages --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d102816..1d24266f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,18 +76,21 @@ set(MM2_SOURCES ) if(ONT_MM2_EXE) - 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) - get_target_property(MM2_BIN_DIR minimap2-exe SOURCE_DIR) + add_executable(minimap2_exe ${MM2_SOURCES} src/3rdparty/minimap2/main.c) + message(STATUS "added exec: minimap2_exe") + list(APPEND TARGETS minimap2_exe) + set_target_properties(minimap2_exe PROPERTIES OUTPUT_NAME minimap2) + get_target_property(MM2_BIN_DIR minimap2_exe SOURCE_DIR) add_test( NAME minimap2_version_test WORKING_DIRECTORY ${MM2_BIN_DIR} COMMAND minimap2 -V ) + message(STATUS "added test: minimap2_version_test") endif() if(ONT_MM2_LIB) add_library(minimap2 ${MM2_SOURCES}) + message(STATUS "added lib: minimap2") list(APPEND TARGETS minimap2) endif() From 57bddc46260e1b13092c5d873a73987c85d39c00 Mon Sep 17 00:00:00 2001 From: Jon Matteo Church Date: Fri, 29 Sep 2023 09:40:41 +0100 Subject: [PATCH 3/3] fix minimap2_version_test --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d24266f..2952871f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,20 +77,15 @@ set(MM2_SOURCES if(ONT_MM2_EXE) add_executable(minimap2_exe ${MM2_SOURCES} src/3rdparty/minimap2/main.c) - message(STATUS "added exec: minimap2_exe") list(APPEND TARGETS minimap2_exe) set_target_properties(minimap2_exe PROPERTIES OUTPUT_NAME minimap2) - get_target_property(MM2_BIN_DIR minimap2_exe SOURCE_DIR) add_test( NAME minimap2_version_test - WORKING_DIRECTORY ${MM2_BIN_DIR} - COMMAND minimap2 -V + COMMAND minimap2_exe -V ) - message(STATUS "added test: minimap2_version_test") endif() if(ONT_MM2_LIB) add_library(minimap2 ${MM2_SOURCES}) - message(STATUS "added lib: minimap2") list(APPEND TARGETS minimap2) endif()