The error
[ 33%] Building CXX object CMakeFiles/socket.dir/server.cpp.o
[ 66%] Building CXX object CMakeFiles/socket.dir/client.cpp.o
[100%] Linking CXX executable socket
/usr/bin/ld: CMakeFiles/socket.dir/client.cpp.o: in function `error(char const*)':
client.cpp:(.text+0x0): multiple definition of `error(char const*)'; CMakeFiles/socket.dir/server.cpp.o:server.cpp:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/socket.dir/client.cpp.o: in function `main':
client.cpp:(.text+0x22): multiple definition of `main'; CMakeFiles/socket.dir/server.cpp.o:server.cpp:(.text+0x22): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/socket.dir/build.make:118: socket] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/socket.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
The file structure and CMakeLists.txt
The program works when i compile the client.cpp and server.cpp on their own but i want to do it using cmake