diff --git a/CMakeLists.txt b/CMakeLists.txt index 4787286..19af1dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ set(CMAKE_MODULE_PATH include(TestHelper) include(VersionHelper) include(ProjectHelper) +include(PreDepends) +PreDependsInit() #set(EXE_VERSION_SUFFIX ${FULL_VERSION}) @@ -27,9 +29,6 @@ include_directories(${Boost_INCLUDE_DIRS}) include(BuildSamtools) include_directories(${Samtools_INCLUDE_DIRS}) -add_custom_target(deps ALL) -add_dependencies(deps samtools-lib boost-1.55) - if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang") set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") endif () @@ -40,18 +39,6 @@ link_libraries(${CMAKE_THREAD_LIBS_INIT}) # make sure to pick up headers from library dirs include_directories("src/lib") -# unit tests -find_package(GTest) -if(GTEST_FOUND) - message("Google Test framework found, building unit tests") - enable_testing(true) - add_projects(test/lib) -else() - message("Google Test framework not found, no tests will be built") - message("GTest is available at http://code.google.com/p/googletest/") - message("Ubuntu users can likely sudo apt-get install gtest") -endif() - # main project set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/README.textile b/README.textile index ba8fb4d..03610ac 100644 --- a/README.textile +++ b/README.textile @@ -110,7 +110,6 @@ h3. Compile bam-readcount * bam-readcount does not support in source builds. Create a new build directory, enter it, and run: bc. cmake /path/to/bam-readcount/repo - make deps make p. The binary can then be found in the bin/ subdirectory of your build directory. diff --git a/cmake/BuildBoost.cmake b/cmake/BuildBoost.cmake index ca0debc..d796ad5 100644 --- a/cmake/BuildBoost.cmake +++ b/cmake/BuildBoost.cmake @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(ExternalProject) - set(DEFAULT_BOOST_URL ${CMAKE_SOURCE_DIR}/vendor/boost-1.55-bamrc.tar.gz) if(NOT DEFINED BOOST_URL) set(BOOST_URL ${DEFAULT_BOOST_URL}) @@ -24,17 +22,19 @@ endforeach(libname ${REQUIRED_BOOST_LIBS}) message("Extracting boost from ${BOOST_URL}") message("Boost build log can be found at ${BOOST_LOG}") -ExternalProject_Add( +ExternalDependency_Add( boost-1.55 - URL ${BOOST_URL} - SOURCE_DIR ${BOOST_SRC} - BINARY_DIR ${BOOST_SRC} - CONFIGURE_COMMAND "./bootstrap.sh" - BUILD_COMMAND - echo "Building boost, build log is ${BOOST_LOG}" && - ./b2 --prefix=${BOOST_ROOT} --layout=system link=static - threading=multi install ${BOOST_BUILD_LIBS} > ${BOOST_LOG} 2>&1 - INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${Boost_LIBRARIES} + ARGS + URL ${BOOST_URL} + SOURCE_DIR ${BOOST_SRC} + BINARY_DIR ${BOOST_SRC} + CONFIGURE_COMMAND "./bootstrap.sh" + BUILD_COMMAND + echo "Building boost, build log is ${BOOST_LOG}" && + ./b2 --prefix=${BOOST_ROOT} --layout=system link=static + threading=multi install ${BOOST_BUILD_LIBS} > ${BOOST_LOG} 2>&1 + INSTALL_COMMAND "true" ) set(Boost_INCLUDE_DIRS ${BOOST_ROOT}/include) diff --git a/cmake/BuildSamtools.cmake b/cmake/BuildSamtools.cmake index 3f1389a..889a9db 100644 --- a/cmake/BuildSamtools.cmake +++ b/cmake/BuildSamtools.cmake @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(ExternalProject) - set(SAMTOOLS_ROOT ${CMAKE_BINARY_DIR}/vendor/samtools) set(SAMTOOLS_LOG ${SAMTOOLS_ROOT}/build.log) set(SAMTOOLS_LIB ${SAMTOOLS_ROOT}/${CMAKE_FIND_LIBRARY_PREFIXES}bam${CMAKE_STATIC_LIBRARY_SUFFIX}) @@ -11,37 +9,36 @@ find_package(ZLIB) if (NOT ZLIB_FOUND) set(ZLIB_ROOT ${CMAKE_BINARY_DIR}/vendor/zlib) set(ZLIB_SRC ${CMAKE_BINARY_DIR}/vendor/zlib-src) - ExternalProject_Add( - zlib - URL ${CMAKE_SOURCE_DIR}/vendor/zlib-1.2.8.tar.gz - SOURCE_DIR ${ZLIB_SRC} - BINARY_DIR ${ZLIB_SRC} - CONFIGURE_COMMAND ./configure --prefix=${ZLIB_ROOT} - BUILD_COMMAND make - INSTALL_COMMAND make install - ) set(ZLIB_INCLUDE_DIRS ${ZLIB_ROOT}/include) set(ZLIB_LIBRARIES ${ZLIB_ROOT}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}z${CMAKE_STATIC_LIBRARY_SUFFIX}) - add_library(z STATIC IMPORTED) - set_property(TARGET z PROPERTY IMPORTED_LOCATION ${ZLIB_LIBRARIES}) + ExternalDependency_Add( + zlib + BUILD_BYPRODUCTS ${ZLIB_LIBRARIES} + ARGS + URL ${CMAKE_SOURCE_DIR}/vendor/zlib-1.2.8.tar.gz + SOURCE_DIR ${ZLIB_SRC} + BINARY_DIR ${ZLIB_SRC} + CONFIGURE_COMMAND ./configure --prefix=${ZLIB_ROOT} + BUILD_COMMAND make + INSTALL_COMMAND make install + ) endif (NOT ZLIB_FOUND) -ExternalProject_Add( +ExternalDependency_Add( samtools-lib - URL ${CMAKE_SOURCE_DIR}/vendor/samtools-0.1.19.tar.gz - SOURCE_DIR ${SAMTOOLS_ROOT} - BINARY_DIR ${SAMTOOLS_ROOT} - PATCH_COMMAND patch -p2 -t -N < ${CMAKE_SOURCE_DIR}/vendor/samtools0.1.19.patch - CONFIGURE_COMMAND echo "Building samtools, build log at ${SAMTOOLS_LOG}" - BUILD_COMMAND make INCLUDES=-I${ZLIB_INCLUDE_DIRS} libbam.a > ${SAMTOOLS_LOG} 2>&1 - INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${SAMTOOLS_LIB} ${SAMTOOLS_BIN} + ARGS + URL ${CMAKE_SOURCE_DIR}/vendor/samtools-0.1.19.tar.gz + SOURCE_DIR ${SAMTOOLS_ROOT} + BINARY_DIR ${SAMTOOLS_ROOT} + PATCH_COMMAND patch -p2 -t -N < ${CMAKE_SOURCE_DIR}/vendor/samtools0.1.19.patch + CONFIGURE_COMMAND echo "Building samtools, build log at ${SAMTOOLS_LOG}" + BUILD_COMMAND make INCLUDES=-I${ZLIB_INCLUDE_DIRS} libbam.a > ${SAMTOOLS_LOG} 2>&1 + INSTALL_COMMAND "true" ) -add_library(bam STATIC IMPORTED) -set_property(TARGET bam PROPERTY IMPORTED_LOCATION ${SAMTOOLS_LIB}) - set(Samtools_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS};${SAMTOOLS_ROOT}) -set(Samtools_LIBRARIES bam m ${ZLIB_LIBRARIES}) +set(Samtools_LIBRARIES ${SAMTOOLS_LIB} m ${ZLIB_LIBRARIES}) if (NOT ZLIB_FOUND) add_dependencies(samtools-lib zlib) diff --git a/src/exe/bam-readcount/CMakeLists.txt b/src/exe/bam-readcount/CMakeLists.txt index 020a0db..b1551da 100644 --- a/src/exe/bam-readcount/CMakeLists.txt +++ b/src/exe/bam-readcount/CMakeLists.txt @@ -5,7 +5,7 @@ project(bam-readcount) set(SOURCES bamreadcount.cpp) set(EXECUTABLE_NAME bam-readcount) -add_executable(${EXECUTABLE_NAME} ${SOURCES}) +xadd_executable(${EXECUTABLE_NAME} ${SOURCES}) target_link_libraries(${EXECUTABLE_NAME} bamrc ${Samtools_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES PACKAGE_OUTPUT_NAME ${EXECUTABLE_NAME}${EXE_VERSION_SUFFIX}) install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin/) diff --git a/src/lib/bamrc/CMakeLists.txt b/src/lib/bamrc/CMakeLists.txt index c25baba..7326f52 100644 --- a/src/lib/bamrc/CMakeLists.txt +++ b/src/lib/bamrc/CMakeLists.txt @@ -9,5 +9,5 @@ set(SOURCES BasicStat.cpp ) -add_library(bamrc ${SOURCES}) +xadd_library(bamrc ${SOURCES}) target_link_libraries(bamrc ${Boost_LIBRARIES} ${Samtools_LIBRARIES} ${ZLIB_LIBRARIES})