CMake cross-compilation best practices

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

CMake cross-compilation best practices

Romain CHANU
Hi,

If I need to compile a library on both Linux and Windows, the best CMake practice would be to write toolchain files for Linux and Windows (cf. http://www.cmake.org/Wiki/CMake_Cross_Compiling)

Is that correct?

Cheers,

Romain Chanu

_______________________________________________
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: CMake cross-compilation best practices

Johannes Stallkamp
Hello Romain,

Romain CHANU schrieb:
> If I need to compile a library on both Linux and Windows, the best
> CMake practice would be to write toolchain files for Linux and
> Windows (cf. http://www.cmake.org/Wiki/CMake_Cross_Compiling)
>
> Is that correct?
Do you really want to cross-compile (i.e. build your Linux library on
Windows or vice versa) or do you just want to be able to compile your
platform-independent library natively on Linux or Windows but with the
same CMakeLists.txt ?
In the latter case, just go for it. Basically, your Windows
CMakeLists.txt should work just fine on Linux and vice versa. You
might need to adjust some paths if you use some 3rd party libraries or
use some compiler specific additional options. But you can implement
that just fine within the same CMakeLists.txt using IF( MSVC ) ....
ENDIF() (or other compiler/system-variables, see
http://www.itk.org/Wiki/CMake_Useful_Variables )

HTH
Johannes

_______________________________________________
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: CMake cross-compilation best practices

Romain CHANU
Hi,

Thank you for your answer.

I want to compile on both Linux and Windows with the same CMakeLists.txt. I will have a look to the different variables.

Cheers,

Romain

2009/11/30 Johannes Stallkamp <[hidden email]>
Hello Romain,

Romain CHANU schrieb:
> If I need to compile a library on both Linux and Windows, the best
> CMake practice would be to write toolchain files for Linux and
> Windows (cf. http://www.cmake.org/Wiki/CMake_Cross_Compiling)
>
> Is that correct?
Do you really want to cross-compile (i.e. build your Linux library on
Windows or vice versa) or do you just want to be able to compile your
platform-independent library natively on Linux or Windows but with the
same CMakeLists.txt ?
In the latter case, just go for it. Basically, your Windows
CMakeLists.txt should work just fine on Linux and vice versa. You
might need to adjust some paths if you use some 3rd party libraries or
use some compiler specific additional options. But you can implement
that just fine within the same CMakeLists.txt using IF( MSVC ) ....
ENDIF() (or other compiler/system-variables, see
http://www.itk.org/Wiki/CMake_Useful_Variables )

HTH
Johannes

_______________________________________________
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: CMake cross-compilation best practices

Alexander Neundorf-3
On Monday 30 November 2009, Romain CHANU wrote:
> Hi,
>
> Thank you for your answer.
>
> I want to compile on both Linux and Windows with the same CMakeLists.txt. I
> will have a look to the different variables.

Ok, so this is not cross compiling, you don't need any toolchain files or
anything else which is related to cross compiling.
I suggest you start with something simple and then add features (build-wise)
to it until you have what you need for your actual project.

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