CMake: use compile_features to set min C++ standard (#647)

This commit is contained in:
SpaceIm 2023-05-25 19:34:34 +02:00 committed by GitHub
parent 69557d4623
commit d93b687bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 24 deletions

View File

@ -14,10 +14,7 @@ function(fuzz source)
target_link_libraries(${name} PRIVATE component) target_link_libraries(${name} PRIVATE component)
target_compile_options(${name} PRIVATE -fsanitize=fuzzer,address) target_compile_options(${name} PRIVATE -fsanitize=fuzzer,address)
target_link_libraries(${name} PRIVATE -fsanitize=fuzzer,address) target_link_libraries(${name} PRIVATE -fsanitize=fuzzer,address)
set_target_properties(${name} PROPERTIES target_compile_features(${name} PRIVATE cxx_std_17)
CXX_STANDARD 20
CXX_EXTENSIONS OFF
)
endfunction(fuzz) endfunction(fuzz)
fuzz(terminal_input_parser_test_fuzzer) fuzz(terminal_input_parser_test_fuzzer)

View File

@ -43,19 +43,7 @@ function(ftxui_set_options library)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
) )
# Play nicely if we are being consumed by another project target_compile_features(${library} PUBLIC cxx_std_17)
# and use their CMAKE_CXX_STANDARD. Otherwise, fall back to 17
# C++17 is used. We require fold expression at least.
if (DEFINED CMAKE_CXX_STANDARD)
set(CXX_STANDARD ${CMAKE_CXX_STANDARD})
else()
set(CXX_STANDARD 17)
endif()
set_target_properties(${library} PROPERTIES
CXX_STANDARD ${CXX_STANDARD}
CXX_EXTENSIONS OFF
)
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies # Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
# to the library and the library users. # to the library and the library users.

View File

@ -57,10 +57,7 @@ target_link_libraries(ftxui-tests
target_include_directories(ftxui-tests target_include_directories(ftxui-tests
PRIVATE src PRIVATE src
) )
set_target_properties(ftxui-tests PROPERTIES target_compile_features(ftxui-tests PRIVATE cxx_std_20)
CXX_STANDARD 20
CXX_EXTENSIONS OFF
)
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK) if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
target_compile_definitions(ftxui-tests target_compile_definitions(ftxui-tests

View File

@ -8,9 +8,7 @@ function(example name)
target_link_libraries(ftxui_example_${name} PUBLIC ${DIRECTORY_LIB}) target_link_libraries(ftxui_example_${name} PUBLIC ${DIRECTORY_LIB})
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name}) set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
set_target_properties(ftxui_example_${name} PROPERTIES target_compile_features(ftxui_example_${name} PRIVATE cxx_std_17)
CXX_STANDARD 17
)
endfunction(example) endfunction(example)
add_subdirectory(component) add_subdirectory(component)