views:

33

answers:

1

Hi,

I try to force including header with CMake(2.8.2) and this first solution:

   SET_TARGET_PROPERTIES(${MyTarget} PROPERTIES COMPILE_FLAGS "/FI\"${ForcedHeader_A}\"/FI\"${ForcedHeader_B}\"")

Somehow CMake ignores (or overwrites) the first compiler flag. This happens only if the two compiler flags are the same as in this case . I have to port something I dont want to modify the software structure at this moment. Can anyone help me ?

Thanks

A: 

Try this (note also that recent CMake means you don't need to USE_CAPS_ALL_THE_TIME):

get_target_property(FLAGS ${MyTarget} COMPILE_FLAGS)
set_target_properties(${MyTarget} PROPERTIES COMPILE_FLAGS "${FLAGS} /FI\"${ForcedHeader_A}\"/FI\"${ForcedHeader_B}\"")
Jack Kelly
Thanks Jack, but it should work this way. get_target_property(FLAGS ${MyTarget} COMPILE_FLAGS) set_target_properties(${MyTarget} PROPERTIES COMPILE_FLAGS "${FLAGS} /FI\"${ForcedHeader_A}\"/FI\"${ForcedHeader_B}\"")
Seroti
Sorry, it was just sent. set (FLAG "${FLAGS} "/FI\"${ForcedHeader_A}\"" "\"${ForcedHeader_A}\"") set_target_properties(${MyTarget} PROPERTIES COMPILE_FLAGS "${FLAGS}") # Please note that the second flag must not have the option /FI in front, this is an internal problem of the CMake Parser I guess.
Seroti
I'm sorry, I didn't understand that. If you've worked it out, you should answer your own question (there's nothing wrong with answering your own questions) and then accept the answer.
Jack Kelly