On 06/14/2011 09:12 PM, Andreas Naumann wrote: > Am 14.06.2011 19:26, schrieb Michael Wild: >> On 06/14/2011 07:12 PM, Kfir Lavi wrote: >> >>> >>> On Tue, Jun 14, 2011 at 8:04 PM, Andreas Naumann >>> <andreas-naum...@gmx.net<mailto:andreas-naum...@gmx.net>> wrote: >>> >>> Am 14.06.2011 18:12, schrieb Kfir Lavi: >>> >>>> Hi, >>>> I need to compile the code twice. Once with -DA and once with -DB >>>> My code look like this: >>>> add_definitions(-DA) >>>> add_library(${mylib_A} SHARED ${myfiles}) >>>> remove_definitions(-DA) >>>> >>>> add_definitions(-DB) >>>> add_library(${lib_B} SHARED ${myfiles}) >>>> remove_definitions(-DB) >>>> >>>> What cmake does is to define A and then remove it, so in compile >>>> time, there >>>> is now definition of A or B. >>>> >>>> How do I tell cmake that the remove needs to be in compile time? >>>> >>>> Regards, >>>> Kfir >>>> >>> You want to create two libraries A and B from the same sourcefiles >>> ${myfiles}. The first one have to be compiled with -DA and the >>> second one with -DB, haven't it? >>> >>> So you could simply set the COMPILE_FLAGS property with >>> add_library(A ${myfiles}) >>> add_library(B ${myfiles}) >>> >>> set_target_properties(A PROPERTIES COMPILE_FLAGS "-DA") >>> set_target_properties(B PROPERTIES COMPILE_FLAGS "-DB") >>> >>> Regards, >>> Andreas >>> >>> >>> Thanks, >>> This solved my problems. >>> >>> Again thanks, >>> Kfir >>> >> Except that COMPILE_FLAGS is the wrong property. You should use >> COMPILE_DEFINITIONS without the -D prefix. >> >> Michael >> >> > correct me, if I am wrong, but at > http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_target_properties > > there is no property "COMPILE_DEFINITIONS". > > If I search through the documentation, I get to the target properties. > > It seems to me, that COMPILE_DEFINITIONS can set only preprocessor > definitions like -DVAR=VALUE with > set_target_properties(targ PROPERTIES COMPILE_DEFINITIONS "VAR=VALUE"). > But if I have a special compiler flag like > -flag:flag_value > I should use > set_target_properties(targ PROPERTIES COMPILE_FLAGS "-flag:flag_value") > > ? > > Andreas
The assignment part is AFAIK optional (probably should be mentioned in the docs). And yes, to pass special flags, use COMPILE_FLAGS. COMPILE_DEFINITIONS should be exclusively used for preprocessor-symbols, as is the command add_definitions(). Michael _______________________________________________ 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