Skip to content

Commit 353e7c9

Browse files
author
Vladimir Karnushin
committed
Add flags to build tests, examples and packages
1 parent 94f42de commit 353e7c9

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

CMakeLists.txt

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
cmake_minimum_required(VERSION 2.8.11)
66
project (mFAST CXX)
77

8+
# options to build tests, examples and packages
9+
option(BUILD_TESTS "Build tests" ON)
10+
option(BUILD_EXAMPLES "Build examples" ON)
11+
option(BUILD_PACKAGES "Build packages" ON)
12+
13+
# debug build by default
14+
if(NOT CMAKE_BUILD_TYPE)
15+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
16+
endif(NOT CMAKE_BUILD_TYPE)
17+
818
if(POLICY CMP0054)
919
cmake_policy(SET CMP0054 OLD)
1020
endif()
@@ -17,10 +27,6 @@ set(MFAST_PATCH_VERSION 0)
1727
set(MFAST_VERSION ${MFAST_MAJOR_VERSION}.${MFAST_MINOR_VERSION}.${MFAST_PATCH_VERSION})
1828
set(MFAST_SOVERSION ${MFAST_MAJOR_VERSION}.${MFAST_MINOR_VERSION})
1929

20-
set(CPACK_PACKAGE_VERSION ${MFAST_VERSION})
21-
set(CPACK_PACKAGE_NAME "mfast")
22-
23-
include(CPack)
2430
include(SetInstallPaths)
2531
include(Emscripten)
2632
include(SetCXXStandard)
@@ -30,6 +36,30 @@ include(SetupCoverage)
3036
# flag to enable building shared/dynamic library
3137
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build shared/dynamic library")
3238

39+
if(BUILD_PACKAGES)
40+
# Build deb package by default
41+
if(NOT CPACK_GENERATOR)
42+
set(CPACK_GENERATOR "DEB" CACHE STRING "List of generators.")
43+
endif(NOT CPACK_GENERATOR)
44+
45+
if(CUSTOM_INSTALL_PREFIX)
46+
set(CMAKE_INSTALL_PREFIX ${CUSTOM_INSTALL_PREFIX} CACHE STRING "Custom installation prefix.")
47+
set(CPACK_SET_DESTDIR true)
48+
set(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
49+
endif(CUSTOM_INSTALL_PREFIX)
50+
51+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A FAST (FIX Adapted for STreaming) encoder/decoder")
52+
set(CPACK_PACKAGE_NAME "mfast")
53+
set(CPACK_PACKAGE_VERSION ${MFAST_VERSION})
54+
set(CPACK_PACKAGE_VENDOR "Object Computing, Inc.")
55+
set(CPACK_PACKAGE_CONTACT "[email protected]")
56+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Huang-Ming Huang")
57+
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
58+
59+
include(CPack)
60+
61+
endif(BUILD_PACKAGES)
62+
3363
find_package(Boost 1.56.0 REQUIRED)
3464
include_directories(${Boost_INCLUDE_DIR})
3565
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2)
@@ -48,33 +78,31 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
4878
add_subdirectory (src)
4979
include(FastTypeGenTarget)
5080

51-
enable_testing()
52-
add_subdirectory (tests)
81+
if(BUILD_TESTS)
82+
enable_testing()
83+
add_subdirectory (tests)
84+
endif(BUILD_TESTS)
5385

5486
if (BUILD_SHARED_LIBS)
5587
set(MFAST_LIBRARIES "${MFAST_SHARED_LIBRARIES}")
5688
else (BUILD_SHARED_LIBS)
5789
set(MFAST_LIBRARIES "${MFAST_STATIC_LIBRARIES}")
5890
endif (BUILD_SHARED_LIBS)
5991

60-
add_subdirectory (examples)
61-
92+
if(BUILD_EXAMPLES)
93+
add_subdirectory (examples)
94+
endif(BUILD_EXAMPLES)
6295

6396
# Setting up dist target
64-
# ===============================
65-
6697
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${MFAST_VERSION})
6798
add_custom_target(dist
6899
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
69100
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
70101
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
71-
72102

73103
include(GenProjectConfig)
74104

75105
file(GLOB schema_files "${CMAKE_CURRENT_SOURCE_DIR}/schema/*.*")
76106
install(FILES
77107
${schema_files}
78108
DESTINATION ${INSTALL_DATA_DIR}/mfast)
79-
80-

0 commit comments

Comments
 (0)