-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
169 lines (141 loc) · 5.73 KB
/
CMakeLists.txt
File metadata and controls
169 lines (141 loc) · 5.73 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Destruct -- The data structure analysis library
# Copyright (C) 2013-2014 ArxSys
# This program is free software, distributed under the terms of
# the GNU General Public License Version 2. See the LICENSE file
# at the top of the source tree.
#
# See http://www.digital-forensic.org for more information about this
# project. Please do not directly contact any of the maintainers of
# DFF for assistance; the project provides a web site, mailing lists
# and IRC channels for your use.
#
# Author(s):
# Solal Jacob <sja@digital-forensic.org>
#project (destruct)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
set(CMAKE_INCLUDE_PATH "${INCLUDEDIR}")
set(CMAKE_LIBRARY_PATH "${LIBDIR}")
# Check 64 bit
if( "${CMAKE_SIZEOF_VOID_P}" EQUAL 4 )
set( HAVE_64_BITS 0 )
else( "${CMAKE_SIZEOF_VOID_P}" EQUAL 4 )
if (WIN32)
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DSWIGWORDSIZE32)
else()
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DSWIGWORDSIZE64)
endif()
set( HAVE_64_BITS 1 )
endif( "${CMAKE_SIZEOF_VOID_P}" EQUAL 4 )
if (WIN32)
if (DEPENDENCIES_PATH)
set(DEPENDENCIES_INCLUDE_DIR ${DEPENDENCIES_PATH}/include)
if (HAVE_64_BITS)
set(DEPENDENCIES_LIBRARIES_DIR ${DEPENDENCIES_PATH}/lib64)
set(DEPENDENCIES_RUNTIME_DIR ${DEPENDENCIES_PATH}/bin64)
else (HAVE_64_BITS)
set(DEPENDENCIES_LIBRARY_DIR ${DEPENDENCIES_PATH}/lib)
set(DEPENDENCIES_RUNTIME_DIR ${DEPENDENCIES_PATH}/bin)
endif(HAVE_64_BITS)
message("Headers path ${DEPENDENCIES_INCLUDE_DIR}")
message("Libraries path ${DEPENDENCIES_LIBRARIES_DIR}")
message("Runtime path ${DEPENDENCIES_RUNTIME_DIR}")
else (DEPENDENCIES_PATH)
message(FATAL_ERROR "On Windows platform DEPENDENCIES_PATH must be provided and point to the directory containing include lib[64] and bin[64] folders")
endif(DEPENDENCIES_PATH)
endif(WIN32)
if (WIN32)
set(ICU_INCLUDE_PATH ${DEPENDENCIES_INCLUDE_DIR}/icu)
set(ICU_LIBRARIES_PATH ${DEPENDENCIES_LIBRARIES_DIR})
set(ICU_DYNLIB_PATH ${DEPENDENCIES_RUNTIME_DIR})
message(${ICU_INCLUDE_PATH})
endif (WIN32)
find_package(ICU REQUIRED)
include_directories(ICU_INCLUDE_PATH)
include_directories(${ICU_INCLUDE_DIRS})
find_package(ZMQ)
include_directories(${LIBZMQ_INCLUDE_DIR})
find_package(CZMQ)
include_directories(${CZMQ_INCLUDE_DIR})
IF (NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
SET(DEDICATED_BUILD_DIR 1)
message(STATUS "Building project in dedicated build directory : ${CMAKE_BINARY_DIR}")
ENDIF (NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
option(ENABLE_DEBUG "Compile using -g flag ? Useful for debugging" OFF)
add_definitions(-D__STDC_LIMIT_MACROS)
if(UNIX)
if (ENABLE_LEAK_DETECTION)
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=leak")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=leak")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=leak")
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -g -Wall -O1 -fsanitize=leak -fno-omit-frame-pointer -fno-optimize-sibling-calls)
message(STATUS "Compile using lsan library to detect memory leak, use LD_PRELOAD=path_to_gcc_lsan.so ./dff.py to run")
elseif(ENABLE_DEBUG)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -g -O3 -flto -Wall -fprofile-use)
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -flto")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
message(STATUS "Compile using -g and no optimization")
else(ENABLE_LEAK_DETECTION)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -O3 -flto -Wall -fprofile-use)
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -flto")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
message(STATUS "Compile with optimization")
endif(ENABLE_LEAK_DETECTION)
endif(UNIX)
if (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__value=_value")
endif(MSVC)
include_directories(.)
add_subdirectory(protocol)
set (destruct_source_files
dattribute.cpp
ddynamicobject.cpp
dobject.cpp
dsimpleobject.cpp
dstruct.cpp
dtype.cpp
dvalue.cpp
dstructs.cpp
dnullobject.cpp
dexception.cpp
dunicodestring.cpp
dbuffer.cpp
protocol/protocol.cpp
protocol/dmutablestruct.cpp
protocol/dmutableobject.cpp
protocol/dserializebinary.cpp
protocol/dserializetext.cpp
protocol/dserializexml.cpp
protocol/dserializeraw.cpp
protocol/dstream.cpp
protocol/dstreamcout.cpp
protocol/dstreamstring.cpp
protocol/traceobject.cpp
protocol/recursivetraceobject.cpp
protocol/import.cpp
)
configure_file(__init__.py __init__.py COPYONLY)
add_library(destruct SHARED ${destruct_source_files})
target_link_libraries(destruct ${ICU_LIBRARIES})
if(UNIX)
target_link_libraries(destruct dl)
endif(UNIX)
file(RELATIVE_PATH rpath ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if ( CMAKE_GENERATOR MATCHES "Visual Studio")
set_target_properties (destruct PROPERTIES
SUFFIX ".dll"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}/python"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/python"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_BINARY_DIR}/python"
)
file(APPEND "${CMAKE_BINARY_DIR}/installed_files.log" "${rpath}/destruct.dll\n")
elseif (UNIX)
file(APPEND "${CMAKE_BINARY_DIR}/installed_files.log" "${rpath}/libdestruct.so\n")
endif()
file(APPEND "${CMAKE_BINARY_DIR}/installed_files.log" "${rpath}/__init__.py\n")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py DESTINATION ${INSTALL_FILE_DESTINATION}/${rpath})
add_subdirectory(examples)
add_subdirectory(python)
add_subdirectory(doc)