Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shxyke
CMake
Commits
fada8cbf
Commit
fada8cbf
authored
5 years ago
by
Robert Maynard
Committed by
Brad King
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
CheckLanguage: Report CMAKE_CUDA_HOST_COMPILER if needed for compilation
Fixes: #19013
parent
22d58e07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/CheckLanguage.cmake
+23
-4
23 additions, 4 deletions
Modules/CheckLanguage.cmake
Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
+2
-1
2 additions, 1 deletion
Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
with
25 additions
and
5 deletions
Modules/CheckLanguage.cmake
+
23
−
4
View file @
fada8cbf
...
...
@@ -18,7 +18,9 @@ such as ``Fortran``. If :variable:`CMAKE_<LANG>_COMPILER` is already defined
the check does nothing. Otherwise it tries enabling the language in a
test project. The result is cached in :variable:`CMAKE_<LANG>_COMPILER`
as the compiler that was found, or ``NOTFOUND`` if the language cannot be
enabled.
enabled. For CUDA which can have an explicit host compiler, the cache
:variable:`CMAKE_CUDA_HOST_COMPILER` variable will be set if it was required
for compilation.
Example:
...
...
@@ -39,13 +41,23 @@ macro(check_language lang)
set
(
_desc
"Looking for a
${
lang
}
compiler"
)
message
(
STATUS
${
_desc
}
)
file
(
REMOVE_RECURSE
${
CMAKE_CURRENT_BINARY_DIR
}
/CMakeFiles/Check
${
lang
}
)
file
(
WRITE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CMakeFiles/Check
${
lang
}
/CMakeLists.txt"
set
(
extra_compiler_variables
)
if
(
lang STREQUAL CUDA
)
set
(
extra_compiler_variables
"set(CMAKE_CUDA_HOST_COMPILER
\\\"\$
{CMAKE_CUDA_HOST_COMPILER}
\\\"
)"
)
endif
()
set
(
content
"cmake_minimum_required(VERSION
${
CMAKE_VERSION
}
)
project(Check
${
lang
}
${
lang
}
)
file(WRITE
\"\$
{CMAKE_CURRENT_BINARY_DIR}/result.cmake
\"
\"
set(CMAKE_
${
lang
}
_COMPILER
\\\"\$
{CMAKE_
${
lang
}
_COMPILER}
\\\"
)
\\
n
\"
)
"
)
\"
${
extra_compiler_variables
}
\\
n
\"
)"
)
file
(
WRITE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CMakeFiles/Check
${
lang
}
/CMakeLists.txt"
"
${
content
}
"
)
if
(
CMAKE_GENERATOR_INSTANCE
)
set
(
_D_CMAKE_GENERATOR_INSTANCE
"-DCMAKE_GENERATOR_INSTANCE:INTERNAL=
${
CMAKE_GENERATOR_INSTANCE
}
"
)
else
()
...
...
@@ -75,5 +87,12 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
message
(
STATUS
"
${
_desc
}
-
${
CMAKE_
${
lang
}
_COMPILER
}
"
)
set
(
CMAKE_
${
lang
}
_COMPILER
"
${
CMAKE_
${
lang
}
_COMPILER
}
"
CACHE FILEPATH
"
${
lang
}
compiler"
)
mark_as_advanced
(
CMAKE_
${
lang
}
_COMPILER
)
if
(
CMAKE_
${
lang
}
_HOST_COMPILER
)
message
(
STATUS
"Looking for a
${
lang
}
host compiler -
${
CMAKE_
${
lang
}
_HOST_COMPILER
}
"
)
set
(
CMAKE_
${
lang
}
_HOST_COMPILER
"
${
CMAKE_
${
lang
}
_HOST_COMPILER
}
"
CACHE FILEPATH
"
${
lang
}
host compiler"
)
mark_as_advanced
(
CMAKE_
${
lang
}
_HOST_COMPILER
)
endif
()
endif
()
endmacro
()
This diff is collapsed.
Click to expand it.
Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
+
2
−
1
View file @
fada8cbf
...
...
@@ -7,7 +7,8 @@ set(expect_C 1)
set
(
expect_CXX 1
)
unset
(
expect_Fortran
)
set
(
expect_NoSuchLanguage 0
)
foreach
(
lang C CXX Fortran NoSuchLanguage
)
foreach
(
lang C CXX Fortran CUDA NoSuchLanguage
)
check_language
(
${
lang
}
)
if
(
NOT DEFINED CMAKE_
${
lang
}
_COMPILER
)
message
(
FATAL_ERROR
"check_language(
${
lang
}
) did not set result"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment