target_link_options does not append linker flags
Shouldn't the target_link_options command append the linker flags? I don't see any difference between:
target_link_options(${app_name} PRIVATE "-lquadmath")
and
target_link_options(${app_name} BEFORE PRIVATE "-lquadmath")
Using this command will result in a linker error for the attached project:
cmd.exe /C "cd . && C:\msys64\mingw64\bin\gcc.exe -g -lquadmath CMakeFiles/testQuadMath.dir/main.c.obj -o testQuadMath.exe -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
This is because the "-lquadmath" option is listed before the object file.
Using
target_link_libraries(${app_name} PRIVATE quadmath)
works.
Is there any reason to use target_link_options
over target_link_libraries
anyway, because the linker option could also be passed using target_link_libraries
?