I’m facing a problem where I build a shared library and a unit-test executable (which is in a sub directory). I want to execute this test as a POST_BUILD operation for the shared library. So I gave
Add_Custom_Command (TARGET ShLibName POST_BUILD COMMAND unit_test_exe)
CMake throws an error message during generation process:
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"libCUEUtilities" of type SHARED_LIBRARY depends on "UtilitiesUnitTest"
"UtilitiesUnitTest" of type EXECUTABLE depends on "libCUEUtilities"
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.
So, how can I achieve what I’m trying to do.
I’m using CMake 2.8.1 (RC3) with VS2005 generator.
Sounds like you want to run a unit test every time the shared library is compiled. Since the test executable already depends on the shared library, you can change the
add_custom_commandto run once the unit test executable has been built. For example:Changing any of the library sources will cause the library to be recompiled. Since the executable has a dependency on the library, the exe will get relinked, and finally the post-build step will be run again.