-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
189 lines (154 loc) · 8.66 KB
/
CMakeLists.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
cmake_minimum_required(VERSION 3.2)
project(savvy VERSION 2.1.0)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose build type (Debug|Release|RelWithDebInfo|MinSizeRel)" FORCE)
endif()
#set(CMAKE_CXX_FLAGS "-fsanitize=address")
#set(CMAKE_CXX_FLAGS "-fPIC -funsigned-char")
set(CMAKE_CXX_STANDARD 11)
#add_library(hts STATIC IMPORTED)
#set_property(TARGET hts PROPERTY IMPORTED_LOCATION ${CMAKE_INSTALL_PREFIX}/lib/libhts.a)
#set_property(TARGET hts APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/include)
if (USE_CXX3_ABI)
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")
endif()
if(CGET_PREFIX)
link_directories(${CGET_PREFIX}/lib)
endif()
#list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
#find_package(shrinkwrap CONFIG REQUIRED)
#if (NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;${CMAKE_FIND_LIBRARY_SUFFIXES}") # Prefer libz.a when both are available
#endif()
#find_library(ZLIB_LIBRARY z)
#find_library(ZSTD_LIBRARY zstd)
find_package(shrinkwrap REQUIRED)
find_package(Threads)
#get_target_property(SHRINKWRAP_LIBS shrinkwrap INTERFACE_LINK_LIBRARIES)
#add_definitions(-DSAVVY_VERSION="${PROJECT_VERSION}")
add_library(savvy INTERFACE)
# include/savvy/allele_status.hpp
# include/savvy/armadillo_vector.hpp
# include/savvy/compressed_vector.hpp
# include/savvy/data_format.hpp
# include/savvy/eigen3_vector.hpp
# include/savvy/portable_endian.hpp
# include/savvy/reader.hpp #src/savvy/reader.cpp include/savvy/reader.hpp
# include/savvy/region.hpp #src/savvy/region.cpp include/savvy/region.hpp
# include/savvy/s1r.hpp
# include/savvy/sav_reader.hpp #src/savvy/sav_reader.cpp include/savvy/sav_reader.hpp
# include/savvy/savvy.hpp #src/savvy/savvy.cpp include/savvy/savvy.hpp
# include/savvy/site_info.hpp #src/savvy/site_info.cpp include/savvy/site_info.hpp
# include/savvy/ublas_vector.hpp
# include/savvy/utility.hpp #src/savvy/utility.cpp include/savvy/utility.hpp
# include/savvy/variant_group_iterator.hpp
# include/savvy/variant_iterator.hpp
# include/savvy/varint.hpp #src/savvy/varint.cpp include/savvy/varint.hpp
# include/savvy/vcf_reader.hpp) #src/savvy/vcf_reader.cpp include/savvy/vcf_reader.hpp)
target_link_libraries(savvy INTERFACE shrinkwrap) #${ZLIB_LIBRARY} ${ZSTD_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(savvy INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_compile_definitions(savvy INTERFACE -DSAVVY_VERSION="${PROJECT_VERSION}")
add_executable(sav
src/sav/main.cpp
src/sav/concat.cpp include/sav/concat.hpp
src/sav/export.cpp include/sav/export.hpp
src/sav/head.cpp include/sav/head.hpp
src/sav/import.cpp include/sav/import.hpp
src/sav/index.cpp include/sav/index.hpp
include/sav/filter.hpp
src/sav/merge.cpp include/sav/merge.hpp
src/sav/rehead.cpp include/sav/rehead.hpp
src/sav/sort.cpp include/sav/sort.hpp
src/sav/stat.cpp include/sav/stat.hpp
src/sav/utility.cpp include/sav/utility.hpp)
target_link_libraries(sav savvy)
#add_executable(bcf2m3vcf src/sav/bcf2m3vcf.cpp)
#target_link_libraries(bcf2m3vcf savvy)
#add_executable(sav-sample-sort src/sav/sav_sample_sort.cpp)
#target_link_libraries(sav-sample-sort savvy)
#add_executable(savvy-speed-test src/test/savvy_speed_test.cpp)
#target_link_libraries(savvy-speed-test savvy)
add_custom_target(manuals
COMMAND help2man --output "${CMAKE_BINARY_DIR}/sav.1" "${CMAKE_BINARY_DIR}/sav"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_export.1" "${CMAKE_BINARY_DIR}/sav export"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_head.1" "${CMAKE_BINARY_DIR}/sav head"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_import.1" "${CMAKE_BINARY_DIR}/sav import"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_index.1" "${CMAKE_BINARY_DIR}/sav index"
#COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_merge.1" "${CMAKE_BINARY_DIR}/sav merge"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_rehead.1" "${CMAKE_BINARY_DIR}/sav rehead"
COMMAND help2man --version-string "v${PROJECT_VERSION}" --output "${CMAKE_BINARY_DIR}/sav_stat-index.1" "${CMAKE_BINARY_DIR}/sav stat-index")
if(BUILD_TESTS)
enable_testing()
add_definitions(-DSAVVYT_VCF_FILE=\"${CMAKE_CURRENT_SOURCE_DIR}/test_file.vcf\"
-DSAVVYT_MISSING_HEADERS_VCF_FILE=\"${CMAKE_CURRENT_SOURCE_DIR}/test_file_missing_headers.vcf\"
-DSAVVYT_SAV_FILE_HARD=\"test_file_hard.sav\"
-DSAVVYT_SAV_FILE_DOSE=\"test_file_dose.sav\"
-DSAVVYT_MARKER_COUNT_HARD=24
-DSAVVYT_MARKER_COUNT_DOSE=20)
add_executable(savvy-test src/test/main.cpp src/test/test_class.cpp include/test/test_class.hpp)
target_link_libraries(savvy-test savvy)
add_test(convert_file_test savvy-test convert-file)
add_test(subset_test savvy-test subset)
add_test(random_access_test savvy-test random-access)
add_test(stride_reduce_test savvy-test stride-reduce)
add_test(missing_headers_test savvy-test missing-headers)
endif()
if (BUILD_EVAL)
find_library(HTS_LIBRARY hts)
if (NOT HTS_LIBRARY)
message(FATAL_ERROR "Error: missing htslib. Run the following from base directory of repo\ncget install https://github.com/samtools/htslib/releases/download/1.6/htslib-1.6.tar.bz2 -DCMAKE_VERBOSE_MAKEFILE=1 --cmake dep/htslib.cmake")
endif()
add_executable(sav-eval src/eval/main.cpp)
target_link_libraries(sav-eval savvy ${HTS_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
# add_executable(columnar-eval src/eval/columnar_main.cpp)
# target_link_libraries(columnar-eval savvy)
endif()
if(BUILD_SLR_EXAMPLES)
add_executable(slr-examples src/test/slr_examples.cpp)
target_link_libraries(slr-examples savvy armadillo)
find_library(OPENCL_LIB OpenCL)
add_executable(linreg-ttest src/test/linreg_ttest.cpp)
target_link_libraries(linreg-ttest savvy ${OPENCL_LIB})
endif()
if(BUILD_SPARSE_REGRESSION)
set(CMAKE_CXX_STANDARD 17)
include(CMakeFindDependencyMacro)
find_package(xtensor-blas REQUIRED)
#find_package(Boost REQUIRED)
add_executable(sav-at src/test/sp_reg.cpp)
target_link_libraries(sav-at savvy xtensor-blas)
endif()
install(DIRECTORY include/savvy COMPONENT api DESTINATION include)
install(TARGETS savvy COMPONENT api EXPORT ${PROJECT_NAME}-targets)
install(TARGETS sav COMPONENT cli
RUNTIME DESTINATION bin
OPTIONAL)
install(EXPORT ${PROJECT_NAME}-targets COMPONENT api DESTINATION share/${PROJECT_NAME})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
"include(CMakeFindDependencyMacro)\n"
"find_dependency(shrinkwrap REQUIRED)\n"
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake)\n")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake COMPONENT api DESTINATION share/${PROJECT_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sav.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_export.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_head.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_import.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_index.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_merge.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_rehead.1 ${CMAKE_CURRENT_BINARY_DIR}/sav_stat-index.1
COMPONENT cli
DESTINATION share/man/man1
OPTIONAL)
export(EXPORT ${PROJECT_NAME}-targets)
#set(CPACK_PACKAGE_NAME "${PROJECT_NAME")
#set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
#set(CPACK_DEB_COMPONENT_INSTALL ON)
#set(CPACK_RPM_COMPONENT_INSTALL ON)
#set(CPACK_COMPONENTS_ALL "")
#set(CPACK_SYSTEM_NAME Linux-cxx3-abi)
#execute_process(COMMAND bash "-c" "finger $(whoami) | egrep -o 'Name: [a-zA-Z0-9 ]{1,}' | cut -d ':' -f 2 | xargs echo -n" OUTPUT_VARIABLE FULL_NAME)
#set(CPACK_PACKAGE_CONTACT ${FULL_NAME})
#if (UNIX AND NOT APPLE)
# set(CPACK_GENERATOR "DEB;RPM;STGZ")
#endif()
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
include(CPack)