Add missing pthread flags.
Small CMake tweaks for catkin

Conflicts:

	joint_trajectory_controller/CMakeLists.txt
Use correct return type when calling permutation()

- Fixes a 32-64bit issue.
Change return type of permutation() function.

Problem: permutation return type was vector<T>::size_type, which is:
- 32bits wide in 32bits Unix, which is the size of both unsigned int
  and unsigned long int.

- 64bits wide in 64bits Unix, which is the size of unsigned long int,
  but not unsigned int (the latter being 32bits wide).

I was doing at some points vector<unsigned int> = permutation(...),
which triggered a compile error in 64bit systems. Due to this, I'm
changing the return type of the function to be vector<unsigned int>,
and live with the implicit narrowing conversions that will take
place inside the implementation, since we won't be storing vectors
large enough to overflow an unsigned int.