Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking a .s file with CMake

Tags:

gcc

cmake

icc

ros

I have a c function that I'd like to use but thats compiled with the Intel compiler instead of the gnu C compiler. I'm using cmake to build the program. (I'm actually using ROS and hence rosmake but the base is cmake so I think its more of a cmake issue than a ROS issue). Suppose the file built with icc is x.c and produces an x.s file. I want to use the function a() from x.c in my file y.cpp. In y.cpp I have:

#include "x.h" 
..... 
call a() 

which works if CMakeLists.txt has

rosbuild_add_executable(y y.cpp x.c)

rosbuild_add_executable is analogous to add_executable(...) 

but if I build x.c with icc and try to include the x.s file instead:

rosbuild_add_executable(y y.cpp x.s) 

It doesnt work. Is there some change I should make to the way I call a() in y.cpp? or is there some other way to link it.

like image 908
canatan Avatar asked Dec 27 '22 01:12

canatan


1 Answers

When using gcc, you can compile .S files with your C compiler (no explicit invocation of asm needed). CMake can be told to do so using

set_property(SOURCE <myfile>.S PROPERTY LANGUAGE C)

for each of your .S files.

like image 128
roffez Avatar answered Jan 04 '23 02:01

roffez