On 01/05/2012 02:42 PM, Mateusz Loskot wrote: > On 5 January 2012 12:31, vivek goel <goelvivek2...@gmail.com> wrote: >> I am using code >> where f contains the file name >> >> >> set(MY_PATH "-D__RELATIVE_PATH__=\\\"ab\\\"") >> set_source_files_properties(${f} PROPERTIES >> COMPILE_FLAGS ${MY_PATH}) >> >> I am not able to see -D__RELATIVE_PATH__ inside compilation flags. > > You have read the 2nd paragraph of COMPILE_FLAGS section in manual, haven't > you. > > Best regards,
Although COMPILE_FLAGS is not meant to specify definitions, it usually works; look at the following exemplary project: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(P C) SET(CMAKE_VERBOSE_MAKEFILE ON) FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n") ADD_EXECUTABLE(main main.c) SET_SOURCE_FILES_PROPERTIES(main.c PROPERTIES COMPILE_FLAGS "-D__RELATIVE_PATH__=\\\"ab\\\"") Make's output reveals: .../gcc -D__RELATIVE_PATH__=\"ab\" -o .../main.c.o -c .../main.c Vivek, perhaps a mistake with regard to the variable f? BTW, note that the COMPILE_DEFINITIONS properties take account for proper escaping and then some; the COMPILE_FLAGS ones don't, AFAIK. 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