-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeTestTOPSCompiler.cmake
More file actions
75 lines (68 loc) · 2.76 KB
/
Copy pathCMakeTestTOPSCompiler.cmake
File metadata and controls
75 lines (68 loc) · 2.76 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
#
# Copyright 2020-2022 Enflame. All Rights Reserved.
#
if(CMAKE_TOPS_COMPILER_FORCED)
# The compiler configuration was forced by the user.
# Assume the user has configured all compiler information.
set(CMAKE_TOPS_COMPILER_WORKS TRUE)
return()
endif()
include(CMakeTestCompilerCommon)
unset(CMAKE_TOPS_COMPILER_WORKS CACHE)
if(NOT CMAKE_TOPS_COMPILER_WORKS)
PrintTestCompilerStatus("TOPS")
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.tops
"#include \"tops.h\"\n"
"#include \"tops/tops_runtime.h\"\n"
"__global__ void foo() {}\n"
"int main(int argc, char **argv) {"
"foo<<<1, 1>>>();"
"return 0;}"
)
# Clear result from normal variable.
unset(CMAKE_TOPS_COMPILER_WORKS)
# Puts test result in cache variable.
try_compile(CMAKE_TOPS_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.tops
LINK_LIBRARIES -ltops -fno-sanitize=all
OUTPUT_VARIABLE __CMAKE_TOPS_COMPILER_OUTPUT)
# Move result from cache to normal variable.
set(CMAKE_TOPS_COMPILER_WORKS ${CMAKE_TOPS_COMPILER_WORKS})
unset(CMAKE_TOPS_COMPILER_WORKS CACHE)
if(NOT CMAKE_TOPS_COMPILER_WORKS)
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the TOPS compiler works failed with "
"the following output:\n${__CMAKE_TOPS_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_TOPS_COMPILER_OUTPUT}")
message(FATAL_ERROR "The TOPS compiler\n \"${CMAKE_TOPS_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif()
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the TOPS compiler works passed with "
"the following output:\n${__CMAKE_TOPS_COMPILER_OUTPUT}\n\n")
endif()
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeTmp_ABI)
file(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp_ABI/main.tops
"#include \"tops.h\"\n"
"#include \"tops/tops_runtime.h\"\n"
"__global__ void foo() {}\n"
"int main(int argc, char **argv) {"
"foo<<<1, 1>>>();"
"return 0;}"
)
set(CMAKE_TOPS_VERBOSE_FLAG "-v")
CMAKE_DETERMINE_COMPILER_ABI(TOPS ${CMAKE_BINARY_DIR}/CMakeTmp_ABI/main.tops)
# Re-configure to save learned information.
configure_file(
${CMAKE_CURRENT_LIST_DIR}/CMakeTOPSCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeTOPSCompiler.cmake
@ONLY
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeTOPSCompiler.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeTOPSInitialize.cmake)
unset(__CMAKE_TOPS_COMPILER_OUTPUT)