forked from objectcomputing/mFAST
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
128 lines (104 loc) · 4.05 KB
/
CMakeLists.txt
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# The name of our project is "mFAST". CMakeLists files in this project can
# refer to the root source directory of the project as ${MFAST_SOURCE_DIR} and
# to the root binary directory of the project as ${MFAST_BINARY_DIR}.
cmake_minimum_required(VERSION 3.13)
project (mFAST CXX)
# options to build tests, examples and packages
option(BUILD_TESTS "Build tests" ON)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_PACKAGES "Build packages" ON)
option(STATIC_GEN "Static link fast type generator" OFF)
option(IS_CONAN2_BUILD "Indicates if conan2 was used for build" OFF)
# debug build by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(MFAST_MAJOR_VERSION 1)
set(MFAST_MINOR_VERSION 3)
set(MFAST_PATCH_VERSION 1)
set(MFAST_VERSION ${MFAST_MAJOR_VERSION}.${MFAST_MINOR_VERSION}.${MFAST_PATCH_VERSION})
set(MFAST_SOVERSION ${MFAST_MAJOR_VERSION}.${MFAST_MINOR_VERSION}.${MFAST_PATCH_VERSION})
# Setup conan dependencies if available
if (IS_CONAN2_BUILD)
find_package(Boost REQUIRED COMPONENTS headers)
find_package(tinyxml2 REQUIRED)
if (BUILD_TESTS)
find_package(Catch2 REQUIRED)
endif()
else()
find_package(Boost 1.59.0 REQUIRED)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2)
include_directories ("${PROJECT_SOURCE_DIR}/src")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
include(SetInstallPaths)
include(Emscripten)
include(SetCXXStandard)
include(SetCompilerWarnings)
include(SetupCoverage)
# flag to enable building shared/dynamic library
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build shared/dynamic library")
if(BUILD_PACKAGES)
# Build deb package by default
if(NOT CPACK_GENERATOR)
set(CPACK_GENERATOR "DEB" CACHE STRING "List of generators.")
endif()
if(CUSTOM_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CUSTOM_INSTALL_PREFIX} CACHE STRING "Custom installation prefix.")
set(CPACK_SET_DESTDIR true)
set(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A FAST (FIX Adapted for STreaming) encoder/decoder")
set(CPACK_PACKAGE_NAME "mfast")
set(CPACK_PACKAGE_VERSION ${MFAST_VERSION})
set(CPACK_PACKAGE_VENDOR "Object Computing, Inc.")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Huang-Ming Huang")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
include(CPack)
endif()
add_definitions(-DSIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
# variables to be used later
set(MFAST_SHARED_LIBRARIES CACHE INTERNAL "")
set(MFAST_STATIC_LIBRARIES CACHE INTERNAL "")
set(MFAST_DYNAMIC_COMPONENTS CACHE INTERNAL "")
set(MFAST_STATIC_COMPONENTS CACHE INTERNAL "")
add_subdirectory (src)
include(FastTypeGenTarget)
if(BUILD_TESTS)
enable_testing()
add_subdirectory (tests)
endif()
if (BUILD_SHARED_LIBS)
set(MFAST_LIBRARIES "${MFAST_SHARED_LIBRARIES}")
else()
set(MFAST_LIBRARIES "${MFAST_STATIC_LIBRARIES}")
endif()
if(BUILD_EXAMPLES)
add_subdirectory (examples)
endif()
# Setting up dist target
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${MFAST_VERSION})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
include(GenProjectConfig)
file(GLOB schema_files "${CMAKE_CURRENT_SOURCE_DIR}/schema/*.*")
install(FILES
${schema_files}
DESTINATION ${INSTALL_DATA_DIR}/mfast)
# Print summary
message(STATUS "")
message(STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND})
message(STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM})
message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER})
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
message(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
message(STATUS "BUILD_TESTS: " ${BUILD_TESTS})
message(STATUS "BUILD_EXAMPLES: " ${BUILD_EXAMPLES})
message(STATUS "BUILD_PACKAGES: " ${BUILD_PACKAGES})
message(STATUS "")