Is there a way to build two versions (one release and one debug) of a target with cmake ? and also to choose the build configuration per target... (the goal is to build a debug version for the tests and a release for normal usage) ...But with only one call to make
While in principal it is possible to do this with CMake, it will be very painful.
For Makefile generators, CMake is designed to provide one configuration only, which is specified when invoking CMake. You should stick with that. If you need to maintain two builds in parallel, use two separate build directories and configure one with Release and one with Debug configuration (mind you, they can still build from the same source!)
If you are worried about the complexity of the build system, provide additional wrapper scripts that automate this process.
Also, why would you want to run the tests only with the debug version? You should always run all the tests for all configurations if possible. Think about an assert()
with a side-effect masking a bug in the code. You will never catch this error when you only test the debug builds.