On Monday 08 November 2010 18:10:01 Eric Noulard wrote: > 2010/11/8 luxInteg <lux-in...@btconnect.com>: > > On Saturday 06 November 2010 23:08:29 Eric Noulard wrote: > >> I think you cannot use **the same** file properties on a source file > >> and expect CMake will compile the file twice for the same target. > >> If you want to compile the same source file twice with different compile > >> flags **FOR THE SAME TARGET** you have to copy this file > >> > >> > >> SET_SOURCE_FILES_PROPERTIES(file1-long.c PROPERTIES > >> COMPILE_DEFINITIONS "-DLONG") > >> > >> > >> ** same for file 2 ** > >> ADD_LIBRARY(LearnCMAKE-static STATIC file1.c file1-long.c file2.c > >> file2-long.c) ADD_LIBRARY(LearnCMAKE-shared SHARED file1.c file1-long.c > >> file2.c file2-long.c) > > > > BUT > > suppose I decide to set file1.c and file2.c as some variable "FILES" > > and I want to use a preprocessor say DLONG > > could I do the following? > > > > set(FILES file1.c file2.c ) > > SET_SOURCE_FILES_PROPERTIES(${FILES} PROPERTIES COMPILE_DEFINITIONS > > "-DLONG") > > Off course you can thanks, it worked a treat. > BUT you cannot set the SAME PROPERTY twice for the same file. > So if you have to do so (compile fileX.c with BOTH -DINT and DLONG) then > you have to do some sort of loop with CMake or > populate 2 CMake variable > > SRC_FILES_LONG > and > SRC_FILES_INT > with the list of appropriate file. > > If you manipulate list have a look at the CMake builtin "LIST" command.
I had a look at lists on this page http://www.cmake.org/Wiki/CMakeMacroListOperations I have also came across this problem:- I have some files say file1.c file2.c file3.c file4.c to be compiled into a library before archiving file1.c is compiled into file1.o but file2.c and file3.c are compiled int file2file3.o then file4.c is compiled into file4.o I had a cursory look at list an came up with this embryonic/rudimentary 'half-attempt' But I am stuck on the bracketed line --------------- set(RUN oddone.o file2.c file3.c ) LIST CONTAINS(file2.c file3.c ${RUN}) IF (contains ) (--compile file2.c and file3.c into oddone.o ) endif (contains) ------------- advice on whether lists of othrwise is appropriate would be appreciated. _______________________________________________ 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