Zitat von Eric Noulard <[EMAIL PROTECTED]>:
2007/11/6, Salvatore Iovene <[EMAIL PROTECTED]>:
On 11/6/07, Nicholas Yue <[EMAIL PROTECTED]> wrote:
>
> 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.
In the same spirit I usually define a var which contains the list
of file to be included in a library and augment var content
conditionally.
The general pattern is the following:
# put unconditional sources in
SET(MYLIB_SRC c.cpp g.cpp <any otherunconditional source>)
# then ADD the conditional ones
IF(WIN32)
SET(MYLIB_SRC ${MYLIB_SRC} win32-a.cpp)
ENDIF(WIN32)
IF(LIBXML2_FOUND)
SET(MYLIB_SRC ${MYLIB_SRC} xml2-a.cpp)
ENDIF()
Additionally, I suggest using the LIST macro instead, the above
actually reinvents LIST(APPEND ....).
HS
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake