forked from maidsafe-archive/MaidSafe-Drive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
148 lines (127 loc) · 7.52 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#==================================================================================================#
# #
# Copyright 2012 MaidSafe.net limited #
# #
# This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License, #
# version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which #
# licence you accepted on initial access to the Software (the "Licences"). #
# #
# By contributing code to the MaidSafe Software, or to this project generally, you agree to be #
# bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root #
# directory of this project at LICENSE, COPYING and CONTRIBUTOR respectively and also available #
# at: http://www.maidsafe.net/licenses #
# #
# Unless required by applicable law or agreed to in writing, the MaidSafe Software distributed #
# under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF #
# ANY KIND, either express or implied. #
# #
# See the Licences for the specific language governing permissions and limitations relating to #
# use of the MaidSafe Software. #
# #
#==================================================================================================#
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
project(drive)
include(../../cmake_modules/standard_setup.cmake)
include_directories(${common_SOURCE_DIR}/include)
include_directories(${private_SOURCE_DIR}/include)
include_directories(${passport_SOURCE_DIR}/include)
include_directories(${encrypt_SOURCE_DIR}/include)
include_directories(${routing_SOURCE_DIR}/include)
include_directories(${rudp_SOURCE_DIR}/include)
include_directories(${nfs_SOURCE_DIR}/include)
#==================================================================================================#
# Callback File System / Fuse library search #
#==================================================================================================#
set(DriveThirdPartyIncludes PARENT_SCOPE)
if(WIN32)
include(maidsafe_find_cbfs)
set(DriveThirdPartyIncludes ${Cbfs_INCLUDE_DIR} PARENT_SCOPE)
else()
include(maidsafe_find_fuse)
if(APPLE)
set(DriveThirdPartyIncludes ${Fuse_INCLUDE_DIR} PARENT_SCOPE)
endif()
endif()
#==================================================================================================#
# Set up all files as GLOBs #
#==================================================================================================#
set(DriveSourcesDir ${PROJECT_SOURCE_DIR}/src/maidsafe/drive)
set(DriveApiDir ${PROJECT_SOURCE_DIR}/include/maidsafe/drive)
glob_dir(Drive ${DriveSourcesDir} Drive)
set(WinServiceMain ${DriveSourcesDir}/win_service_main.cc)
set(UnixFiles ${DriveApiDir}/unix_drive.h ${DriveSourcesDir}/unix_drive.cc)
set(CbfsWinFiles ${DriveApiDir}/win_drive.h ${DriveSourcesDir}/win_drive.cc)
set(DummyWinFiles ${DriveApiDir}/dummy_win_drive.h ${DriveSourcesDir}/dummy_win_drive.cc)
if(WIN32)
if(Cbfs_FOUND)
list(REMOVE_ITEM DriveAllFiles ${WinServiceMain} ${UnixFiles} ${DummyWinFiles})
else()
list(REMOVE_ITEM DriveAllFiles ${WinServiceMain} ${UnixFiles} ${CbfsWinFiles})
endif()
else()
list(REMOVE_ITEM DriveAllFiles ${WinServiceMain} ${CbfsWinFiles} ${DummyWinFiles})
endif()
glob_dir(DriveTests ${DriveSourcesDir}/tests Tests)
list(REMOVE_ITEM DriveTestsAllFiles ${DriveSourcesDir}/tests/filesystem_benchmark.cc
${DriveSourcesDir}/tests/filesystem_test.cc
${DriveSourcesDir}/tests/shares_test.cc)
set(TestSharesFiles ${DriveSourcesDir}/tests/shares_test.cc
${DriveSourcesDir}/tests/test_main.cc
${DriveSourcesDir}/tests/test_utils.cc
${DriveSourcesDir}/tests/test_utils.h)
source_group("Source Files" FILES ${DriveSourcesDir}/tests/filesystem_benchmark.cc
${DriveSourcesDir}/tests/filesystem_test.cc)
if(WIN32)
glob_dir(Installer ${DriveSourcesDir}/installer Installer)
endif()
#==================================================================================================#
# Define MaidSafe libraries and executables #
#==================================================================================================#
ms_add_static_library(drive ${DriveAllFiles})
target_link_libraries(maidsafe_drive maidsafe_encrypt maidsafe_nfs_client ${BoostRegexLibs})
if(WIN32)
if(Cbfs_FOUND)
ms_add_executable(cbfs_driver "Production" ${InstallerAllFiles})
target_link_libraries(maidsafe_drive ${Cbfs_LIBRARIES})
target_link_libraries(cbfs_driver ${BoostFilesystemLibs} ${BoostSystemLibs} ${Cbfs_LIBRARIES} ${JustThread_LIBRARIES})
add_dependencies(cbfs_driver boost)
endif()
elseif(APPLE)
target_link_libraries(maidsafe_drive ${Fuse_LIBRARY})
else()
target_link_libraries(maidsafe_drive ${Fuse_LIBRARY} rt dl)
endif()
#TODO (TEAM) Create unit test target for directory listing to build even with dummy win dependency
if(MaidsafeTesting AND (Cbfs_FOUND OR NOT WIN32))
ms_add_executable(filesystem_benchmark "Tools/Drive" ${DriveSourcesDir}/tests/filesystem_benchmark.cc)
ms_add_executable(FilesystemTest "Tests/Drive" ${DriveSourcesDir}/tests/filesystem_test.cc)
ms_add_executable(TESTdrive "Tests/Drive" ${DriveTestsAllFiles})
target_link_libraries(filesystem_benchmark maidsafe_common)
target_link_libraries(FilesystemTest maidsafe_common)
add_dependencies(FilesystemTest catch)
target_link_libraries(TESTdrive maidsafe_drive)
endif()
rename_outdated_built_exes()
#==================================================================================================#
# Set compiler and linker flags #
#==================================================================================================#
include(standard_flags)
if(Cbfs_FOUND)
add_definitions(-DCBFS_KEY=${Cbfs_KEY} -DHAVE_CBFS)
endif()
if(Cbfs_FOUND)
set_target_properties(cbfs_driver PROPERTIES LINK_FLAGS "/level='requireAdministrator' /uiAccess='false'")
endif()
#==================================================================================================#
# Tests #
#==================================================================================================#
if(MaidsafeTesting)
add_style_test()
if(Cbfs_FOUND OR NOT WIN32)
add_gtests(TESTdrive)
endif()
add_project_experimental()
test_summary_output()
endif()