There is a rule of thumb here that our dog trainer taught us which is, if you cannot hold your hand on the ground for more than 5 seconds, pavement, dirt etc, it is too hot for your dog to be walking on or be out in. This can be taken with a pinch of salt if you are for example at a beach, the sand maybe too hot but the access to vast amounts of water to play in will keep the dog cool.
Whilst the coat @ShemSeger linked to can be useful (along with cooling bandanas), as dogs cannot sweat, only reduce their heat from panting, it's only part of a solution (and will obviously only work for as long as the coat has water, the hotter the day gets the more water will be needed as they do need topping up).
Also with the heat you need to take your breed of dog into consideration as well. We have a long haired breed, a Shetland Sheepdog, and have always had long haired breeds (Rough Collies / German Shepherds) who are bred for colder climes. A 40C day is very unlikely where we live (Bucks, England) however even in 25C heat a all dogs need access to shade, water to drink, or to lounge in (For our dog he gets his own paddling pool).
When we take Blaze out for the day he has his own water bottle as well because he can and often will drink more than we will being long haired. (See Warm weather walkies and water)
Some people are known to shave their long haired dogs in summer like you would do a horse, but for some breeds like a Sheltie which have a triple layered waterproof coat this isn't advised. Short haired dog breeds bred for hotter climes will do much better as a standard, as would lighter coat colours.
The issue I have here is the coat is only a partial solution, if you're out in 40C heat you're also making your dog walk on hot ground with no protection to his feet - which is why I stated the rule of thumb - whilst dogs paws are tougher than human feet it is still unfair to make them walk on ground that is being heated by the sun to the tune of a 40C day. You can purchase shoes / boots for dogs for hiking as well.
TL;DR;
In combination you need to consider a few factors here - the heat of the ground as well as the air. The cooling coats / bandanas are a partial solution, but you need to consider making your dog walk on hot bare ground without protection (would you want to bare foot?) Also you need to make sure you're regularly allowing your dog to drink and take water for him as well as yourself. As much access to shade as possible is a bonus.
If it's far too hot, consider not taking your dog with you.
RSPCA blog post for hot weather and dogs