forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
71 lines (60 loc) · 2.16 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
# minimum required cmake version: 3.1.0
cmake_minimum_required(VERSION 3.1.0)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(DEPENDENCIES realsense2)
find_package (Python3 COMPONENTS Interpreter Development)
if (NOT ${BUILD_EASYLOGGINGPP})
message(FATAL_ERROR "Unit tests are not supported without BUILD_EASYLOGGINGPP; Check BUILD_EASYLOGGINGPP to run them.")
endif()
# Set <empty> on exit
function(is_file_empty empty filename)
set (data "")
set(res TRUE)
if(EXISTS ${filename})
# Travis has CMake 3.5.1... no SIZE support!
#file(SIZE ${filename} data_length)
file(READ ${filename} data LIMIT 2 HEX)
string(LENGTH "${data}" data_length)
if (NOT ${data_length} STREQUAL "0")
set(res FALSE)
#else()
# message(STATUS "${data_length} bytes from ${filename}")
endif()
endif()
set(empty ${res} PARENT_SCOPE)
endfunction()
# General function for downloading files
function(dl_file src dir filename sha1)
get_filename_component( dest ${dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR} )
is_file_empty( empty ${dest}/${filename} )
#message(STATUS "empty= ${empty}")
if( ${empty} )
message(STATUS "Downloading '${filename}' into '${dest}'")
#message(STATUS "... from '${src}/${filename}'")
if( NOT sha1 )
file( DOWNLOAD "${src}/${filename}" "${dest}/${filename}"
STATUS status )
else()
file(DOWNLOAD "${src}/${filename}" "${dest}/${filename}"
EXPECTED_HASH SHA1=${sha1}
STATUS status)
endif()
list( GET status 0 code )
list( GET status 1 message )
#message( STATUS " status = ${status} code = ${code} message = ${message}" )
if( code )
#message( STATUS "... from '${src}/${filename}'" )
message( SEND_ERROR " ${message}")
endif()
endif()
endfunction()
if(BUILD_UNIT_TESTS)
include(./unit-tests.cmake)
endif()
if(BUILD_LEGACY_LIVE_TEST)
include(./live-test.cmake)
endif()
if(NOT ${BUILD_SHARED_LIBS} AND ${BUILD_INTERNAL_UNIT_TESTS})
add_subdirectory(internal)
endif()