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
|
# ==========================
# BamTools CMakeLists.txt
# (c) 2010 Derek Barnett
#
# top-level
# ==========================
# CMake requirements
cmake_minimum_required( VERSION 3.0 )
# allow setting project version in project()
# https://cmake.org/cmake/help/v3.0/policy/CMP0048.html#policy:CMP0048
cmake_policy( SET CMP0048 NEW )
# set project name and version
project( BamTools LANGUAGES CXX VERSION 2.5.1 )
enable_testing()
# on macOS, MACOSX_RPATH is enabled by default on more recent versions
# of CMake. Disable this behaviour, and let user enable it if need be.
cmake_policy( SET CMP0042 OLD )
# Set Release type for builds where CMAKE_BUILD_TYPE is unset
# This is usually a good default as this implictly enables
#
# CXXFLAGS = -O3 -DNDEBUG
#
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE "Release" )
endif()
# Adhere to GNU filesystem layout conventions
include( GNUInstallDirs )
# Force the build directory to be different from source directory
macro( ENSURE_OUT_OF_SOURCE_BUILD MSG )
string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource )
get_filename_component( PARENTDIR ${CMAKE_SOURCE_DIR} PATH )
string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir )
IF( insource OR insourcesubdir )
message( FATAL_ERROR "${MSG}" )
ENDIF( insource OR insourcesubdir )
endmacro( ENSURE_OUT_OF_SOURCE_BUILD )
ensure_out_of_source_build( "
${PROJECT_NAME} requires an out of source build.
$ mkdir build
$ cd build
$ cmake ..
$ make
(or the Windows equivalent)\n" )
# define compiler flags for all code, copied from Autoconf's AC_SYS_LARGEFILE
if( NOT WIN32 )
add_definitions( -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE )
add_compile_options( -Wall )
endif()
# -----------------------------------------------
# handle platform-/environment-specific defines
# By default build bamtools as a static library
# Most users will prefer static libraries, distributions
# can always switch the standard CMake variable over to ON.
set( BUILD_SHARED_LIBS OFF CACHE BOOL "Build all libraries as shared" )
# If planning to run in Node.js environment, run:
# cmake -DEnableNodeJS=true
if( EnableNodeJS )
add_definitions( -DSYSTEM_NODEJS=1 )
endif()
# If running on SunOS
if( "${CMAKE_SYSTEM_NAME}" MATCHES "SunOS" )
add_definitions( -DSUN_OS )
endif()
# find system JsonCpp
find_package( PkgConfig )
pkg_search_module( JSONCPP jsoncpp>=1 )
set( BAMTOOLS_PRIVATE_DEPS "zlib" )
if( JSONCPP_FOUND )
message( "Found system JsonCpp, not using bundled version" )
set( BAMTOOLS_PRIVATE_DEPS "${BAMTOOLS_PRIVATE_DEPS} jsoncpp" )
else()
message( "Did NOT find system JsonCpp, instead using bundled version" )
set( JSONCPP_LDFLAGS jsoncpp )
set( JSONCPP_INCLUDE_DIRS ${BamTools_SOURCE_DIR}/src/third_party/jsoncpp )
endif()
# -------------------------------------------
# add our includes root path
include_directories( src )
# list subdirectories to build in
add_subdirectory( src )
add_test(NAME bamtools_help
COMMAND bin/bamtools --help
)
add_test(NAME bamtools_stats
COMMAND bin/bamtools stats -in ${CMAKE_BINARY_DIR}/../debian/sam_spec_example.bam
)
|