<html dir="ltr" hola_ext_inject="disabled">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hello,
<div><br>
</div>
<div>How should I properly setup a header-only library in cmake such that:</div>
<div>1. The headers appear in the Visual Studio solution.</div>
<div>2. In an executable i can use target_link_libraries(<TARGET> <HEADER_ONLY_LIBRARY>) to specify that I want to use (the headers of) this library.</div>
<div><br>
</div>
<div>So far I have considered two options: </div>
<div>a) create a INTERFACE library using add_library(<HEADER_ONLY_LIBRARY> INTERFACE), this fulfills property 2. from above but not 1.</div>
<div>b) create a usual library and set LINKER_LANGUAGE to CXX. In this way 1. works but 2. doesn't work unfortunately because the executable will try to link to a library that does not exist.</div>
<div><br>
</div>
<div>Notes: </div>
<div>- A not so nice workaround is to go with b) and add an empty source file to it. </div>
<div>- Another option would be to not link the executable with the HEADER_ONLY_LIBRARY. However one thing that I like about target_link_libraries is that all the "usage requirements" from the HEADER_ONLY_LIBRARY (such as include directories and compile options)
 are applied to the executable automatic. So if I don't use target_link_libraries I would have to set these options manually (unless there is another alternative?).</div>
<div><br>
</div>
<div>I would be very happy for some suggestions :)</div>
<div><br>
</div>
<div>Raffael</div>
<div><br>
</div>
<div>P.S.: See also the (a bit outdated) discussion http://stackoverflow.com/a/11583676/2796908.<a href="http://stackoverflow.com/a/11583676/2796908." target="_blank" style="font-size: 10pt;">http://stackoverflow.com/a/11583676/2796908.</a> </div>
<div><br>
</div>
</div>
</body>
</html>