This passage has nothing to do with who David wanted to build the temple for.
1 Kings 8:17 "Now it was in the heart of my father David to build a house for the name of YHWH, the God of Israel.
Who is "YHWH"? And who is the "God of Israel"?
Psalm 2:7 "I (Yeshua) will surely tell of the decree of YHWH (my Father): He said to Me, 'You are My Son, Today I have begotten You. (parenthesis mine)
These are the words of Yeshua via the spirit of prophecy through the psalmist speaking about his Father YHWH.
Exodus 3:15 God, furthermore, said to Moses, "Thus you shall say to the sons of Israel, 'YHWH, the God of your fathers, the God of Abraham, the God of Isaac, and the God of Jacob (Israel), has sent me to you.' This is My name forever, and this is My memorial-name to all generations. (parenthesis mine)
Acts 3:13 "The God of Abraham, Isaac and Jacob (Israel), the God of our fathers, has glorified His servant Yeshua, the one whom you delivered and disowned in the presence of Pilate, when he had decided to release Him. (parenthesis mine)
YHWH is Yeshua's Father and Yeshua is YHWH's Son and servant. The temple was built for Yeshua's Father.