Skip to content

Commit

Permalink
Merge pull request #2 from jonmatteochurch/allow_lib_and_exe_build
Browse files Browse the repository at this point in the history
allow lib and exe to be built at the same time
  • Loading branch information
iiSeymour authored Sep 29, 2023
2 parents b58015a + 57bddc4 commit a101407
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
32 changes: 20 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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})
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

0 comments on commit a101407

Please sign in to comment.