I have two small files that I want to compile in CMake for debugging it with CLion and GDB
main.c
int my_strlen(char *);
int main()
{
printf("Test: %d
", my_strlen("Hello"));
}
and I have my ASM file that have a my_strlen file
[BITS 64]
global my_strlen
section .text
my_strlen:
push rbp
mov rbp, rsp
xor rcx, rcx
loop:
cmp BYTE [rdi + rcx], 0
jz end
inc rcx
jmp loop
end:
mov rax, rcx
mov rsp, rbp
leave
ret
I'm trying to compile with a CMakeList.txt I add set_source_files_properties but it still doesn't work
cmake_minimum_required(VERSION 3.9)
project(ASM)
set(CMAKE_CXX_STANDARD 11)
set_source_files_properties(src/strlen.asm PROPERTIES COMPILE_FLAGS "-x assembler-with-c")
add_executable(main
src/strlen.asm
tests/src/main.c)
Someone knows a good command to add ASM file in a C project and compile with a CMakeList.txt ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…