[CMake] One source file, different arch

Glenn Coombs glenn.coombs at gmail.com
Fri Jul 1 07:34:24 EDT 2011


Something like this should do the trick:

add_exectuable(myExe32 A.c B.c C.c)
add_exectuable(myExe64 A.c B.c D.c)

set_target_properties(myExe32 PROPERTIES COMPILE_FLAGS -m32)
set_target_properties(myExe32 PROPERTIES LINK_FLAGS -m32)

That assumes that the default setup would build 64-bit executables and you
just override that default with the necessary gcc switches to force a 32-bit
compile and link for the one target.  You would need something more
complicated to get it to work with both Visual Studio and linux/gcc but the
principle is the same.

--
Glenn


On 1 July 2011 02:14, 邓尧 <torshie at gmail.com> wrote:

> Hi,
>
> I'm new to CMake. My project is a little different from the projects found
> in the tutorials. I have to compile some of the source files into two
> different archs(32-bit & 64-bit). It's like the following:
>   Given 4 source files: A.c, B.c, C.c, D.c, I need to compile a 32-bit
> executable with source file A.c, B.c and C.c, I also need to compile a
> 64-bit executable with source file A.c B.c and D.c.
> How to write the CMake script in this situation?
>
> Thanks
>
> -Yao
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110701/63a640b0/attachment.htm>


More information about the CMake mailing list