View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014494CMakeCMakepublic2013-10-20 03:272014-03-05 09:58
Reportericando 
Assigned ToStephen Kelly 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformVisual Studio 2012OSWindowsOS Version
Product VersionCMake 2.8.12 
Target VersionFixed in VersionCMake 3.0 
Summary0014494: Doesn't create .lib for header only targets on Windows.
DescriptionNot sure if it should be a bug report or a feature request. Basically the support for header-only library on Windows is missing.

I've tested under Linux and the feature IS actually supported. A header-only library will generate minimum .a file that has nothing in it. However, on Windows, it passes no source file to the 'lib' tool and the tool doesn't generate any files in this case.

It would be better to handle it in CMake side as opposed to the CMakeLists.txt side.

The simplest fix would be generating an empty source file for windows platform if it is header only. A more complicated fix is when CMake generates Makefile, it doesn't generate dependencies on the .a or .lib if it is header-only target, but generates dependencies on child targets.
Steps To ReproduceUnzip the attached file, and under Windows, run
cmake -G "NMake Makefiles"
nmake

It will produce:
NMAKE : fatal error U1073: don't know how to make 'B.lib'
TagsNo tags attached.
Attached Fileszip file icon tests.zip [^] (856 bytes) 2013-10-20 03:27

 Relationships

  Notes
(0034174)
icando (reporter)
2013-10-20 11:19

I tested on windows, looks like empty source file will generate ugly warning about 'no symbol in object file'. So it would be great it can be handled in CMake side gracely.
(0034180)
Brad King (manager)
2013-10-21 08:48

IIUC the new INTERFACE library target type covers this use case.
(0034186)
Stephen Kelly (developer)
2013-10-21 09:40

Yep, what you seem to want is something like this:

 add_library(B INTERFACE)
 target_include_directories(B INTERFACE b.h)
 target_link_libraries(B INTERFACE A)

Please try it with cmake master.

Thanks,
(0035291)
Robert Maynard (manager)
2014-03-05 09:58

Closing resolved issues that have not been updated in more than 4 months

 Issue History
Date Modified Username Field Change
2013-10-20 03:27 icando New Issue
2013-10-20 03:27 icando File Added: tests.zip
2013-10-20 11:19 icando Note Added: 0034174
2013-10-21 08:47 Brad King Assigned To => Stephen Kelly
2013-10-21 08:47 Brad King Status new => assigned
2013-10-21 08:48 Brad King Note Added: 0034180
2013-10-21 09:40 Stephen Kelly Note Added: 0034186
2013-10-21 09:40 Stephen Kelly Status assigned => resolved
2013-10-21 09:40 Stephen Kelly Fixed in Version => CMake 3.0
2013-10-21 09:40 Stephen Kelly Resolution open => fixed
2014-03-05 09:58 Robert Maynard Note Added: 0035291
2014-03-05 09:58 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team