@@ -36,8 +36,9 @@ for packages included via `CPM` to enable extra languages.
3636 the language is enabled globally.
3737
3838 In CMake 4.5 and later this is not needed as `enable_language` supports being called from
39- within functions and in subdirectories to enable languages globally. This function will act as
40- a no-op in these versions when the policy `CMP0220` is set to `NEW`.
39+ within functions and in subdirectories to enable languages globally. This function will just
40+ call `enable_language` in these versions when the policy `CMP0220` is set to `NEW` where the
41+ `<file_path>` is included.
4142
4243#]=======================================================================]
4344function (rapids_export_write_language type lang file_path )
@@ -51,15 +52,6 @@ function(rapids_export_write_language type lang file_path)
5152# since linking to a target with language standards
5253# means `using`
5354
54- # When CMP0220 is set to NEW, `enable_language` will make the language available globally
55- if(POLICY CMP0220)
56- cmake_policy(GET CMP0220 rapids_cmp0220_value)
57- if(rapids_cmp0220_value STREQUAL "NEW")
58- message(DEBUG "CMP0220 is set to NEW, skipping custom language hook propagation logic for @lang@.")
59- return()
60- endif()
61- endif()
62-
6355if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
6456 if(NOT DEFINED CMAKE_CURRENT_FUNCTION)
6557 #Can't be called inside a function
@@ -90,6 +82,14 @@ endif()
9082# Expose the language at the current scope
9183enable_language(@lang@)
9284
85+ # When CMP0220 is set to NEW, `enable_language` will make the language available globally
86+ if(POLICY CMP0220)
87+ cmake_policy(GET CMP0220 rapids_cmp0220_value)
88+ if(rapids_cmp0220_value STREQUAL "NEW")
89+ return()
90+ endif()
91+ endif()
92+
9393if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake/PropagateCMake@lang@Compiler.cmake")
9494 # 1.
9595 # Take everything that `enable_language` generated and transform all sets to PARENT_SCOPE ()
0 commit comments