mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
CMake: Set C++20 mode in canonical cmake
Problem: - Setting `CMAKE_CXX_FLAGS` directly to effect the version of the C++ standard being used is no longer the recommended best practice. Solution: - Set C++20 mode in the compiler by setting `CMAKE_CXX_STANDARD`. - Force the build system generator not to fallback to the latest standard supported by the compiler by enabling `CMAKE_CXX_STANDARD_REQUIRED`. This shouldn't ever be a problem though since the toolchain is tightly controlled. - Disable GNU compiler extensions by disabling `CMAKE_CXX_EXTENSIONS` to preserve the previous flags.
This commit is contained in:
parent
0316f0627e
commit
ded0b5a93c
Notes:
sideshowbarker
2024-07-19 00:41:17 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/ded0b5a93c9 Pull-request: https://github.com/SerenityOS/serenity/pull/4485
1 changed files with 8 additions and 4 deletions
|
@ -42,7 +42,11 @@ add_custom_target(check-style
|
|||
USES_TERMINAL
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wall -Wextra -Werror -Wmissing-declarations -std=c++2a -fdiagnostics-color=always -ftls-model=initial-exec")
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -ftls-model=initial-exec")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconcepts")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
|
@ -170,7 +174,7 @@ function(serenity_app target_name)
|
|||
serenity_bin("${target_name}")
|
||||
set(small_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||
set(medium_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||
|
||||
|
||||
if (EXISTS "${small_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
||||
endif()
|
||||
|
@ -214,7 +218,7 @@ function(embed_resource target section file)
|
|||
get_filename_component(input_file "${file}" ABSOLUTE)
|
||||
add_custom_command(
|
||||
OUTPUT "${asm_file}"
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}"
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}"
|
||||
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||
COMMENT "Generating ${asm_file}"
|
||||
)
|
||||
|
@ -266,7 +270,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=."
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -DSANITIZE_PTRS")
|
||||
set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostartfiles -pie -fpic")
|
||||
|
||||
|
||||
add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
|
||||
|
||||
include_directories(Libraries/LibC)
|
||||
|
|
Loading…
Reference in a new issue