[CMake] Specify an alternate C++ compiler for some source files

Marc Tajchman marc.tajchman at cea.fr
Wed Mar 30 07:42:06 EDT 2011


Hi,

How to specify different compilers for different source files in 
CMakeLists.txt, e.g. if

test1.cxx must be compiled with g++
test2.cxx must be compiled with mpicxx (mpi compiler)

I tried

 > add_executable(test1.exe test1.cxx)
 > set_source_files_properties(test2.cxx PROPERTIES CMAKE_CXX_COMPILER 
${MPI_COMPILER})
 > add_executable(test2.exe test2.cxx)

but it didn't work (i.e. g++ is still used for test2.cxx -> test2.o).

Any help appreciated.

Best Regards,
Marc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4998 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110330/effca46c/attachment.bin>


More information about the CMake mailing list