Sorry, I forgot that I already had that code pasted in my original post. Sorry for the duplicate code :)
On Mon, May 14, 2012 at 5:17 PM, Robert Dailey <[email protected]>wrote: > On Mon, May 14, 2012 at 4:58 PM, Bill Hoffman <[email protected]>wrote: >> >> For those we hard coded many of the flags into a table. So, basically >> for VS greater than 6, we have a table that maps flags to actual options in >> the IDE. There is no special per-compiled support in CMake... :) >> >> All it knows is that flat /Foobar == "Turn on option foobar" and creates >> the right xml or project input file. > > > Thanks for the explanation. > > It would be nice to have target properties for these, instead of this > obscure mapping. It makes it difficult to figure out how exactly to append > compiler flags. For example, I'm using set_property() with APPEND_STRING, > and I have to make sure my spacing is correct each time I enable a > compiler-specific feature using compiler flags. I had to use trial & error > to determine that APPEND_STRINGS worked, but APPEND didn't for > COMPILE_FLAGS. There's a lot of boilerplate logic that I have to deal with > when using set_property with COMPILE_FLAGS. > > It would be much easier to specify some target properties instead. Or > maybe to simplify things, we can have a compiler_flags() command that > simplifies doing this work, if it is undesirable to have new target > properties? > > Is improvement desired in this area? Is the current implementation really > satisfactory? It doesn't exactly offer an intuitive or maintainable > solution. > > Here is what I have to do right now to enable precompiled headers on MSVC: > > macro( _precompiled_headers PrecompiledHeader PrecompiledSource SourcesVar > ) > if( MSVC ) > get_filename_component( PrecompiledBasename ${PrecompiledHeader} NAME_WE ) > set( PrecompiledBinary > "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch" ) > set( Sources ${${SourcesVar}} ) > > set_property( > SOURCE ${PrecompiledSource} APPEND_STRING PROPERTY > COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\" " > ) > > set_property( > SOURCE ${PrecompiledSource} APPEND PROPERTY > OBJECT_OUTPUTS "${PrecompiledBinary}" > ) > set_property( > SOURCE ${Sources} APPEND_STRING PROPERTY > COMPILE_FLAGS "/Yu\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\" " > ) > set_property( > SOURCE ${Sources} APPEND PROPERTY > OBJECT_DEPENDS "${PrecompiledBinary}" > ) > else() > message( "Precompiled header support not provided for this platform" ) > endif() > # Add precompiled header to SourcesVar > list( APPEND ${SourcesVar} ${PrecompiledSource} ) > endmacro() > > I feel like CMake should offer me a higher-level way of dealing with this. >
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
