RafaGago / mini-async-log

Non bloated asynchronous logger
Other
221 stars 20 forks source link

Add CMake #12

Closed woobs closed 7 years ago

woobs commented 7 years ago

This is a preliminary attempt to port your library to a reasonable build system (even though it only has a single file to compile). It should work on "normal" platforms that aren't 10 years old and using an unsupported operating system. It supports building with GCC and MSVC and with/without Boost. However, since sane compilers have supported C++11 for years, I'm of the opinion that Boost support, which is currently broken (see my other pull request), should be dropped. But that's up to you.

Doesn't work with clang because of very weird platform detection code in include/mal_log/util/system.hpp. Seems weird to force people to use GCC these days.

I've tested it on Ubuntu 16.04 (with GCC 5.4 and Boost 1.58) and on Windows 10 (with MSVC 2017 x64). MSVC 2017 build tools can be downloaded for free and can target insecure OS's like Windows XP if needed (with the cmake -T flag) so I can see no reason to support older versions of Microsoft's build tools (though this CMake file probably works with them).

Could not get things to compile on a docker container for Ubuntu 12.04 LTS (with GCC 4.6 and Boost 1.46), but I don't think it makes sense to support that kind of old platform. 12.04 LTS supports ends in a few days anyway and Boost 1,46 is missing boost::atomic and boost::chrono. A newer boost version on that old compiler may have worked.

To build on Unix:

mkdir builddir
cd builddir
cmake [-DCMAKE_BUILD_TYPE=[Release,RelWithDebInfo,Debug,etc (defaults to Debug per CMake)]] ..
make
make install

To build with MSVC and NMake (from dev command prompt):

mkdir builddir
cd builddir
cmake ..
cmake --build . [--config [Release,RelWithDebInfo,Debug,etc]]
cmake --build . [--config [Release,RelWithDebInfo,Debug,etc]] install

Other usual CMake options, generators, etc are supported.

Custom install directory can be specified (good for staging): cmake .. -DCMAKE_INSTALL_PREFIX=whatever

Show build options (USE_BOOST, STRIPLOG[LEVEL], etc) cmake -LH ..

RafaGago commented 7 years ago

Not a CMake fan here (but who is?), I have been deliberately avoiding it for non-professional use, but I guess that I will have to make it easier for users and consider the effort you put in and merge it. I really hope for the "meson" project to gain traction.

I agree that many of the workarounds could safely be dropped now. Unfortunately this code is used at my former employer so I don't know if they have updated the compiler on the build server that builds this project.

I'll have a look at clang compilation.

Thanks for the patch. I will try to fix the platform detection for Clang.

RafaGago commented 7 years ago

I have fixed the clang compilation too.