On 11/6/07, Nicholas Yue <[EMAIL PROTECTED]> wrote: > Hi, > > I have a project which is build a library fine with CMake (has > around 100 source file). > > ADD_LIBRARY ( mylib STATIC a.cpp b.cpp c.cpp <etc> ) > > The content in b.cpp is relevant to only some platform platform. > > How do I tell CMake that file b.cpp is only to be include as depends > of library "mylib" only if a platform string match. > > I can achieve the desired effect with > > IF (WIN32) > ADD_LIBRARY ( mylib STATIC a.cpp c.cpp <etc>) > ELSE (WIN32) > ADD_LIBRARY ( mylib STATIC a.cpp b.cpp c.cpp <etc>) > ENDIF (WIN32) > > As there are hundreds of file, I want to avoid duplicating and add > to maintainence.
Try this: IF(NOT WIN32) SET(b_SOUCE b.cpp) ENDIF(NOT WIN32) ADD_LIBRARY ( myLib STATIC a.cpp ${b_SOURCE} c.cpp <etc> ) If you're not on WIN32, then the variable ${b_SOURCE} will be empty. -- Salvatore Iovene http://www.iovene.com/ Key Fingerprint: 5647 944D D5AD 2E87 00B4 7D54 2864 359D FF20 16D8 _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake