[CMake] Empty libraries?

Nicholas Braden nicholas11braden at gmail.com
Sun Aug 14 15:35:43 EDT 2016


I noticed it is possible to create empty libraries like this:

    add_library(header-only "header.hpp")
    set_property(TARGET header-only PROPERTY LINKER_LANGUAGE CXX)

On my machine, MinGW spits out an empty 8-byte libheader-only.a, and
Visual Studio works too but outputs nothing. Is this even technically
supported at all? Is this considered portable?

I already know about INTERFACE library targets - however, it seems
that with the above approach, the header file(s) will show up in the
IDE, but not with an INTERFACE library, correct? If so, I would rather
not use INTERFACE in this case as I would like the header files to
show up in generated IDE projects.


More information about the CMake mailing list