forked from arrayfire/forge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForgeInternalUtils.cmake
60 lines (53 loc) · 1.75 KB
/
ForgeInternalUtils.cmake
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
# Copyright (c) 2017, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
function(dependency_check VAR ERROR_MESSAGE)
if(NOT ${VAR})
message(SEND_ERROR ${ERROR_MESSAGE})
endif()
endfunction()
# Includes the directory if the variable is set
function(conditional_directory variable directory)
if(${variable})
add_subdirectory(${directory})
endif()
endfunction()
function(get_native_path out_path path)
file(TO_NATIVE_PATH ${path} native_path)
string(REPLACE "\\" "\\\\" native_path ${native_path})
set(${out_path} ${native_path} PARENT_SCOPE)
endfunction()
function(__fg_deprecate_var var access value)
if(access STREQUAL "READ_ACCESS")
message(DEPRECATION "Variable ${var} is deprecated. Use FG_${var} instead.")
endif()
endfunction()
function(fg_deprecate var newvar)
if(DEFINED ${var})
message(DEPRECATION "Variable ${var} is deprecated. Use ${newvar} instead.")
get_property(doc CACHE ${newvar} PROPERTY HELPSTRING)
set(${newvar} ${${var}} CACHE BOOL "${doc}" FORCE)
unset(${var} CACHE)
endif()
variable_watch(${var} __fg_deprecate_var)
endfunction()
# mark CUDA cmake cache variables as advanced
# this should have been taken care of by FindCUDA I think.
mark_as_advanced(
CMAKE_CUDA_HOST_COMPILER
CUDA_HOST_COMPILER
CUDA_SDK_ROOT_DIR
CUDA_TOOLKIT_ROOT_DIR
CUDA_USE_STATIC_CUDA_RUNTIME
CUDA_rt_LIBRARY)
macro(set_policies)
cmake_parse_arguments(SP "" "TYPE" "POLICIES" ${ARGN})
foreach(_policy ${SP_POLICIES})
if(POLICY ${_policy})
cmake_policy(SET ${_policy} ${SP_TYPE})
endif()
endforeach()
endmacro()