Skip to content

Commit 3923d2e

Browse files
authored
Merge pull request #56 from gymreklab/mlamkin7-update-to-cmake
Update to Cmake
2 parents 45228a0 + 7b84cef commit 3923d2e

52 files changed

Lines changed: 189 additions & 825 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
build/
12
Makefile
23
Makefile.in
34
aclocal.m4

CMakeLists.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
cmake_minimum_required(VERSION 3.7)
2+
3+
include(ExternalProject)
4+
5+
#set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6+
#add_compile_options(-Werror)
7+
8+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
9+
10+
# set the project name
11+
project(chips VERSION 2.1)
12+
configure_file(chipsConfig.h.in chipsConfig.h)
13+
14+
# specify the C++ standard
15+
set(CMAKE_CXX_STANDARD 11)
16+
set(CMAKE_CXX_STANDARD_REQUIRED True)
17+
18+
ExternalProject_Add(zlib
19+
PREFIX ${CMAKE_BINARY_DIR}/thirdparty/zlib
20+
GIT_REPOSITORY "https://github.com/madler/zlib.git"
21+
GIT_TAG "v1.2.8"
22+
UPDATE_COMMAND ""
23+
BUILD_IN_SOURCE 1
24+
CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/thirdparty/zlib/src/zlib/configure --prefix=${CMAKE_BINARY_DIR}/thirdparty/zlib --static
25+
INSTALL_DIR ${CMAKE_BINARY_DIR}/thirdparty/zlib
26+
LOG_DOWNLOAD 1
27+
LOG_INSTALL 1
28+
)
29+
ExternalProject_Add(htslib
30+
PREFIX ${CMAKE_BINARY_DIR}/thirdparty/htslib
31+
GIT_REPOSITORY "https://github.com/samtools/htslib.git"
32+
GIT_TAG "1.3.1"
33+
UPDATE_COMMAND ""
34+
BUILD_IN_SOURCE 1
35+
CONFIGURE_COMMAND ""
36+
BUILD_COMMAND make
37+
INSTALL_COMMAND make install prefix=${CMAKE_BINARY_DIR}/thirdparty/htslib
38+
LOG_DOWNLOAD 1
39+
)
40+
41+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
42+
include_directories(${CMAKE_BINARY_DIR}/thirdparty/zlib/include)
43+
set(zlib_static ${CMAKE_BINARY_DIR}/thirdparty/zlib/lib/libz.a)
44+
set(htslib_static ${CMAKE_BINARY_DIR}/thirdparty/htslib/lib/libhts.a)
45+
include_directories(${CMAKE_BINARY_DIR}/thirdparty/htslib/include)
46+
add_dependencies(htslib zlib)
47+
48+
add_subdirectory(ChIPs)
49+
50+
# add the executable
51+
add_executable(chips src/main.cpp)
52+
53+
target_compile_features(chips PRIVATE cxx_range_for)
54+
target_include_directories(chips PUBLIC "${PROJECT_BINARY_DIR}")
55+
target_link_libraries(chips ChIPs pthread)
56+
install(TARGETS chips DESTINATION bin)
57+
58+
add_dependencies(htslib zlib)
59+
add_dependencies(ChIPs htslib)

ChIPs/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
file(GLOB SOURCES *.cpp *.h *.hpp)
2+
add_library(ChIPs ${SOURCES})
3+
target_link_libraries(ChIPs ${htslib_static} ${zlib_static})
4+
target_include_directories(ChIPs PUBLIC "${PROJECT_BINARY_DIR}")
File renamed without changes.

src/bam_io.h renamed to ChIPs/bam_io.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define bam_ins_size(b) (b)->core.isize;
2222
#include "htslib/sam.h"
2323

24-
#include "src/common.h"
24+
#include "common.h"
2525

2626
// htslib encodes each base using a 4 bit integer
2727
// This array converts each integer to its corresponding base
@@ -171,7 +171,8 @@ class BamAlignment {
171171
bool AddStringTag(const char tag[2], const std::string& value){
172172
if (HasTag(tag))
173173
return false;
174-
return (bam_aux_append(b_, tag, 'Z', value.size()+1, (uint8_t*)value.c_str()) == 0);
174+
bam_aux_append(b_, tag, 'Z', value.size()+1, (uint8_t*)value.c_str());
175+
return true;
175176
}
176177

177178
bool GetCharTag(const char tag[2], char& value) const {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "src/bingenerator.h"
2-
#include "src/ref_genome.h"
3-
#include "src/common.h"
1+
#include "bingenerator.h"
2+
#include "ref_genome.h"
3+
#include "common.h"
44

55
#include <sstream>
66
#include <iostream>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SRC_BINGENERATOR_H__
22
#define SRC_BINGENERATOR_H__
33

4-
#include "src/options.h"
4+
#include "options.h"
55
#include <vector>
66
#include <map>
77

src/common.cpp renamed to ChIPs/common.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <iostream>
55
#include <sstream>
66

7-
#include "src/common.h"
7+
#include "common.h"
8+
#include "chipsConfig.h"
89

910
using namespace std;
1011

@@ -27,8 +28,8 @@ void PrintMessageDieOnError(const string& msg, MSGTYPE msgtype) {
2728
errx(1, "Invalid message type. This should never happen");
2829
}
2930
stringstream ss;
30-
ss << "[" << PROGRAM_NAME
31-
<< "-" << _GIT_VERSION << "] " << typestring << msg << endl;
31+
ss << "[chips-" << chips_VERSION_MAJOR << "." << chips_VERSION_MINOR << "]"
32+
<< typestring << msg << endl;
3233
cerr << ss.str();
3334

3435
if (msgtype == M_ERROR) {
File renamed without changes.

src/fragment.cpp renamed to ChIPs/fragment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "src/fragment.h"
1+
#include "fragment.h"
22

33
Fragment::Fragment(const std::string& _chrom, const std::int32_t& _start, const std::size_t& _length, const float& _score){
44
chrom = _chrom;

0 commit comments

Comments
 (0)