-
Notifications
You must be signed in to change notification settings - Fork 149
/
XRootDUtils.cmake
73 lines (62 loc) · 2.5 KB
/
XRootDUtils.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
61
62
63
64
65
66
67
68
69
70
71
72
73
#-------------------------------------------------------------------------------
# Add a compiler define flag if a variable is defined
#-------------------------------------------------------------------------------
function( compiler_define_if_found predicate name )
if( ${predicate} )
add_definitions( -D${name} )
endif()
endfunction()
macro( define_default variable value )
if( NOT DEFINED ${variable} )
set( ${variable} ${value} )
endif()
endmacro()
macro( component_status name flag found )
if( ${flag} AND ${found} )
set( STATUS_${name} "yes" )
elseif( ${flag} AND NOT ${found} )
set( STATUS_${name} "libs not found" )
else()
set( STATUS_${name} "disabled" )
endif()
endmacro()
#-------------------------------------------------------------------------------
# Detect in source builds
#-------------------------------------------------------------------------------
function( CheckBuildDirectory )
# Get Real Paths of the source and binary directories
get_filename_component( srcdir "${CMAKE_SOURCE_DIR}" REALPATH )
get_filename_component( bindir "${CMAKE_BINARY_DIR}" REALPATH )
# Check for in-source builds
if( ${srcdir} STREQUAL ${bindir} )
message( FATAL_ERROR "XRootD cannot be built in-source! "
"Please run cmake <src-dir> outside the "
"source directory and be sure to remove "
"CMakeCache.txt or CMakeFiles if they "
"exist in the source directory." )
endif()
endfunction()
#-------------------------------------------------------------------------------
# Detect what kind of solaris machine we're running
#-------------------------------------------------------------------------------
macro( define_solaris_flavor )
execute_process( COMMAND isainfo
OUTPUT_VARIABLE SOLARIS_ARCH )
string( REPLACE " " ";" SOLARIS_ARCH_LIST ${SOLARIS_ARCH} )
# amd64 (opteron)
list( FIND SOLARIS_ARCH_LIST amd64 SOLARIS_AMD64 )
if( SOLARIS_AMD64 EQUAL -1 )
set( SOLARIS_AMD64 FALSE )
else()
set( SOLARIS_AMD64 TRUE )
endif()
endmacro()
#-------------------------------------------------------------------------------
# Install headers from a directory
#-------------------------------------------------------------------------------
function( install_headers destination files )
foreach( file ${files} )
string( REGEX MATCH "^(.+)/(.+)$" fileAr ${file} )
install( FILES ${file} DESTINATION ${destination}/${CMAKE_MATCH_1} )
endforeach()
endfunction()