How many days it takes travelling by car from Tangeri to Dakar? How safe is travelling by car from Tangeri to Dakar, specifically in Senegal and Mauritania?
I just did this exact trip a few weeks ago (mid July - early August). I joined a couple of friends in Spain, took the ferry to Tangier, and drove down to The Gambia. The Tangier to Dakar portion took 14 days, including a few days for rest / sightseeing (see below). Here's probably more than you bargained for to answer your questions:
We spent ~9 days in Morocco in order to see as much of the country as we could. We made the poor decision to apply for the Mauritanian visa on a Friday, meaning we had to drive back to Rabat on the following Monday. If you apply Mon-Thurs you get the visa the same day I believe. Be warned, if you don't hold an African passport, it will cost about 150 Euro. You can save 30 Euro by getting it on arrival at the border, but is it really worth the risk of 4000km round-trip to Rabat if they say no?
Western Sahara is very sparsely populated, and Dakhla is really only worth more than day if you're kitesurfing or windsurfing. We spent ~1.5 days here.
As for Mauritania, we spent one night in Nouadhibou and one in Nouakchott -- in total about 2.5 days in Mauritania. Didn't really feel like doing much there other than going off the road to play in the sand.
We relaxed for a couple days at Zebrabar just south of Saint-Louis, Senegal. It's a really nice place set in a national park owned by a Swiss family. Dakar is a great fun city, we spent only about a day there, but most of us had been before and seen a lot already.
To be honest, I can't really think of any issues we had regarding security. Western Sahara and Mauritania, despite travel warnings, were quite desolate along the main highway, and we didn't encounter anything that made us feel unsafe. You will want to create fiche cards for each passenger, containing their full name, nationality, passport number, occupation, along with the vehicle registration number. You can hand these to the officials in Western Sahara and Mauritania, which will save you a lot of time (otherwise they will take your passport to their booth and spend 5 to 20 minutes writing down the information). Many of the officials expect you to have these. I'd print at least 30 of them.
In terms of road safety, however, you need to be alert -- much of the traffic along is lorries, with which you will have to share a two-lane highway (which is more like 1.5 lanes in some places to erosion or sand cover!). The endless desert can make you drowsy, and this is about the last place you want to run off the road and ruin your car (help may be hours or days away).
We camped several times in Morocco / Western Sahara and had no issues. People either didn't care or were genuinely happy to have us camp outside their houses / places of business. We were advised not to camp in Mauritania, though probably wouldn't have had any issues if we had. Senegal is completely safe.
Another piece of advice: buy a jerrycan / plastic petrol container, and fill it up in Western Sahara where the gas is cheapest. On our drive from Nouadhibou to Nouakchott -- about 500 km -- every single petrol station was out of gas and we had to fill up from our jerrycan.
There is no border when entering Western Sahara as it is effectively Morocco. However, checkpoints may become more of a hassle as I think they actually start checking up on where you've been.
The Western Sahara--Mauritania border is fine in terms of safety except for the minefield: the road between the two border posts is unpaved and heavily mined. We paid someone 10 Euro to guide us through (about 10 minutes drive) since it can be quite difficult to tell which way to go in order to avoid the landmines. I'd recommend hiring / following someone just to be safe.
The Mauritania--Senegal border can be a bit of a hassle. You have two options: Diama and Rosso. If you take the Diama crossing, you'll need 2000 MRO per person to pay the fee in the national park, as well as 10000 CFA to cross the dam over the river into Senegal. If your car is foreign you may run into corruption at the border. We hired a local fixer in advance (not cheap!) to sort all this out. Some people we met along the way went to the other border post and ended up paying much more in "fees"/bribes than what our fixer had charged us.