[CMake] My macro library for CMake

Alibek Omarov a1ba.omarov at gmail.com
Mon Jan 29 04:30:12 EST 2018


Hello, fellow CMake users!

For almost 3 years of using CMake in my opensource project, I everytime
encounter the verbosity of CMake scripts. So now I have written a small
library of shorthand utility macros.

At this time it have some macros specific for my project, but I hope others
can find it useful too.
List of macros:
1. fwgs_install -- installs library file. On MSVC installs in separate
directories, corresponding to selected configuration in Visual Studio. For
Debug it also installs PDB file automatically.
2. fwgs_conditional_subproject -- adds subdirectory if conditions was met.
I did this because there is some subdirectories, which can be omitted in
some configurations.
3. fwgs_set_default_properties -- default properties for target. For me it
enables PIC and removes "lib" prefix on Windows.
4. fwgs_string_option -- option() but for strings.
5. fwgs_library_dependency -- downloads dependency from Web, unpacks it,
calls find_library to configure and links to the target. Also does a cache
check, if developer have deleted dependency folder for some reason. Just a
big shortcut.
6. fwgs_add_compile_options -- like add_compile_options, but with language
specification: C for C/C++ flags, CXX for C++ flags, CONLY for C only
flags. Also should work with CMake 2.8, which is still used in Ubuntu
12.04, Debian 7 and Steam Runtime toolchain.

There is other too, but I plan to rework them.

https://github.com/FWGS/xash3d/blob/master/cmake/FWGSLib.cmake

I accept any criticism. I understand that many of them maybe aren't needed,
I just doesn't found any equivalent in documentation.

Thanks for attention!
Alibek Omarov a.k.a a1batross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180129/a4a24a7f/attachment.html>


More information about the CMake mailing list