Why don't using
include(CTest) instead of the "poor"
enable_testing() directly ?
Also you can test
BUILD_TESTING to know if test must be enable or not which is the standard way IMHO...
Note CMake will generate tests only if the enable_testing() command has been invoked. The CTest module invokes the command automatically when the BUILD_TESTING option is ON.