On 03/24/2011 11:39 PM, David Doria wrote:
> On Thu, Mar 24, 2011 at 11:31 AM, Yuri Timenkov <[email protected]> wrote:
>> Use COMPILE_FLAGS target property. Like this:
>>
>> set_target_properties(Exec2 PROPERTIES COMPILE_FLAGS "/flag1 /flag2")
>>
>> You can see full list of properties in CMake documentation. Note that
>> compiler flags may be also set for particular source file with
>> set_source_files_properties command.
> 
> Hi Yuri,
> 
> I tried a CMakeLists.txt file like this:
> 
> cmake_minimum_required(VERSION 2.6)
> PROJECT(SetTargetProperties)
> ADD_EXECUTABLE(SetTargetProperties SetTargetProperties.cxx)
> set_target_properties(SetTargetProperties PROPERTIES COMPILE_FLAGS "-DUNIX")
> 
> Then I ran:
> 
> make VERBOSE=1
> 
> and I don't see anything in the output that indicates that this flag
> was passed, but I also don't see the call to g++ at all. How would I
> check that this worked correctly?

Could you post the output of "make VERBOSE=1"?

On *nix, the following CMakeLists.txt works as expected:

cmake_minimum_required(VERSION 2.6)
PROJECT(SetTargetProperties)
FILE(WRITE ${CMAKE_BINARY_DIR}/SetTargetProperties.cxx
"int main(){return 0;}\n")
ADD_EXECUTABLE(SetTargetProperties SetTargetProperties.cxx)
set_target_properties(SetTargetProperties PROPERTIES COMPILE_FLAGS "-DUNIX")

The output of "make VERBOSE=1" contains:

> .../c++ -DUNIX -o .../SetTargetProperties.cxx.o -c .../SetTargetProperties.cxx

BTW, preprocessor definitions like "-DUNIX" should be set via the
COMPILE_DEFINITIONS properties instead of the COMPILE_FLAGS ones.

Regards,

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

Reply via email to