add_custom_command using CMAKE_CXX_FLAGS

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

add_custom_command using CMAKE_CXX_FLAGS

John Smith-6
Hi,

I have browsed the list for a while trying to figure this but with  
little success and my own testing is yielding confusing results.

I am using the following test case in an attempt to add a custom  
command to build an assembly file. The assembly file should be  
compiled with the C++ compiler driver (which in turn should invoke the  
assembler after pre-processing), and I am building up a  
CMAKE_CXX_FLAGS variable from separate pieces:

# -*- CMake -*-
cmake_minimum_required(VERSION 2.6)

project(test)
set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_CXX_FLAGS -m32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

message (STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")

file (GLOB ASM_SRCS bar.S)
foreach (src ${ASM_SRCS})
    get_filename_component (FILE_BASE ${src} NAME_WE)
    set (SRC ${src})
    set (OBJ ${CMAKE_CURRENT_BINARY_DIR}/${FILE_BASE}.o)
    add_custom_command (OUTPUT ${OBJ}
        MAIN_DEPENDENCY ${SRC}
        COMMAND ${CMAKE_CXX_COMPILER}
        ARGS ${CMAKE_CXX_FLAGS} -o ${OBJ} -c ${SRC}
        MAIN_DEPENDENCY ${src})
        set (ASM_OBJS ${ASM_OBJS} ${OBJ})
endforeach(src)

add_library(test SHARED foo.cpp bar.S)

The above gives this:

[...]
[ 50%] Generating bar.o
/usr/bin/c++ -m32\ -pthread -o /tmp/build-test/bar.o -c /tmp/test/bar.S
cc1: error: unrecognized command line option "-m32 -pthread"
[...]

I see that the space separating the two options is escaped, I assume  
as a result of defining the variable as a string. However, in this:

$ nice make foo.o
[...]
[100%] Building CXX object CMakeFiles/test.dir/foo.cpp.o
/usr/bin/c++   -Dtest_EXPORTS -m32 -pthread -fPIC   -o CMakeFiles/
test.dir/foo.cpp.o -c /tmp/test/foo.cpp

CMAKE_CXX_FLAGS appears fine in this rule. I assume it is processed  
differently when this rule is generated.

My question is: how should I go about hard-coding my rule? I need to  
pass the language-specific flags as well as the include directories  
(same with which I compile all C++ sources in the project).

Thanks for the help.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Tyler Roscoe
On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
> I am using the following test case in an attempt to add a custom  
> command to build an assembly file. The assembly file should be  
> compiled with the C++ compiler driver (which in turn should invoke the  
> assembler after pre-processing), and I am building up a  
> CMAKE_CXX_FLAGS variable from separate pieces:

I think you can just hand your .S files to add_library(). Did you try
searching the ML archives or google for how to handle assembler files
with CMake?

> set(CMAKE_CXX_FLAGS -m32)

When you do this, you clobber the pre-existing value of CMAKE_CXX_FLAGS,
which has some defaults that are probably useful for your platform. Are
you sure this is what you want?

> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
>
> message (STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
>
> file (GLOB ASM_SRCS bar.S)

As a general rule, you probably don't want to use file (GLOB ...). Here
you can just say set(ASM_SRCS bar.S).

> foreach (src ${ASM_SRCS})
>    get_filename_component (FILE_BASE ${src} NAME_WE)
>    set (SRC ${src})
>    set (OBJ ${CMAKE_CURRENT_BINARY_DIR}/${FILE_BASE}.o)
>    add_custom_command (OUTPUT ${OBJ}
>        MAIN_DEPENDENCY ${SRC}
>        COMMAND ${CMAKE_CXX_COMPILER}
>        ARGS ${CMAKE_CXX_FLAGS} -o ${OBJ} -c ${SRC}
>        MAIN_DEPENDENCY ${src})
>        set (ASM_OBJS ${ASM_OBJS} ${OBJ})
> endforeach(src)
>
> add_library(test SHARED foo.cpp bar.S)

Yeah I think you're overthinking this. Look for some CMake examples that
use assembler and go from there.

tyler
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Óscar Fuentes
Tyler Roscoe <[hidden email]> writes:

> On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
>> I am using the following test case in an attempt to add a custom  
>> command to build an assembly file. The assembly file should be  
>> compiled with the C++ compiler driver (which in turn should invoke the  
>> assembler after pre-processing), and I am building up a  
>> CMAKE_CXX_FLAGS variable from separate pieces:
>
> I think you can just hand your .S files to add_library(). Did you try
> searching the ML archives or google for how to handle assembler files
> with CMake?

Assembler support is broken, at least for masm/64 as some user reported
here some days ago.

  enable_language(ASM_MASM)
  set(sources ${sources} X86CompilationCallback_Win64.asm)

My users say that with the previous code the build pretends to compile
the assembler file as if it were a C file.

If the other assemblers are broken too, I guess this is the reason
people are trying workarounds.

[snip]

--
Óscar

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

John Smith-6
In reply to this post by Tyler Roscoe
On Aug 24, 2009, at 12:48 PM, Tyler Roscoe wrote:

> On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
>> I am using the following test case in an attempt to add a custom
>> command to build an assembly file. The assembly file should be
>> compiled with the C++ compiler driver (which in turn should invoke  
>> the
>> assembler after pre-processing), and I am building up a
>> CMAKE_CXX_FLAGS variable from separate pieces:
>
> I think you can just hand your .S files to add_library(). Did you try
> searching the ML archives or google for how to handle assembler files
> with CMake?

I have tried doing that. However, the net end result is that I get a  
rule that invokes the assembler on the assembly source file. My top-
level assembly source file is a shell containing a bunch of platform-
specific conditionals, which in turn guard include directives for  
platform-specific assembly source files. Thus, I want to have the C++  
compiler driver compile the top-level file; the compiler driver would  
first preprocess the include directives and then invoke the assembler  
on the resulting translation unit.

An example of such a technique is here: http://svn.apache.org/viewvc/stdcxx/trunk/src/atomic.s?revision=704153


>
>> set(CMAKE_CXX_FLAGS -m32)
>
> When you do this, you clobber the pre-existing value of  
> CMAKE_CXX_FLAGS,
> which has some defaults that are probably useful for your platform.  
> Are
> you sure this is what you want?

Poorly chosen example, my bad. The point was to show how a variable is  
constructed in my CMakeLists.txt and how it ends up being used.


>> [...]
>> add_library(test SHARED foo.cpp bar.S)
>
> Yeah I think you're overthinking this. Look for some CMake examples  
> that
> use assembler and go from there.
>


Most surely I am over-thinking it. After more local testing I think I  
understand how variables are processed in the generation of commands.  
I started from the command include_directories which actually builds a  
*list* of tokens, each an include directory to be used in (a) makefile  
rule. I noticed that using such a list as ARGS to ADD_CUSTOM_COMMAND  
results in the splitting of the list in separate tokens, i.e.:

set(FOO a b c)
ADD_CUSTOM_COMMAND(...
   ARGS ${FOO}
   ...)

ends up in a rule like:

<CMD> a b c ...

However, strings set up as:

set (FOO "a b c")

end up in the rule as:

<CMD> a\ b\ c ...

Therefore, I conclude that ARGS require lists, not strings of  
concatenated, space-separated options. Am I right in this?

Thanks for the help.

-J
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Michael Wild

On 24. Aug, 2009, at 19:38, John Smith wrote:

> On Aug 24, 2009, at 12:48 PM, Tyler Roscoe wrote:
>> On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
>>> I am using the following test case in an attempt to add a custom
>>> command to build an assembly file. The assembly file should be
>>> compiled with the C++ compiler driver (which in turn should invoke  
>>> the
>>> assembler after pre-processing), and I am building up a
>>> CMAKE_CXX_FLAGS variable from separate pieces:
>>
>> I think you can just hand your .S files to add_library(). Did you try
>> searching the ML archives or google for how to handle assembler files
>> with CMake?
>
> I have tried doing that. However, the net end result is that I get a  
> rule that invokes the assembler on the assembly source file. My top-
> level assembly source file is a shell containing a bunch of platform-
> specific conditionals, which in turn guard include directives for  
> platform-specific assembly source files. Thus, I want to have the C+
> + compiler driver compile the top-level file; the compiler driver  
> would first preprocess the include directives and then invoke the  
> assembler on the resulting translation unit.
>

Why don't you do this:

set(ASM_SRCS bar.S)
add_library(test SHARED foo.cpp ${ASM_SRCS})
set_source_files_properties(${ASM_SRCS} PROPERTIES
   LANGUAGE C
   )

This will get CMake to treat the ASM files as C files and just pass  
them to the C-compiler, which in turn will preprocess them. I know  
this works with gcc, I'm not sure whether this will work with anything  
else.

Michael

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Marcel Loose
In reply to this post by John Smith-6
Hi John,

I took a different approach to the problem you're describing.
Following the instructions on the Wiki
(http://www.cmake.org/Wiki/CMake/Assembler), I've written the three
required *ASM*.cmake files.
In the CMakeASM-<foo>Information.cmake file I've redefined the rule to
build .S files.

set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS S)
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM
${ASM_DIALECT}_COMPILER> <DEFINES> <FLAGS> -c -o <OBJECT> <SOURCE>")
set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE "<CMAKE_ASM
${ASM_DIALECT}_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET>
<LINK_LIBRARIES>")

The trick is in the second line; there I've added <DEFINES> so that any
relevant preprocessor variables will actually be passed when invoking
the compiler.

Furthermore, you need to make sure that the variable
CMAKE_ASM-<foo>_COMPILER points to your C or C++ compiler. This variable
must be set before you use the enable_language(<foo>) command.

Hope this helps.

Best regards,
Marcel Loose.


On Mon, 2009-08-24 at 13:38 -0400, John Smith wrote:

> On Aug 24, 2009, at 12:48 PM, Tyler Roscoe wrote:
> > On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
> >> I am using the following test case in an attempt to add a custom
> >> command to build an assembly file. The assembly file should be
> >> compiled with the C++ compiler driver (which in turn should invoke  
> >> the
> >> assembler after pre-processing), and I am building up a
> >> CMAKE_CXX_FLAGS variable from separate pieces:
> >
> > I think you can just hand your .S files to add_library(). Did you try
> > searching the ML archives or google for how to handle assembler files
> > with CMake?
>
> I have tried doing that. However, the net end result is that I get a  
> rule that invokes the assembler on the assembly source file. My top-
> level assembly source file is a shell containing a bunch of platform-
> specific conditionals, which in turn guard include directives for  
> platform-specific assembly source files. Thus, I want to have the C++  
> compiler driver compile the top-level file; the compiler driver would  
> first preprocess the include directives and then invoke the assembler  
> on the resulting translation unit.
>
> An example of such a technique is here: http://svn.apache.org/viewvc/stdcxx/trunk/src/atomic.s?revision=704153
>
>
> >
> >> set(CMAKE_CXX_FLAGS -m32)
> >
> > When you do this, you clobber the pre-existing value of  
> > CMAKE_CXX_FLAGS,
> > which has some defaults that are probably useful for your platform.  
> > Are
> > you sure this is what you want?
>
> Poorly chosen example, my bad. The point was to show how a variable is  
> constructed in my CMakeLists.txt and how it ends up being used.
>
>
> >> [...]
> >> add_library(test SHARED foo.cpp bar.S)
> >
> > Yeah I think you're overthinking this. Look for some CMake examples  
> > that
> > use assembler and go from there.
> >
>
>
> Most surely I am over-thinking it. After more local testing I think I  
> understand how variables are processed in the generation of commands.  
> I started from the command include_directories which actually builds a  
> *list* of tokens, each an include directory to be used in (a) makefile  
> rule. I noticed that using such a list as ARGS to ADD_CUSTOM_COMMAND  
> results in the splitting of the list in separate tokens, i.e.:
>
> set(FOO a b c)
> ADD_CUSTOM_COMMAND(...
>    ARGS ${FOO}
>    ...)
>
> ends up in a rule like:
>
> <CMD> a b c ...
>
> However, strings set up as:
>
> set (FOO "a b c")
>
> end up in the rule as:
>
> <CMD> a\ b\ c ...
>
> Therefore, I conclude that ARGS require lists, not strings of  
> concatenated, space-separated options. Am I right in this?
>
> Thanks for the help.
>
> -J
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Tyler Roscoe
In reply to this post by John Smith-6
Michael and Marcel have already posted helpful follow-ups to the
original question about compiling assembler files.

On Mon, Aug 24, 2009 at 01:38:13PM -0400, John Smith wrote:

> Most surely I am over-thinking it. After more local testing I think I  
> understand how variables are processed in the generation of commands.  
> I started from the command include_directories which actually builds a  
> *list* of tokens, each an include directory to be used in (a) makefile  
> rule. I noticed that using such a list as ARGS to ADD_CUSTOM_COMMAND  
> results in the splitting of the list in separate tokens, i.e.:
>
> set(FOO a b c)
> ADD_CUSTOM_COMMAND(...
>   ARGS ${FOO}
>   ...)
>
> ends up in a rule like:
>
> <CMD> a b c ...
>
> However, strings set up as:
>
> set (FOO "a b c")
>
> end up in the rule as:
>
> <CMD> a\ b\ c ...
>
> Therefore, I conclude that ARGS require lists, not strings of  
> concatenated, space-separated options. Am I right in this?

You've got the general idea but this may help with specifics:

http://www.cmake.org/Wiki/CMake/Language_Syntax

Also, take a look at the VERBATIM flag for add_custom_command().

tyler
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

John Smith-6

On Aug 25, 2009, at 11:26 AM, Tyler Roscoe wrote:

> Michael and Marcel have already posted helpful follow-ups to the
> original question about compiling assembler files.


The replies have been very helpful indeed, thanks!

-J
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Alexander Neundorf-3
In reply to this post by John Smith-6
On Monday 24 August 2009, John Smith wrote:

> On Aug 24, 2009, at 12:48 PM, Tyler Roscoe wrote:
> > On Sun, Aug 23, 2009 at 09:03:22PM -0400, John Smith wrote:
> >> I am using the following test case in an attempt to add a custom
> >> command to build an assembly file. The assembly file should be
> >> compiled with the C++ compiler driver (which in turn should invoke
> >> the
> >> assembler after pre-processing), and I am building up a
> >> CMAKE_CXX_FLAGS variable from separate pieces:
> >
> > I think you can just hand your .S files to add_library(). Did you try
> > searching the ML archives or google for how to handle assembler files
> > with CMake?
>
> I have tried doing that. However, the net end result is that I get a
> rule that invokes the assembler on the assembly source file. My top-
> level assembly source file is a shell containing a bunch of platform-
> specific conditionals, which in turn guard include directives for
> platform-specific assembly source files.
So you have also hit that bug ?
http://public.kitware.com/Bug/view.php?id=8392

Can you please try the attached patch ?
It introduces a language "ASM-GCC" and removes the extension ".S" from the
normal assembler support.
Can you please give it a try ?

Is it only gcc which supports processing assembler files or do other compilers
also support this ?

Alex

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

asmgcc.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

John Smith-6
Alexander Neundorf wrote:
> On Monday 24 August 2009, John Smith wrote:
>> [...] I have tried doing that. [...]
>
> So you have also hit that bug ?
> http://public.kitware.com/Bug/view.php?id=8392
>

Interesting, did not know of it.

IMHO, I believe that the C compiler (or C compiler driver) should be
invoked on the assembly sources, with the exact definitions and C
compiler flags that are set at that point in the processing of the
source tree. The reason for that is definitions may be involved in
pre-processing the source file as conditionals guarding include
directives, etc. and flags may alter the code generation, e.g., -m32 may
be used to generate x86 code.

If CMake has the concept of a settable "default" language/compiler per
project then perhaps that default compiler -- be it C or C++ -- might be
the perfect choice for building the project's assembly files. The C
compiler would use the compile definitions and C flags, whereas the C++
compiler would use the same definitions but CXX flags. I.e., not
hard-coding the C compiler in might be a better choice. Of course, I
might be wrong, and I invite others to state their opinions on this.

gcc -- per the man page -- does not preprocess .s files but it does so
for .S files, when invoked for compilation. With this behavior, I
believe gcc is unique.

Other compilers which I believe know automagically what to do with .s
assembly sources are:

1. HP aCC at http://tinyurl.com/nhr97k :

Assembly language source files (.s files)
Files with names ending in .s are assumed to be assembly source files.
The compiler invokes the assembler through cc to produce .o files from
these.

2. IBM VisualAge for C++ at http://tinyurl.com/l2lqt4 :

Assembler files
Assembler files must have a .s suffix, for example, file_name.s, unless
you compile with the -qsourcetype=assembler option. Assembler files are
assembled to create an object file.

3. Sun's Sun Studio at http://tinyurl.com/ma6etm :

The syntax of the cc command is:
% cc [options] filenames [libraries]...
[...]
Use the C compiler to compile and link any combination of the following:
[...] o Assembler source files, with .s suffixes

4. Intel C++ at http://tinyurl.com/6lxedl :

The Intel® C++ Compiler recognizes input files with the extensions
listed in the following table:

[...]
file.s   |   Assembly file    |     Passed to assembler

> Can you please try the attached patch ?

Sure thing, I will.

Thanks!
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

Alexander Neundorf-3
On Saturday 05 September 2009, John Smith wrote:

> Alexander Neundorf wrote:
> > On Monday 24 August 2009, John Smith wrote:
> >> [...] I have tried doing that. [...]
> >
> > So you have also hit that bug ?
> > http://public.kitware.com/Bug/view.php?id=8392
>
> Interesting, did not know of it.
>
> IMHO, I believe that the C compiler (or C compiler driver) should be
> invoked on the assembly sources, with the exact definitions and C
> compiler flags that are set at that point in the processing of the
> source tree. The reason for that is definitions may be involved in
> pre-processing the source file as conditionals guarding include
> directives, etc. and flags may alter the code generation, e.g., -m32 may
> be used to generate x86 code.
>
> If CMake has the concept of a settable "default" language/compiler per
> project then perhaps that default compiler -- be it C or C++ -- might be
> the perfect choice for building the project's assembly files. The C
> compiler would use the compile definitions and C flags, whereas the C++
> compiler would use the same definitions but CXX flags. I.e., not
> hard-coding the C compiler in might be a better choice. Of course, I
> might be wrong, and I invite others to state their opinions on this.
>
> gcc -- per the man page -- does not preprocess .s files but it does so
> for .S files, when invoked for compilation. With this behavior, I
> believe gcc is unique.
>
> Other compilers which I believe know automagically what to do with .s
> assembly sources are:

Thanks a lot, I added that to the bug report.

Alex
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: add_custom_command using CMAKE_CXX_FLAGS

John Smith-6
In reply to this post by Alexander Neundorf-3
On Sep 5, 2009, at 3:31 PM, Alexander Neundorf wrote:
> [...]
> Can you please try the attached patch ?

I have tried it and I have got the desired result, i.e. the compiler  
driver is invoked for compilation on the assembly sources. The  
CMakeLists.txt file contains:

ENABLE_LANGUAGE(ASM-GCC)
set (ASM_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/asm.S)
add_library (mylib ${CXX_LIBRARY_TYPE} somesrc.cpp ${ASM_SRCS})

which results in:

[  2%] Building ASM-GCC object .../asm.S.o
cd projdir && /usr/bin/gcc  -Isomeinclude -c asm.S -o bindir/asm.S.o

As I said before, and after more thinking, I believe that in my case a  
better solution is to have the assembly source compiled like the other  
sources in the project. This might not be the ideal solution for other  
projects.

So, a better solution for me is to have:

set_source_files_properties (${ASM_SRCS} PROPERTIES LANGUAGE CXX)

Thanks!

-J

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake