[CMake] Conditional dependency

Nicholas Yue yue.nicholas at gmail.com
Tue Nov 6 03:19:13 EST 2007


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.

Regards


More information about the CMake mailing list