tools: preserve the order of CPPPATH/CPPDEFINES/LIBPATH/LIBS

The order of them are important while the uniqueness has nothing to do
with the compiling.

commit 2c5eea4c21ea66f711974ab6ce1048337f7b9efc in upstream.