<div dir="ltr"><div dir="ltr"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 3, 2018 at 10:29 AM Gregor Jasny <<a href="mailto:gjasny@googlemail.com">gjasny@googlemail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
<br>
On 10/3/18 6:08 PM, Tom Finegan via CMake wrote:<br>
> I'm trying to get rid of some local CMake scripting for building assembly<br>
> with nasm and yasm, but I'm running into a problem with the Xcode generator.<br>
> <br>
> For the make and ninja generators, everything is fine-- nasm and yasm are<br>
> both working as expected.<br>
> <br></blockquote><div><br></div><div>This works fine with Visual Studio as well.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> The same is not true for Xcode. When building a target that includes<br>
> assembly files Xcode outputs the warnings like the following during its<br>
> "Check dependencies" step:<br>
> <br>
> warning: no rule to process file <assembly file> of type sourcecode for<br>
> architecture x86_64<br>
<br>
If the Xcode included nasm and the default Xcode flags are good enough <br>
for you you might get away with:<br>
<br>
set_source_files_properties(${yasm_file} PROPERTIES<br>
XCODE_EXPLICIT_FILE_TYPE "sourcecode.nasm")<br>
<br></blockquote><div><br></div><div>This has no impact on Xcode's behavior at build time; I see the same warning each time Xcode encounters a .asm file. I can see that the property is actually set on the .asm files, so it is at least doing something. Just not quite enough. :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Otherwise I had to create a add_custom_command for every file and <br>
pointed to a shell script that based on all architectures found in ARCHS <br>
ran yasm and in the end called lipo to create the final fat .o file.<br></blockquote><div><br></div><div>Indeed. I use add_custom_command() and then add the objects into a dependent target. I was hoping to drop the script that was doing the work. Oh well. </div><div><br></div><div>Just in case, here's the util macro I'm using to do the work-- maybe someone can spot something silly I've missed:</div><div><br></div><div><div><font face="monospace, monospace">macro(add_asm_object_library target dependent_target sources)</font></div><div><font face="monospace, monospace"> if("${${sources}}" STREQUAL "")</font></div><div><font face="monospace, monospace"> message(FATAL_ERROR "--- add_asm_object_library: empty source list.")</font></div><div><font face="monospace, monospace"> endif()</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> add_library(${target} OBJECT ${${sources}})</font></div><div><font face="monospace, monospace"> target_sources(${dependent_target} PRIVATE $<TARGET_OBJECTS:${target}>)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> if("${CMAKE_ASM_NASM_COMPILER}" MATCHES "nasm")</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> # Include path handling in nasm is broken. If the trailing slash is omitted</font></div><div><font face="monospace, monospace"> # nasm cannot find includes. Explicitly add the necessary include paths with</font></div><div><font face="monospace, monospace"> # trailing slashes.</font></div><div><font face="monospace, monospace"> target_compile_options(${target} PRIVATE "-I${AOM_ROOT}/"</font></div><div><font face="monospace, monospace"> "-I${AOM_CONFIG_DIR}/")</font></div><div><font face="monospace, monospace"> endif()</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> if(XCODE)</font></div><div><font face="monospace, monospace"> set_source_files_properties(${${sources}} PROPERTIES</font></div><div><font face="monospace, monospace"> XCODE_EXPLICIT_FILE_TYPE "sourcecode.nasm")</font></div><div><font face="monospace, monospace"> endif()</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> list(APPEND AOM_LIB_TARGETS ${target})</font></div><div><font face="monospace, monospace">endmacro()</font></div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Hope that helps,<br>
-Gregor<br>
</blockquote></div></div></div></div>