Why is CMake ignoring assembly files when building static library?

℡╲_俬逩灬. 提交于 2019-12-10 14:16:55

问题


I've set

set(CAN_USE_ASSEMBLER TRUE)

And it's not helping at all. I'm trying to create a static library with a command like:

add_library(${CMAKE_PROJECT_NAME} STATIC ../PropWare ../spi ../spi_as.S ../sd)

where the files without extensions are C++ or C files and the .S file is assembly. But when I run cmake and make, it compiles the C/C++ sources and just ignores the assembly file... no warnings, no errors... just skips right over it.

I'd love any ideas. Full source is available on github (do note: this link is to the cmake branch, all others should be ignored). The first line is in this file and the second line is in this file.

Thanks, David


回答1:


Finally found it. Instead of

set(CAN_USE_ASSEMBLER TRUE)

I should have used

enable_language(ASM)



回答2:


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. Then they got compiled in...



来源:https://stackoverflow.com/questions/23452089/why-is-cmake-ignoring-assembly-files-when-building-static-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!