[CMake] patch for supporting multiple toolchain in single source tree

Yinyin yinyin.pt at livemail.tw
Mon May 5 11:00:04 EDT 2008




Hi there,



The attached file (multi-toolchain.patch.bz2) is a patch I made for supporting multiple tool-chain in single source tree.

The idea is add an extra property "TARGET_ARCH" to target 
and make the variable expansion routine lookup toolchain according to TARGET_ARCH.

For example, if TARGET_ARCH is set as CPUX (ie: SET_TARGET_PROPERTIES(my_target  PROPERTIES  TARGET_ARCH  CPUX) ), 
the modified expansion routine will check CMAKE_C_COMPILER_CPUX first when cmake attempts to generate statements which reference to C compiler.

For heterogeneous computing  environment such as grid / clustering or Cell (the multiple core processor used in PS3), such support would be useful.


Besides the patch, two module files for supporting Cell SDK 3 are also attached.
Those modules would find toolchain binaries and adjust compiling rules for you.




Here is an example of CMakeList.txt for a HelloWorld in Cell:

First of all, the layout of source tree:
{{{
ProjectRoot $ ls -RF .
CMakeLists.txt          
spe/
ppe/                    
toolchain.cmake

./ppe:
CMakeLists.txt  
main_ppe.c

./spe:
CMakeLists.txt  
main_spe.c

}}}

====
The CMakeList-s.

$ProjectRoot/CMakeList.txt
{{{

project (HELLOCELL)

add_subdirectory(spe)
add_subdirectory(ppe)

}}}

----

$ProjectRoot/ppe/CMakeList.txt
{{{
add_executable(ppe_helo main_ppe.c)
target_link_libraries(ppe_helo spe2)
target_link_libraries(ppe_helo pthread)
set_target_properties (ppe_helo PROPERTIES TARGET_ARCH  PPU)

target_link_libraries(ppe_helo "${HELLOCELL_BINARY_DIR}/spe/Hello_CBE_SPE.a")

}}}

----

$ProjectRoot/spe/CMakeList.txt

{{{

add_executable (Hello_CBE_SPE main_spe.c)
set_target_properties (Hello_CBE_SPE PROPERTIES TARGET_ARCH SPU256K)
set_target_properties (Hello_CBE_SPE PROPERTIES ENABLE_EXPORTS 1)

make_embedspu(Hello_CBE_SPE)

}}}

====

The C files can be obtain from the example code directory of SDK.


I did not includes these codes.

Since there is a "All Rights Reserved" section on those sources ,
I am not sure about its appropriate or not to redistribute those hello world code here.

However, you can always download your own SDK copy for free if you really like to see those codes.



I am new to cmake :)

Please let me know if any problems or suggestions.

Thanks !!


Best regards,
  Yinyin



----
EOF
.

--
Taiwan, a beautiful, warm and independent island country.

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080505/b6b97859/attachment.htm>


More information about the CMake mailing list