Replace make with CMake
KOLANICH opened this issue · comments
CMake supports multiple toolchains.
CMake is an overkill for compiling three portable .c
files when simple cc *.c -o crchack
suffices. Maybe later if we decide to build a dynamic library (#7).
Of course it is. But meson and especially bazel are even worse overkills and basic systems like make
have no tolchain abstraction layer.
simple cc *.c -o crchack suffices
it doesn't. It has following issues:
- it is only for toolchains with gcc-compatible interface
- it doesn't allow cross-building automatically (in order to do it a bunch of flags should be provided to CLang and a convenient way to setup it is CMake toolchain file)
- no hardening flags were used (I have a CMake script automatically probing hardening flags and applying them if they are present)
it doesn't. It has following issues:
- it is only for toolchains with gcc-compatible interface
So that means MSVC doesn't work, but on the other hand, MSVC also doesn't really come with a Make program that can handle GNU make. More generally, many projects don't worry about whether something works on MSVC because people can always just use mingw.
- it doesn't allow cross-building automatically (in order to do it a bunch of flags should be provided to CLang and a convenient way to setup it is CMake toolchain file)
Certainly it does... just set CC=my-cross-clang
which is even MORE convenient than a cmake toolchain file.
- no hardening flags were used (I have a CMake script automatically probing hardening flags and applying them if they are present)
The Makefile uses $CFLAGS
. It is also buggy because it doesn't use $LDFLAGS
, although for reasons I'm not sure I understand it does use $LDLIBS
as arbitrary compiler options without actually defining any of its own; this is a completely nonstandard variable that happens to be used in GNU Make for the implicit rules, allowing you to hook into those implicit rules with project-specific libraries to link to.
This is trivially fixed and doesn't require adding a heavyweight build system when no platform-specific logic such as "how to build a shared library" has come up yet.