forked from pinglu-zhang/FMAlign2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
81 lines (68 loc) · 2.19 KB
/
CMakeLists.txt
File metadata and controls
81 lines (68 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.15)
project(FMAlign2 VERSION 1.0 LANGUAGES CXX C)
# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
# 编译选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
# 包含目录
include_directories(include)
# 源文件
set(SOURCES
main.cpp
src/utils.cpp
src/mem_finder.cpp
src/sequence_split_align.cpp
src/ssw.cpp
src/ssw_cpp.cpp
src/gsacak.c
)
# 根据操作系统添加不同的源文件
if(WIN32)
# Windows: 使用 OpenMP
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else()
# Linux/Unix: 使用 pthread 和自定义线程池
list(APPEND SOURCES
src/thread_pool.cpp
src/thread_condition.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
if(UNIX AND NOT APPLE)
# Linux 特定: 需要 rt 库
set(EXTRA_LIBS rt)
endif()
endif()
# M64 宏定义 (可选,用于大数据)
option(USE_M64 "Use 64-bit integer types" OFF)
if(USE_M64)
add_definitions(-DM64=1)
endif()
# Debug 宏定义
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG=1)
endif()
# 创建可执行文件
add_executable(fmalign2 ${SOURCES})
# 链接库
if(NOT WIN32)
target_link_libraries(fmalign2 pthread ${EXTRA_LIBS})
endif()
# 静态链接选项 (Linux)
option(STATIC_LINK "Build with static linking" OFF)
if(STATIC_LINK AND UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libstdc++ -static-libgcc")
target_link_libraries(fmalign2 -Wl,--whole-archive -lpthread -Wl,--no-whole-archive)
endif()
# Sanitizer 选项 (用于调试)
option(USE_SANITIZER "Build with address and undefined behavior sanitizers" OFF)
if(USE_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize=undefined")
endif()
# 安装配置
install(TARGETS fmalign2 DESTINATION bin)