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

2011-03-30 Thread Marc Tajchman

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




smime.p7s
Description: S/MIME Cryptographic Signature
___
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

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

2011-03-30 Thread Michael Wild
On 03/30/2011 01:42 PM, Marc Tajchman wrote:
 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


CMake can't do that. But if you need MPI, use

find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
add_executable(test1 test1.cxx)
add_executable(test2 test2.cxx)
target_link_libraries(test2 ${MPI_LIBRARIES})
set_target_properties(test2 PROPERTIES
  COMPILE_FLAGS ${MPI_COMPILE_FLAGS}
  LINK_FLAGS ${MPI_LINK_FLAGS})


HTH

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


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

2011-03-30 Thread Verweij, Arjen
Since our default compilers are not gcc (icc, pgcc, cc, xlc_r etc) we've 
introduced FLEXLM_C_COMPILER and friends to be able to compile this from a 
single source tree.

But perhaps it would be cleaner to off-load it with ExternalProject_Add().

Seriously, how often do you want to compile LAPACK, BLAS, MPI, FLEXlm 
yourself...

Regards,
Arjen

-Original Message-
From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf
Of Michael Wild
Sent: woensdag 30 maart 2011 14:11
To: cmake@cmake.org
Subject: Re: [CMake] Specify an alternate C++ compiler for some source
files

On 03/30/2011 01:42 PM, Marc Tajchman wrote:
 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


CMake can't do that. But if you need MPI, use

find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
add_executable(test1 test1.cxx)
add_executable(test2 test2.cxx)
target_link_libraries(test2 ${MPI_LIBRARIES})
set_target_properties(test2 PROPERTIES
  COMPILE_FLAGS ${MPI_COMPILE_FLAGS}
  LINK_FLAGS ${MPI_LINK_FLAGS})


HTH

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
___
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