Tips on how to deploy C++ code to work every where

前端 未结 4 913
不思量自难忘°
不思量自难忘° 2021-02-01 19:35

I\'m not talking about making portable code. This is more a question of distribution. I have a medium-sized project. It has several dependencies on common libraries (eg opens

4条回答
  •  无人及你
    2021-02-01 20:30

    I would recommend CMake. Advantages:

    • It is very easy to use for building simple and complex projects with static libraries, dynamic libraries, executables and their dependencies.
    • It is platform independent and generates makefiles and/or ide project files for most compilers and IDEs.
    • It abstracts the differences between windows and unix, eg "libShared.so" and "Shared.dll" are referred to as "Shared" (cmake handles the name differences for each platform), if Shared is part of your project it sorts out the dependency if not it assumes that it is in the linker path.
    • It investigates the users system for compiler and 3rd party libraries that are required, you can then optionally remove components when 3rd party libraries are not available or display an error message (It ships with macros to find most common 3rd party libraries).
    • It can be run from the command line or with a simple gui that enables the user to change any of the parameters that were discovered above (eg compiler or version of 3rd party library).
    • It supports macros for automating common steps.
    • There is a component called CPack that enables you to create an installer, I think this is just a make install command line thing (I have not used it).
    • The CTest component integrates with other unit testing libraries like boost test or google test.

    I use CMake for everything now, even simple test projects with visual studio.

    I have never used autotools but a lot of other users have commented that cmake is easier to use. The KDE project moved to cmake from autotools for this reason.

提交回复
热议问题