-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
134 lines (101 loc) · 4.49 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
129
130
131
132
133
134
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.4 )
project (dstc)
SET(PACKAGE_VERSION "1.00")
SET(PACKAGE_LICENSE "GPL")
SET(CMAKE_BUILD_TYPE Release)
SET(PROJECT_DESCRIPTION_SUMMARY "C++ tools for the belief tracker problem on the DSTC data")
option(DSTC_Viewer "Do you want to compile the viewer as well ? (ON/OFF(default))" OFF)
IF(${DSTC_Viewer} MATCHES "ON")
MESSAGE("I will compile the viewer of the DSTC data")
ELSE(${DSTC_Viewer} MATCHES "ON")
MESSAGE("I will NOT compile the viewer of the DSTC data, add -DDSTC_Viewer=ON otherwise")
ENDIF()
#######################################
# Get the libs/inc for the dependencies
#######################################
find_package(PkgConfig)
pkg_check_modules(JSONCPP jsoncpp REQUIRED)
set(PKG_CONFIG_DEPENDS "jsoncpp")
#######################################
# Get the libs/inc for the viewer
#######################################
IF(${DSTC_Viewer} MATCHES "ON")
set(DESIRED_QT_VERSION 4)
find_package(Qt REQUIRED)
include_directories(${QT_INCLUDE_DIRS} ${QT_INCLUDE_DIR})
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ENDIF()
#######################################
# Setting the compilation flags
#######################################
# cflags added by the package
SET(PROJECT_CFLAGS "-Wall -std=c++11")
# cflags added by the pkg-config dependencies contains ';' as separator. This is a fix.
string(REPLACE ";" " " JSONCPP_CFLAGS "${JSONCPP_CFLAGS}")
# libs added by the pkg-config dependencies contains ';' as separator. This is a fix.
string(REPLACE ";" " " JSONCPP_LDFLAGS "${JSONCPP_LDFLAGS}")
# Gathering of all flags
# (e.g. for compiling examples)
SET(PROJECT_ALL_CFLAGS "${PROJECT_CFLAGS} ${JSONCPP_CFLAGS}")
SET(PROJECT_ALL_LDFLAGS "-Wl,--no-as-needed ${JSONCPP_LDFLAGS} -lboost_system -lboost_filesystem")
###################################
# Some prefix definitions
###################################
# Define the prefix where libs are going to be installed
SET(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
# Define the path to install the headers
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}/" CACHE PATH "The subdirectory to the header prefix")
# Define the path to install the documentation
SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}" CACHE PATH "The subdirectory to the documentation prefix")
# Define the path to install the pc pkg-config file
SET(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
###################################
# Pkg-config stuff
###################################
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
"
Name: ${CMAKE_PROJECT_NAME}
Description: ${PROJECT_DESCRIPTION_SUMMARY}
Version: ${PACKAGE_VERSION}
Requires: ${PKG_CONFIG_DEPENDS}
Libs: -L${LIB_INSTALL_DIR} ${PROJECT_LDFLAGS} ${PROJECT_LIBS}
Cflags: -I${INCLUDE_INSTALL_DIR} ${PROJECT_CFLAGS}
"
)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
DESTINATION ${PKGCONFIG_INSTALL_DIR}
COMPONENT devel)
###################################
# Subdirectories
###################################
add_subdirectory(src)
add_subdirectory(examples)
#add_subdirectory(doc)
###################################
# Custom command for source tgz
###################################
SET(DIST_DIR "${CMAKE_PROJECT_NAME}-${PACKAGE_VERSION}")
ADD_CUSTOM_TARGET(dist
COMMAND rm -rf ${DIST_DIR}
COMMAND mkdir ${DIST_DIR}
COMMAND cp -r ${CMAKE_SOURCE_DIR}/* ${DIST_DIR} || true
COMMAND rm -rf ${DIST_DIR}/build
COMMAND mkdir ${DIST_DIR}/build
COMMAND tar --exclude="*~" --exclude="._*" --exclude=".svn" -zcvf ${DIST_DIR}.tar.gz ${DIST_DIR}
COMMAND rm -rf ${DIST_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
###################################
# For building packages
###################################
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION_SUMMARY})
SET(CPACK_PACKAGE_VENDOR "Jeremy Fix")
SET(CPACK_PACKAGE_CONTACT "Jeremy.Fix@centralesupelec.fr")
SET(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
SET(CPACK_PACKAGE_LICENSE "${PACKAGE_LICENSE}")
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README.md)
SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.md)
SET(CPACK_RESOURCE_FILE_INSTALL ${CMAKE_SOURCE_DIR}/INSTALL)