This repository has been archived by the owner on Oct 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
94 lines (80 loc) · 3.25 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
project(shadow-plugins-extra)
## ensure cmake version
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
## ensure unix environment (CMAKE_SYSTEM_NAME == "Linux")
if((NOT UNIX) OR (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")))
message(FATAL_ERROR "Unix/Linux environment is required.")
endif((NOT UNIX) OR (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")))
## ensure out-of-source build
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "An out-of-source build is required. Please see the README.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
## make it easier for sub-projects to add CFLAGS
macro(add_cflags)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGN}")
endmacro(add_cflags)
## now handle the options, set up our own flags
set(CMAKE_C_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Release enabled. Setting '-DNDEBUG' and '-O3'.")
add_definitions(-DNDEBUG)
add_cflags(-O3)
else()
message(STATUS "Debug enabled. Setting '-DDEBUG' and '-g'.")
add_definitions(-DDEBUG)
add_cflags(-g)
endif()
## get general includes
include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(TestBigEndian)
## general tests and configurations
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
## we need to know where shadow is installed
if("${SHADOW_ROOT}" STREQUAL "")
set(SHADOW_ROOT "$ENV{HOME}/.shadow")
endif("${SHADOW_ROOT}" STREQUAL "")
if(EXISTS "${SHADOW_ROOT}")
message(STATUS "SHADOW_ROOT = ${SHADOW_ROOT}")
else()
message(FATAL_ERROR "SHADOW_ROOT path does not exist: '${SHADOW_ROOT}'")
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${SHADOW_ROOT}")
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(EXISTS "${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
else()
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX path does not exist: '${CMAKE_INSTALL_PREFIX}'")
endif()
## we use cmake files from shadow
set(CMAKE_MODULE_PATH "${SHADOW_ROOT}/share/cmake/Modules")
if(EXISTS "${CMAKE_MODULE_PATH}")
message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
else()
message(FATAL_ERROR "CMAKE_MODULE_PATH path does not exist: '${CMAKE_MODULE_PATH}'")
endif()
include_directories(${CMAKE_MODULE_PATH})
include(ShadowTools)
## plug-ins need to disable fortification to ensure syscalls are intercepted
#add_definitions(-D_GNU_SOURCE)
add_cflags("-fno-inline -fno-strict-aliasing -U_FORTIFY_SOURCE")
## CFLAGS status update
message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
## recurse to build each plug-in
add_subdirectory(${CMAKE_SOURCE_DIR}/echo/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/filetransfer/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/browser/)
add_subdirectory(${CMAKE_SOURCE_DIR}/hello/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/ping/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/torcontrol/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/torrent/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/python/)
#add_subdirectory(${CMAKE_SOURCE_DIR}/python/python3)
add_subdirectory(${CMAKE_SOURCE_DIR}/tor-echo/)
add_subdirectory(${CMAKE_SOURCE_DIR}/pcap_replay/)