The various Articles of Secession indicate slavery was a major cause. The election of Lincoln was a major cause, obviously, and the main objection was his stance (or perceived stance) on slavery. There were other issues that folks use to confuse. I'm not talking about individual motivations to fight, that issue is more complex, but the core cause of secession was slavery.
The cause of the war itself gets more complex. South Carolina seceded months before the war started. Had Lincoln removed Federal troops from Fort Sumter, the Confederacy would likely have peacefully gone its way (sans NC and VA) and there would have been no war.
Your comment that individual motivations to fight are "more complex" is very true and really quite an understatement.
In the antebellum South only a fairly small percentage of whites actually owned slaves. The actual percentage is the subject of some debate but the absolute highest expression of it that I have seen comes from a pro-reparations activist who claims that almost one-third of southern families owned slaves. Even using that extraordinarily high figure, still more than two-thirds of southern families did NOT own slaves so it stands to reason that at least around two-thirds of Confederate Soldiers had no direct personal benefit from the institution of Slavery.
In the North the situation was quite convoluted. A lot of poorer whites, particularly recent immigrants were at best lukewarm to the concept of abolition due to fear of wage competition from freed slaves. This contributed to anti-war sentiment in the north that got so bad as to require Union Troops to be rushed from their win at the Battle of Gettysburg not South in pursuit of Lee but Northeast to NYC to put down violent anti-draft riots.
In my own ancestry (AFAIK all of my ancestors were in North America before the Civil War) I have some ancestors who appear to have been drafted and fought rather begrudgingly for the Union possibly fighting to "preserve the Union" and others who joined up of their own free will and expressly for the purpose of freeing the slaves.
My 2-great grandfather (Mother's, Mother's, Father's Father) was born to Quaker parents and raised a Quaker. Quakers opposed both slavery and war but my 2-great Grandfather Joshua and his brother Caleb felt that "opposing slavery" as an intellectual pursuit but sitting idly by while hundreds of thousands of your countrymen actually fought to end it was hypocritical so they joined up. My three-great uncle Caleb was killed in a small and previously little-known Pennsylvania Village called Gettysburg on July 3, 1863. His brother Joshua served for the entire war from nearly the beginning until the final surrender. He was wounded twice but survived the war and went on to have a large family with my great-grandfather as one of his sons. I have a picture of my Grandmother (born 1909) sitting on his knee in about 1919.
My ancestors Joshua and Caleb were unusual but not altogether unique. They joined up explicitly to end slavery. Most Northerners fought either because they didn't have a choice or to "preserve the union". In fact, Lincoln was not elected on a platform of "ending slavery". His platform was to stop the spread (not allow it in new territories) and enforce the already existing prohibition on the importation of additional slaves.
Then there is the Emancipation Proclamation:
The Holy Roman Empire was famously neither Holy, nor Roman, nor an Empire. Similarly, the Emancipation Proclamation functionally did not free a single slave. Lincoln worded it carefully because there were still some slaves within Union States and, in any case, the President's Constitutional authority to unilaterally free such persons was dubious at best. Lincoln avoided those issues by proclaiming the freedom of slaves in areas "then in rebellion". That made it a military action under his authority as "Commander in Chief" which had a much stronger Constitutional basis than a domestic Presidential edict.
Additionally, the Emancipation Proclamation was not issued for the purpose of freeing slaves, it was issued for the purpose of keeping France and Great Britain out of the war. The developing industrial North was an economic competitor to European industry while the agrarian South was an economic supplier of raw materials to and purchaser of industrial goods from European Industry. The European powers were in a bit of a pickle because their economic interests leaned strongly toward the South but Slavery was extremely unpopular in Europe so their emotional interests were with the North. The purpose of the Emancipation Proclamation was to make the abolition of slavery an explicit war aim of the North which would effectively make it impossible for either Britain or France to join the war on the (now) explicitly pro-slavery side.