mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 22:42:31 +08:00
🔧 Adjust the cmake build options
also add later use of libc++ later, for now it's not compiling with libc++.
This commit is contained in:
parent
0b76a9a968
commit
1f0cfb9b10
@ -77,10 +77,11 @@ CPMAddPackage(
|
||||
##
|
||||
## CONFIGURATION
|
||||
##
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program -fuse-linker-plugin")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program -fuse-linker-plugin")
|
||||
endif()
|
||||
|
||||
# Link this 'library' to set the c++ standard / compile-time options requested
|
||||
|
@ -29,17 +29,33 @@ set(SIMDJSON_DISABLE_DEPRECATED_API ON CACHE INTERNAL "" FORCE)
|
||||
# Generate compile_commands.json to make it easier to work with clang based tools
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fwhole-program -fuse-linker-plugin")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES ".*Clang")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto -fwhole-program -fuse-linker-plugin")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program -fuse-linker-plugin")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program -fuse-linker-plugin")
|
||||
endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")# -static")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
#add_compile_options(-nostdlib++ -stdlib=libc++ -nodefaultlibs -fexperimental-library)
|
||||
#add_link_options(-stdlib=libc++)
|
||||
|
||||
add_compile_options(-fstrict-vtable-pointers)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
|
||||
# Set new experimental pass manager, it's a performance, build time and binary size win.
|
||||
# Can be removed after https://reviews.llvm.org/D66490 merged and released to at least two versions of clang.
|
||||
add_compile_options(-fexperimental-new-pass-manager)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_IPO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)" OFF)
|
||||
|
||||
if(ENABLE_IPO)
|
||||
@ -66,6 +82,8 @@ endif()
|
||||
# Enables STL container checker if not building a release.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-D_GLIBCXX_ASSERTIONS)
|
||||
add_definitions(-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1)
|
||||
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
|
||||
endif()
|
||||
|
||||
# Enables dev environment.
|
||||
|
14
meson.build
14
meson.build
@ -16,17 +16,22 @@ if cc.get_id() == 'clang'
|
||||
specific_cc_flags = [
|
||||
'-nostdlib++',
|
||||
#'-stdlib=libc++',
|
||||
'-nodefaultlibs',
|
||||
]
|
||||
specific_link_flags = [
|
||||
'-fuse-ld=lld',
|
||||
#'-nodefaultlibs',
|
||||
#'-fexperimental-library',
|
||||
'-fstrict-vtable-pointers',
|
||||
'-fexperimental-new-pass-manager',
|
||||
]
|
||||
#specific_link_flags = [
|
||||
# '-stdlib=libc++',
|
||||
#]
|
||||
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
|
||||
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
|
||||
endif
|
||||
|
||||
if is_debug_build
|
||||
add_global_arguments('-D_GLIBCXX_ASSERTIONS', language : 'cpp')
|
||||
add_global_arguments('-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1', language : 'cpp')
|
||||
add_global_arguments('-D_LIBCPP_ENABLE_ASSERTIONS=1', language : 'cpp')
|
||||
endif
|
||||
|
||||
if not is_dev_environment
|
||||
@ -140,6 +145,7 @@ if not is_debug_build
|
||||
else
|
||||
possible_cc_flags += [
|
||||
'-flto=thin',
|
||||
'-fwhole-program-vtables',
|
||||
]
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user