View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013567CMakeCMakepublic2012-10-02 07:252013-03-04 08:38
ReporterJussiP 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionduplicate 
PlatformLinuxOSLinuxOS VersionAny
Product VersionCMake 2.8.9 
Target VersionFixed in Version 
Summary0013567: Add functionality to help users write precompiled header support
DescriptionThis bug is not a request for general precompiled header support, but rather a request for some additional functionality to make writing that support easier.

To use precompiled headers with gcc, they must be compiled like this:

g++ [every single flag and option that would be given to source files] header.h -o header.h.gch

Those flags include stuff like -fPIC, -D flags and so on. If any one of them is missing, the produced file will not work.

Currently in CMake this list of flags is really hard to get to. There are two choices that I can see.

1) add a function to CMake that gives all command line switches for a given target. Then it could be used to build the pch like this

-----

get_all_switches_for_target(switches targetname)
list(APPEND switches ${pch_file} -o ${CMAKE_CURRENT_BINARY_DIR}/${pch_file}.gch)
add_custom_command(...

-----

2) If you add the header to the list of source files and then do this:

set_property(SOURCE precompiled.h PROPERTY LANGUAGE CXX)

then CMake will build the pch correctly, but it will be called precompiled.o. GCC will not use it in this case. If there were an additional property which would allow the user to set the output file name (and tell CMake not to link the resulting object file in the target), then the pch could be generated and used easily.

The difference between the two is that the latter would automatically be part of dependency tracking. This is only an issue if you want to precompile your own headers. Most projects only use precompiled headers for system headers, such as STL, Boost and Qt.
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0001260closedKitware Robot Support for precompiled headers 

  Notes
(0031148)
Brad King (manager)
2012-10-02 08:02

All PCH discussion is in issue 0001260.
(0032464)
Robert Maynard (manager)
2013-03-04 08:38

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

 Issue History
Date Modified Username Field Change
2012-10-02 07:25 JussiP New Issue
2012-10-02 08:01 Brad King Relationship added duplicate of 0001260
2012-10-02 08:02 Brad King Note Added: 0031148
2012-10-02 08:02 Brad King Status new => resolved
2012-10-02 08:02 Brad King Resolution open => duplicate
2013-03-04 08:38 Robert Maynard Note Added: 0032464
2013-03-04 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team