Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): convert set_languages() latest standard to cmake #5180

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

offscum
Copy link

@offscum offscum commented Jun 3, 2024

This fix convert languages last standard to cmake, for example:

set_languages('clatest', 'gnulatest', 'cxxlatest', 'gnuxxlatest')

This will generate the following code separately:

  • clatest
set_target_properties(<target> PROPERTIES C_EXTENSIONS OFF)
foreach(standard 23 17 11 99 90)
    include(CheckCCompilerFlag)
    if(MSVC)
        check_c_compiler_flag("/std:c${standard}" <target>_support_c_standard_${standard})
    else()
        check_c_compiler_flag("-std=c${standard}" <target>_support_c_standard_${standard})
    endif()
    if(<target>_support_c_standard_${standard})
        target_compile_features(<target> PRIVATE c_std_${standard})
        break()
    endif()
endforeach()
  • gnulatest
set_target_properties(<target> PROPERTIES C_EXTENSIONS ON)
foreach(standard 23 17 11 99 90)
    include(CheckCCompilerFlag)
    if(MSVC)
        check_c_compiler_flag("/std:gnu${standard}" <target>_support_gnu_standard_${standard})
    else()
        check_c_compiler_flag("-std=gnu${standard}" <target>_support_gnu_standard_${standard})
    endif()
    if(<target>_support_gnu_standard_${standard})
        target_compile_features(<target> PRIVATE c_std_${standard})
        break()
    endif()
endforeach()
  • cxxlatest
set_target_properties(<target> PROPERTIES CXX_EXTENSIONS OFF)
foreach(standard 26 23 20 17 14 11 98)
    include(CheckCXXCompilerFlag)
    if(MSVC)
        check_cxx_compiler_flag("/std:c++${standard}" <target>_support_c++_standard_${standard})
    else()
        check_cxx_compiler_flag("-std=c++${standard}" <target>_support_c++_standard_${standard})
    endif()
    if(<target>_support_c++_standard_${standard})
        target_compile_features(<target> PRIVATE cxx_std_${standard})
        break()
    endif()
endforeach()
  • gnuxxlatest
set_target_properties(<target> PROPERTIES CXX_EXTENSIONS ON)
foreach(standard 26 23 20 17 14 11 98)
    include(CheckCXXCompilerFlag)
    if(MSVC)
        check_cxx_compiler_flag("/std:gnu++${standard}" <target>_support_gnu++_standard_${standard})
    else()
        check_cxx_compiler_flag("-std=gnu++${standard}" <target>_support_gnu++_standard_${standard})
    endif()
    if(<target>_support_gnu++_standard_${standard})
        target_compile_features(<target> PRIVATE cxx_std_${standard})
        break()
    endif()
endforeach()

@waruqi waruqi added this to the v2.9.3 milestone Jun 3, 2024
@waruqi waruqi merged commit c65b5e9 into xmake-io:dev Jun 3, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants