Fixed CMake setting -static for the wrong invocation.