cmake and asm?
Alexander Neundorf
neundorf at kde.org
Wed Jan 24 22:54:58 CET 2007
On Wednesday 24 January 2007 22:44, Boudewijn Rempt wrote:
> On Sunday 21 January 2007 01:41, Alexander Neundorf wrote:
> > Hi,
> >
> > On Saturday 20 January 2007 21:38, Boudewijn Rempt wrote:
> > > On Saturday 20 January 2007 17:36, Alexander Neundorf wrote:
> > > > For now it should be possible to do something like the following:
> > > > create a custom command which processes the asm file:
> > > >
> > > > add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o
> > > > COMMAND as ...
> > > > ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S
> > >
> > > Eh... What do I put in place of the triple dots? I'm very much a newbie
> > > so cmake is a black box to me.
> >
> > The call to the assembler (as).
> > See the cmake manpage for the documentation for add_custom_command() and
> > autotools generated makefile for the exact call to as.
>
> Okay! I got it working:
>
> add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o
> COMMAND gcc -c -DHAVE_X86_MMX -DHAVE_X86_SSE
> -DHAVE_X86_SSE2 -DHAVE_X86_3DNOW ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S )
>
> I need to use gcc, not as, because it needs to go through the
> preprocessor first. (There are things like #ifdef HAVE_X86_MMX
> in the file).
>
> Now, of course, I need to somehow parametrize it. I've got a file called
> config-processor.h.cmake that contains the following:
>
> /********** processor stuff *************/
>
> /* Defined to 1 if the assembler supports MMX instructions. */
> #cmakedefine HAVE_X86_MMX
>
> /* Defined to 1 if the assembler supports SSE instructions. */
> #cmakedefine HAVE_X86_SSE
>
> /* Defined to 1 if the assembler supports SSE2 instructions. */
> #cmakedefine HAVE_X86_SSE2
>
> /* Defined to 1 if the assembler supports AltiVec instructions. */
> #cmakedefine HAVE_PPC_ALTIVEC
>
> And a call in my CMakeLists.txt file as follows:
>
> configure_file(config-processor.h.cmake
> ${CMAKE_CURRENT_BINARY_DIR}/config-processor.h )
>
> So, how do I make sure that only the right -D's are in the COMMAND section?
Can you simply include this header in the assembler file ?
If not, is this header then used at all ?
E.g. the line
#cmakedefine HAVE_X86_SSE2
means that cmake will read it and replace it depending on the value of the
cmake variable HAVE_X86_SSE2.
So you could do also something like this:
set(_myFlags)
if(HAVE_X86_SSE2)
set(_myFlags ${_myFlags} -DHAVE_X86_SSE2)
endif(HAVE_X86_SSE2)
and so also for the others.
And then use these flags in the custom command.
Bye
Alex
--
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org - http://www.kde.org
alex AT neundorf.net - http://www.neundorf.net
More information about the Kde-buildsystem
mailing list