On Saturday 06 November 2010 23:08:29 Eric Noulard wrote: > 2010/11/7 luxInteg <lux-in...@btconnect.com>: > > I tried the following:- > > > > ADD_LIBRARY(LearnCMAKE-shared SHARED file1.c file2.c ) > > ADD_LIBRARY(LearnCMAKE-static STATIC file1.c file2.c ) > > SET(var "") > > FOREACH(var DINT DLONG) > > SET_SOURCE_FILES_PROPERTIES( file1.c file2.c > > PROPERTIES COMPILE_DEFINITIONS ${var}) > > ENDFOREACH(var) > > SET_TARGET_PROPERTIES(LearnCMAKE-shared LearnCMAKE-static > > PROPERTIES OUTPUT_NAME LearnCMAKE) > > > > but my compile logs only show lines with "-DDLONG -O3 " > > and one with "-DDINT -O3" > > > > and the generated libs are about half the size they should be. > > > > advice would be appreciated > > 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 > > configure_file(file1.c file1-long.c @COPYONLY) > SET_SOURCE_FILES_PROPERTIES(file1.c PROPERTIES COMPILE_DEFINITIONS "-DINT") > 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) > > note however that you CAN compile the **same file** twice with differents > flags if it is for **DIFFERENT** targets. You can use > "set_target_properties". i.e. > ADD_LIBRARY(LearnCMAKE-int file1.c file2.c) > ADD_LIBRARY(LearnCMAKE-long file1.c file2.c) > > set_target_properties(LearnCMAKE-int PROPERTIES COMPILE_FLAGS "-DINT") > set_target_properties(LearnCMAKE-long PROPERTIES COMPILE_FLAGS "-DLONG")
many thanks. It worked. And I extended it to a setup with ~dozen files succesfully. And thanks to everyone who forwarded suggestions. > _______________________________________________ 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