1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

Meta: Add Clang support to the CMake build scripts

This commit is contained in:
Daniel Bertalan 2021-07-13 16:43:45 +02:00 committed by Andreas Kling
parent 15e217ea68
commit 13e3df41de
7 changed files with 128 additions and 22 deletions

View file

@ -18,14 +18,18 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
add_executable(${PREKERNEL_TARGET} ${SOURCES})
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic)
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib)
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib LINKER:--no-pie)
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
target_link_libraries(${PREKERNEL_TARGET} gcc supc++)
if (USE_CLANG_TOOLCHAIN)
target_link_libraries(${PREKERNEL_TARGET} clang_rt.builtins-${SERENITY_CLANG_ARCH} c++abi)
else()
target_link_libraries(${PREKERNEL_TARGET} gcc supc++)
endif()
add_custom_command(
TARGET ${PREKERNEL_TARGET} POST_BUILD
COMMAND ${TOOLCHAIN_PREFIX}objcopy -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
)