Skip to content

Commit 2778c78

Browse files
committed
Set compiler.cstd in host profile
The cstd setting was added to Conan in v2.4.0. Similar to cppstd, it is used to indicate the selected C language standard.
1 parent c22bbf0 commit 2778c78

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

conan_provider.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
set(CONAN_MINIMUM_VERSION 2.0.5)
23+
set(CONAN_MINIMUM_VERSION 2.4.0)
2424

2525
# Create a new policy scope and set the minimum required cmake version so the
2626
# features behind a policy setting like if(... IN_LIST ...) behaves as expected
@@ -128,6 +128,14 @@ function(detect_arch arch)
128128
endfunction()
129129

130130

131+
function(detect_c_standard c_standard)
132+
set(${c_standard} ${CMAKE_C_STANDARD} PARENT_SCOPE)
133+
if(CMAKE_C_EXTENSIONS)
134+
set(${c_standard} "gnu${CMAKE_C_STANDARD}" PARENT_SCOPE)
135+
endif()
136+
endfunction()
137+
138+
131139
function(detect_cxx_standard cxx_standard)
132140
set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE)
133141
if(CMAKE_CXX_EXTENSIONS)
@@ -363,6 +371,7 @@ function(detect_host_profile output_file)
363371
detect_os(os os_api_level os_sdk os_subsystem os_version)
364372
detect_arch(arch)
365373
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type)
374+
detect_c_standard(compiler_cstd)
366375
detect_cxx_standard(compiler_cppstd)
367376
detect_lib_cxx(compiler_libcxx)
368377
detect_build_type(build_type)
@@ -399,6 +408,9 @@ function(detect_host_profile output_file)
399408
if(compiler_runtime_type)
400409
string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n")
401410
endif()
411+
if(compiler_cstd)
412+
string(APPEND profile compiler.cstd=${compiler_cstd} "\n")
413+
endif()
402414
if(compiler_cppstd)
403415
string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n")
404416
endif()

0 commit comments

Comments
 (0)