Dynamically allocating morph targets in shaders So with the idea that I want to load in an object with morph targets and for simplicity sake I know it will have between 1-8 position morph targets. Ultimately I want to do

renderedPrimitive.POSITION = primitive.POSITION + 
   weights[0] * primitive.targets[0].POSITION +
   ....
   weights[N] * primitive.targets[N].POSITION;


But being open to load in any model how do you go about knowing the number of vertex input attributes to allocate. Getting the CPU side dynamically is not an issue, but am I wrong that the ONLY way around this is building your shader with some #define and compiling during runtime?
With modern hardware, morph targets probably should not be VS inputs. They should be SSBOs or the D3D equivalent. The vertex shader should fetch from these arrays of positions and act on them appropriately. You can pass the number of targets as a uniform or something.