building system

On researching…

The Meson Build system
http://mesonbuild.com/

./configure –help

CLion supports only CMake-based projects for now.

Makefile projects (CPP-494)
Qt projects (CPP-318)
Autotools projects (CPP-193)

新建一个 CMakeLists.txt 文件,导入clion,多个构建系统可以并存
加入源文件,依赖库等信息

project(myproject C)
cmake_minimum_required(VERSION 2.8)

What toolchain should I use on Windows?
A: You have three options: Cygwin, MinGW and Microsoft Visual C++ compiler. More details on how to configure these toolchains:

https://stackoverflow.com/questions/719057/why-use-build-tools-like-autotools-when-we-can-just-write-our-own-makefiles
building system:

Gitian Building
Gitian is an open source software program that offers what is known as a “build environment.” A build environment is perhaps best described as a “computer within a computer,” but with a specific purpose: a virtual space to compile binaries, completely free of any variables. “Gitian Building,” the process of compiling binaries in Gitian, ensures that whatever computer is used, the binaries turn out exactly the same.

The features that I specifically need for this are:

C++11 support
Cross platform (Linux as main target, but able to build on at least Windows as well)
Decent unit testing support
Support for multiple modules for separating code out
Support for code generation (Using asn1c or protobuf - not 100% sure yet)
Easy to maintain

Tool chain:
GCC
Clang
GCC with MinGW
GCC with Cygwin 32

https://bazel.build/
Build and test software of any size, quickly and reliably

https://scons.org/
SCons 是一个开放源代码、以 Python 语言编写的下一代的程序建造工具。

gradle:
https://guides.gradle.org/building-cpp-executables/?_ga=2.95501525.87336500.1531787554-1352908805.1531787554

GNU Build System:

recently found out about these, I have not personally used them yet:

Ninja, a small build system focused on speed. Google now uses Ninja to build Android instead of Make: link.

Shake, a powerful and fast build system.

Tup, a high performance build system. Algorithmic based design. Analysis of Tup.

All are now cross-platform and support Windows. I’m not yet sure about the rest of your requirements as, again, I have yet to test them myself. They are being used in commercial development, CIG picked Ninja up. First two are akin to Scons, Ant, etc.

CMake
which is a Makefile-generator (also generates native MSVC++ .proj/.sln).

Autotools:creating the makefiles
Autotools:
Autoconf:
Autoconf easily scans an existing tree to find its dependencies and create a configure script that will run under almost any kind of shell. The configure script allows the user to control the build behavior (i.e. –with-foo, –without-foo, –prefix, –sysconfdir, etc..) as well as doing checks to ensure that the system can compile the program.

Configure generates a config.h file (from a template) which programs can include to work around portability issues. For example, if HAVE_LIBPTHREAD is not defined, use forks instead.

I personally use Autoconf on many projects. It usually takes people some time to get used to m4. However, it does save time.

You can have makefiles inherit some of the values that configure finds without using automake.

Automake:
By providing a short template that describes what programs will be built and what objects need to be linked to build them, Makefiles that adhere to GNU coding standards can automatically be created. This includes dependency handling and all of the required GNU targets.

Some people find this easier. I prefer to write my own makefiles.

Libtool
GNU coding standards

环境变量设置:
Both of the these makefiles support the following environment variables:

ICU_PATH: tells the makefile to build with Unicode support, set to the path where your ICU installation is located, for example with: make ICU_PATH=/usr/local install -fgcc.mak

CXXFLAGS: extra compiler options - note that this applies to both the debug and release builds.
INCLUDES: additional include directories.
LDFLAGS: additional linker options.
LIBS: additional library files.

export PATH=$PATH:/local/bin
export LD_LIBRARY_PATH=
/local/lib
export C_INCLUDE_PATH=/local/include
export CPLUS_INCLUDE_PATH=
/local/include

export CPPFLAGS=”${CPPFLAGS} -I${PREFIX}/include -I${SYSROOT}/usr/include -I${TOOLCHAIN}/include”
export CFLAGS=”${CFLAGS} -static -O2 –sysroot=${SYSROOT} -DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=i686 -fpic”
export CXXFLAGS=”${CXXFLAGS} ${CFLAGS}”
export LDFLAGS=”${LDFLAGS} -Bstatic -L${PREFIX}/lib -L${SYSROOT}/usr/lib -L${TOOLCHAIN}/lib”
export LIBS=”${LIBS} ${SYSROOT}/usr/lib/crtbegin_static.o ${SYSROOT}/usr/lib/crtend_android.o -lc -lgcc -lgnustl_static -lstdc++ -lsupc++ -landroid_support”

export CPLUS_INCLUDE_PATH=/home/data/primecoin-core-desktop-src_mac/depends/SDKs/MacOSX10.11.sdk/usr/include/:/usr/include
export C_INCLUDE_PATH=/home/data/primecoin-core-desktop-src_mac/depends/SDKs/MacOSX10.11.sdk/usr/include/:/usr/include
上面的写法覆盖了系统设定的路径,下面的写法会先搜索指定路径,如果未找到就会到系统路径搜索
C_INCLUDE_PATH=~/local/include:$C_INCLUDE_PATH

取消环境变量
unset C_INCLUDE_PATH
unset LD_LIBRARY_PATH