From 6800236eb3c48b127d08eae15fbc81b2fabe92ea Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Sat, 1 Nov 2014 20:33:11 -0400 Subject: [PATCH] Make CMAKE the default build script * use add_compile_options instead of hardcode setting of the env variable * remove lib from include directories * add header files to the source list * include htslib directories at the cmake build location (no longer using the git-submodule) * remove git submodule and use htslib via cmake from now on. * exclude tests from building by default * build release by default, but tests in debug mode * remove boost build files * add cmake to travis * add release / debug options to the build --- .gitmodules | 4 -- .travis.yml | 10 +++-- .travis_scripts/boost.sh | 6 --- .travis_scripts/coveralls.sh | 3 +- .travis_scripts/gcc.sh | 14 +++++++ CMakeLists.txt | 26 ++++++++++--- Jamroot | 19 --------- contrib/htslib.cmake | 14 ++++--- gamgee/CMakeLists.txt | 75 +++++++++++++++++++++++++++++++----- lib/Jamfile | 20 ---------- lib/htslib | 1 - test/CMakeLists.txt | 9 ++--- test/Jamfile | 10 ----- 13 files changed, 122 insertions(+), 89 deletions(-) delete mode 100644 Jamroot delete mode 100644 lib/Jamfile delete mode 160000 lib/htslib delete mode 100644 test/Jamfile diff --git a/.gitmodules b/.gitmodules index 590a7eff9..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "lib/htslib"] - path = lib/htslib - url = ../htslib.git - branch = broad diff --git a/.travis.yml b/.travis.yml index 9803b44a1..6e1e38614 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,14 +15,16 @@ before_install: - sudo apt-get -qq update; install: - - .travis_scripts/boost.sh + - .travis_scripts/boost.sh - if [ "$CXX" == "clang++" ]; then .travis_scripts/clang.sh; fi - if [ "$CXX" == "g++" ]; then .travis_scripts/gcc.sh; fi script: - - if [ "$TRAVIS_BRANCH" == "master" ]; then b2 -a toolset=${CC} test variant=production; fi - - b2 -a toolset=${CC} test variant=debug cxxflags=--coverage linkflags=--coverage + - mkdir build; pushd build; + - cmake .. && make debug && make -j 2 gamgee_test + - popd; + - build/test/gamgee_test after_success: - .travis_scripts/update_website_dox.sh - - .travis_scripts/coveralls.sh + - .travis_scripts/coveralls.sh diff --git a/.travis_scripts/boost.sh b/.travis_scripts/boost.sh index bb2e5e124..f45cd1f3b 100755 --- a/.travis_scripts/boost.sh +++ b/.travis_scripts/boost.sh @@ -3,9 +3,3 @@ # install boost libraries sudo apt-get install -qq boost1.55 -# install boost build from sources in ${HOME}/boost-build -git clone https://github.com/boostorg/build.git ${HOME}/boost-build -cd ${HOME}/boost-build -./bootstrap.sh --with-toolset=${CC} -sudo ./b2 install -cd - diff --git a/.travis_scripts/coveralls.sh b/.travis_scripts/coveralls.sh index ed51aaa5e..00e877f1d 100755 --- a/.travis_scripts/coveralls.sh +++ b/.travis_scripts/coveralls.sh @@ -5,5 +5,6 @@ if [ "$CXX" == "g++" ]; then sudo pip install cpp-coveralls - coveralls -b . -r . -e lib -e test -e testdata -t ${COVERALLS_TOKEN} + cd build + coveralls -r ../ -e CMakeFiles -e contrib -e test -t ${COVERALLS_TOKEN} fi diff --git a/.travis_scripts/gcc.sh b/.travis_scripts/gcc.sh index 60178497f..b52ae26a2 100755 --- a/.travis_scripts/gcc.sh +++ b/.travis_scripts/gcc.sh @@ -3,3 +3,17 @@ wget ftp://gsapubftp-anonymous@ftp.broadinstitute.org/travis/gcc_4.9.1-1_amd64.deb sudo apt-get remove cpp libffi-dev sudo dpkg --install gcc_4.9.1-1_amd64.deb + +echo "BEGIN Eliminating old libstdc++" +sudo rm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a +sudo rm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.la +sudo rm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++_s.a +sudo rm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++_sjlj_6.dll +sudo rm /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a +sudo rm /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so +sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6 +sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16 +echo "END Eliminating old libstdc++" + +export LD_LIBRARY_PATH=/usr/lib64 +sudo ln -s /usr/lib64/libstd* /usr/lib/x86_64-linux-gnu/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 2642567f6..8b275ed71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,32 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.7) project(gamgee) include(ExternalProject) +## This is the right way to do this, but only supported in cmake 2.8.12 +#add_compile_options("-std=c++1y") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") -find_package(Boost 1.56 COMPONENTS unit_test_framework REQUIRED) +# Dependency: Boost Unit Test Framework (find in the system) +find_package(Boost 1.55 COMPONENTS unit_test_framework REQUIRED) +include_directories(${Boost_INCLUDE_DIRS}) + +# Dependency: htslib (download and build) +include("contrib/htslib.cmake") include_directories(gamgee) -include_directories(gamgee/utils) -include_directories(lib) -include_directories(lib/htslib) add_subdirectory(gamgee) add_subdirectory(test) + +ADD_CUSTOM_TARGET(debug + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) + +ADD_CUSTOM_TARGET(release + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) \ No newline at end of file diff --git a/Jamroot b/Jamroot deleted file mode 100644 index 3bb704203..000000000 --- a/Jamroot +++ /dev/null @@ -1,19 +0,0 @@ -project gamgee - : requirements - -std=c++1y - -std=c++1y - on - ; - - use-project /gamgee/libs : lib ; - - variant production - : on speed - ; - - lib gamgee - : [ glob-tree *.cpp : .git test lib bin dox build ] /gamgee/libs//hts - : static - : production - : . - ; diff --git a/contrib/htslib.cmake b/contrib/htslib.cmake index d15bb597f..0fec8601f 100644 --- a/contrib/htslib.cmake +++ b/contrib/htslib.cmake @@ -1,16 +1,20 @@ # build htslib -set(htslib_PREFIX ${CMAKE_BINARY_DIR}/contrib/htslib-prefix) +set(htslib_PREFIX ${CMAKE_BINARY_DIR}/contrib/htslib) ExternalProject_Add(htslib PREFIX ${htslib_PREFIX} GIT_REPOSITORY "https://github.com/broadinstitute/htslib.git" - # NOTE: gamgee tracks the 'broad' branch - # we should always sync to a commit from that branch for consistency GIT_TAG broad BUILD_IN_SOURCE 1 CONFIGURE_COMMAND "" - BUILD_COMMAND ${MAKE} + BUILD_COMMAND make lib-static -j 4 INSTALL_COMMAND "" - ) + LOG_DOWNLOAD 0 + LOG_UPDATE 0 + LOG_CONFIGURE 0 + LOG_BUILD 0 + LOG_TEST 0 + LOG_INSTALL 0 +) include_directories(${htslib_PREFIX}/src/htslib) set(htslib_LIB ${htslib_PREFIX}/src/htslib/libhts.a) \ No newline at end of file diff --git a/gamgee/CMakeLists.txt b/gamgee/CMakeLists.txt index 2fb776c9e..c88fc0cef 100644 --- a/gamgee/CMakeLists.txt +++ b/gamgee/CMakeLists.txt @@ -1,40 +1,97 @@ set(SOURCE_FILES - utils/file_utils.cpp - utils/genotype_utils.cpp - utils/hts_memory.cpp - utils/utils.cpp - utils/variant_field_type.cpp - utils/variant_utils.cpp base_quals.cpp + base_quals.h cigar.cpp + cigar.h + exceptions.h fastq.cpp + fastq.h fastq_iterator.cpp + fastq_iterator.h fastq_reader.cpp + fastq_reader.h + gamgee.h genotype.cpp + genotype.h indexed_sam_iterator.cpp + indexed_sam_iterator.h + indexed_sam_reader.h indexed_variant_iterator.cpp + indexed_variant_iterator.h + indexed_variant_reader.h + individual_field.h + individual_field_iterator.h + individual_field_value.h + individual_field_value_iterator.h interval.cpp + interval.h + missing.h multiple_variant_iterator.cpp + multiple_variant_iterator.h + multiple_variant_reader.h read_bases.cpp + read_bases.h read_group.cpp + read_group.h reference_iterator.cpp + reference_iterator.h reference_map.cpp - sam.cpp + reference_map.h sam_builder.cpp sam_builder_data_field.cpp + sam_builder_data_field.h + sam_builder.h + sam.cpp + sam.h sam_header.cpp + sam_header.h sam_iterator.cpp + sam_iterator.h sam_pair_iterator.cpp + sam_pair_iterator.h + sam_reader.h + sam_tag.h sam_writer.cpp + sam_writer.h + shared_field.h + shared_field_iterator.h synced_variant_iterator.cpp - variant.cpp + synced_variant_iterator.h + synced_variant_reader.h + utils/file_utils.cpp + utils/file_utils.h + utils/genotype_utils.cpp + utils/genotype_utils.h + utils/hts_memory.cpp + utils/hts_memory.h + utils/short_value_optimized_storage.h + utils/utils.cpp + utils/utils.h + utils/variant_field_type.cpp + utils/variant_field_type.h + utils/variant_utils.cpp + utils/variant_utils.h variant_builder.cpp + variant_builder.h + variant_builder_individual_field.h variant_builder_individual_region.cpp + variant_builder_individual_region.h variant_builder_shared_region.cpp - variant_header.cpp + variant_builder_shared_region.h + variant.cpp + variant_filters.h + variant_filters_iterator.h + variant.h variant_header_builder.cpp + variant_header_builder.h + variant_header.cpp + variant_header.h variant_iterator.cpp + variant_iterator.h + variant_reader.h variant_writer.cpp + variant_writer.h + zip.h ) add_library(gamgee STATIC ${SOURCE_FILES}) diff --git a/lib/Jamfile b/lib/Jamfile deleted file mode 100644 index ba04fc702..000000000 --- a/lib/Jamfile +++ /dev/null @@ -1,20 +0,0 @@ -project libs ; - -path-constant htslib_dir : htslib ; - -lib z ; - -actions external-make -{ - echo "Rebuilding htslib..."; - cd "$(htslib_dir)" && make clean > /dev/null 2> /dev/null && make lib-static > /dev/null 2> /dev/null -} - -make libhts.a : : @external-make : htslib ; - -alias hts - : libhts.a z - : static multi - : - : htslib -; diff --git a/lib/htslib b/lib/htslib deleted file mode 160000 index a68627505..000000000 --- a/lib/htslib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a686275058e5f99ba466f54441b646021dd69e17 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4aa75588b..d79a577b1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,11 +21,10 @@ set(SOURCE_FILES variant_reader_test.cpp variant_test.cpp) -include("../contrib/htslib.cmake") +add_executable(gamgee_test EXCLUDE_FROM_ALL ${SOURCE_FILES}) -include_directories(${Boost_INCLUDE_DIRS}) - -add_executable(gamgee_test ${SOURCE_FILES}) -target_compile_definitions(gamgee_test PUBLIC -DBOOST_TEST_DYN_LINK) +## This is the right way to do this, but only supported in cmake 2.8.12 +# target_compile_definitions(gamgee_test PUBLIC -DBOOST_TEST_DYN_LINK) +set_property(TARGET gamgee_test PROPERTY COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK) target_link_libraries(gamgee_test gamgee ${htslib_LIB} ${Boost_LIBRARIES} pthread z) add_dependencies(gamgee_test htslib) \ No newline at end of file diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 5ce138e4a..000000000 --- a/test/Jamfile +++ /dev/null @@ -1,10 +0,0 @@ -using testing ; -lib boost_unit_test_framework ; - -run [ glob *.cpp ] /gamgee//gamgee /gamgee/libs//hts boost_unit_test_framework - : - : - : BOOST_ALL_DYN_LINK multi ../gamgee - : run - : debug -;