-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
140 lines (114 loc) · 5.21 KB
/
Copy pathCMakeLists.txt
File metadata and controls
140 lines (114 loc) · 5.21 KB
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
#
# Copyright 2021 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This file contains mainly the logic to create the wrapper scripts for the
# installation directory, to build GraphBLAS binaries outside of CMake's workflow.
#
### ADD BACKENDS
add_subdirectory( graphblas )
### Add transition path targets
add_subdirectory( transition )
### BUILD WRAPPER SCRIPTS FOR INSTALLATION
assert_valid_variables( AVAILABLE_BACKENDS CMAKE_INSTALL_PREFIX INCLUDE_INSTALL_DIR
VERSION BIN_INSTALL_DIR COMMON_LFLAGS_POST
)
if( WITH_BSP1D_BACKEND OR WITH_HYBRID_BACKEND )
assert_valid_variables( LPFRUN_CMD MANUALRUN )
endif()
# join elements in the list named inListName by a space ' ', wrap them inside
# quotes "" and append them to the list named outListName
# EXAMPLE: input list: 'compiler;--switch;value' -> appended string: '"compiler --switch value"'
# (quotes "" are also part of the text)
#
# do NOT expand strings with paths as macro arguments, pass only NAMES of variables
# (not their content)
macro( joinAndAppend outListName inListName )
list( JOIN ${inListName} " " tmp_spaced )
list( APPEND ${outListName} "\"${tmp_spaced}\"" )
endmacro( joinAndAppend )
# for each backend, check for the wrapper information variables and create the lists
# of values to be stored inside the wrappers
foreach( backend ${AVAILABLE_BACKENDS} )
assert_valid_variables( ${backend}_WRAPPER_COMPILER_COMMAND )
assert_defined_variables( ${backend}_WRAPPER_RUNNER ${backend}_WRAPPER_LINK_FLAGS
${backend}_WRAPPER_COMPILE_DEFINITIONS ${backend}_WRAPPER_COMPILE_OPTIONS
)
list( APPEND backend_list "\"${backend}\"" )
joinAndAppend( compiler_list ${backend}_WRAPPER_COMPILER_COMMAND )
joinAndAppend( library_dir ${backend}_LIB_DIR )
joinAndAppend( runner_list ${backend}_WRAPPER_RUNNER )
string( TOUPPER ${backend} _bname )
list( APPEND backend_dir_list "ALP_${_bname}_LIBRARY_PATH=\"${${backend}_LIB_DIR}\"" )
joinAndAppend( runenv_list ${backend}_LIB_DIR )
set( compile_options "${${backend}_WRAPPER_COMPILE_DEFINITIONS}" )
list( TRANSFORM compile_options PREPEND "-D" )
list( APPEND compile_options ${${backend}_WRAPPER_COMPILE_OPTIONS} )
joinAndAppend( compile_options_list compile_options )
joinAndAppend( link_flags_list ${backend}_WRAPPER_LINK_FLAGS )
endforeach( )
# space the options and pass them to the scripts via configure_file
#
# internal issue #317: cannot use quoted LPFRUN_CMD_Q here, because
# sourcing the resulting setenv makes the quotes seem as part of the
# executable name. Until this is fixed, we do not support spaces in
# the LPF install path (FIXME)
macro( joinWithNewLine inListName outListName )
list( JOIN ${inListName} "\n" tmp_spaced )
set( ${outListName} "\n${tmp_spaced}\n" )
endmacro( joinWithNewLine )
joinWithNewLine( backend_list AVAILABLE_BACKENDS_SPACED )
list( JOIN LPFRUN_CMD " " LPFRUN_CMD_SPACED )
list( JOIN MANUALRUN " " MANUALRUN_SPACED )
joinWithNewLine( backend_dir_list BACKEND_DIR_LIST )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/setenv.in ${CMAKE_CURRENT_BINARY_DIR}/setenv @ONLY )
joinWithNewLine( compiler_list BACKEND_COMPILERS_SPACED )
joinWithNewLine( library_dir LIBRARY_DIRS_SPACED )
joinWithNewLine( compile_options_list BACKEND_CFLAGS_SPACED )
joinWithNewLine( link_flags_list BACKEND_LFLAGS_SPACED )
list( JOIN COMMON_LFLAGS_POST " " COMMON_LFLAGS_POST_SPACED )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/grbcxx.in ${CMAKE_CURRENT_BINARY_DIR}/grbcxx @ONLY )
joinWithNewLine( runenv_list BACKEND_RUNENV_SPACED )
joinWithNewLine( runner_list BACKEND_RUNNER_SPACED )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/grbrun.in ${CMAKE_CURRENT_BINARY_DIR}/grbrun @ONLY )
# install them to the install folder with execute permission
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/setenv
${CMAKE_CURRENT_BINARY_DIR}/grbcxx
${CMAKE_CURRENT_BINARY_DIR}/grbrun
DESTINATION "${BIN_INSTALL_DIR}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
### GENERATE CMAKE INFRASTRUCTURE INSIDE INSTALLATION DIRECTORY
include( CMakePackageConfigHelpers )
# write file with version information
write_basic_package_version_file(
ALPGraphBLASVersion.cmake
VERSION ${VERSION}
COMPATIBILITY AnyNewerVersion
)
# write custom file to check for dependencies and set custom variables
configure_file( ALPGraphBLASConfig.cmake.in ALPGraphBLASConfig.cmake @ONLY )
#install modules for dependencies lookup
install( FILES "${PROJECT_SOURCE_DIR}/cmake/FindNuma.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindLibM.cmake"
DESTINATION "${CMAKE_CONFIGS_INSTALL_DIR}/modules"
)
# install custom file and version file
install( FILES "${CMAKE_CURRENT_BINARY_DIR}/ALPGraphBLASVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ALPGraphBLASConfig.cmake"
DESTINATION "${CMAKE_CONFIGS_INSTALL_DIR}"
)