linux cmake fix for arm64 compiling
continuous-integration/drone/pr Build is pending Details
continuous-integration/drone/push Build is pending Details

This commit is contained in:
Dan Ballard 2024-04-21 19:34:12 -07:00
parent 7741b255da
commit 899da5fea1
1 changed files with 8 additions and 1 deletions

View File

@ -40,12 +40,19 @@ endif()
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
# Not ideal, there doesn't appear to be a way to get target arch so getting host arch. won't work for cross compiling
execute_process(COMMAND uname -m OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ARCH)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
# -Os -fno-ident (optimize for size, and strip idents, don't generate a build-id, fix hash style)
target_compile_options(${TARGET} PRIVATE -Wall -Werror -Os -fno-ident)
target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none,--script=${PROJECT_BUILD_DIR}/../elf_x86_64.x)
# on x86_64 use an included elf_x86_64.x for reproducibility. for other arches don't (and then don't be reproducible)
if(${ARCH} STREQUAL "x86_64")
target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none,--script=${PROJECT_BUILD_DIR}/../elf_x86_64.x)
else()
target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none)
endif()
endfunction()
# Flutter library and tool build rules.