cmake and custom pass

Hi,

I tried to compile a custom llvm's pass with the usage of a cmake.
It does not work.
I receive a well known assert in a Pass.cpp: "Pass registered multiple
times!".

The custom pass has to be linked with the core, support and system
archive libraries.
This seems to be a problem.

I suppose the conflict occurs because opt and pass are using the same
libraries.
Does anyone have a working cmake for a custom pass?
If not then can anyone explain how do Makefiles link libraries to
custom passes?

The pass is written well because it works with a autoconf's generated
Makefile.

Best,
Mariusz