wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
7.28k stars 1.17k forks source link

fix CMakeLists.txt #455

Closed HiGarfield closed 1 year ago

wangyu- commented 1 year ago

oops, this doesn't work very well.

If you delete the git_version.h after you have run make, then the file will not be regenerated. And the build will fail

HiGarfield commented 1 year ago

oops, this doesn't work very well.

If you delete the git_version.h after you have run make, then the file will not be regenerated. And the build will fail

I did remove git_version.h. I removed makefile. Once we use cmake, cmake will generate Makefile, which has lower priority than makefile when running make command. So makefile should be removed when cmake is adopted.

wangyu- commented 1 year ago

to make it clear, here is my step to reproduce the problem:

git clone https://github.com/wangyu-/udp2raw.git
cd udp2raw
git checkout ec6fad552b9cd     # the commit with you change
mkdir build && cd build
cmake -S .. -B .
make
rm ../git_version.h
make

it shows:

yancey@yancey-ubuntu:~/ttt/udp2raw/build$ make
[  5%] Building CXX object CMakeFiles/udp2raw.dir/main.cpp.o
[ 11%] Building CXX object CMakeFiles/udp2raw.dir/lib/md5.cpp.o
[ 17%] Building CXX object CMakeFiles/udp2raw.dir/lib/pbkdf2-sha1.cpp.o
[ 23%] Building CXX object CMakeFiles/udp2raw.dir/lib/pbkdf2-sha256.cpp.o
[ 29%] Building CXX object CMakeFiles/udp2raw.dir/encrypt.cpp.o
[ 35%] Building CXX object CMakeFiles/udp2raw.dir/log.cpp.o
[ 41%] Building CXX object CMakeFiles/udp2raw.dir/network.cpp.o
[ 47%] Building CXX object CMakeFiles/udp2raw.dir/common.cpp.o
[ 52%] Building CXX object CMakeFiles/udp2raw.dir/connection.cpp.o
[ 58%] Building CXX object CMakeFiles/udp2raw.dir/misc.cpp.o
[ 64%] Building CXX object CMakeFiles/udp2raw.dir/fd_manager.cpp.o
[ 70%] Building CXX object CMakeFiles/udp2raw.dir/client.cpp.o
[ 76%] Building CXX object CMakeFiles/udp2raw.dir/server.cpp.o
[ 82%] Building CXX object CMakeFiles/udp2raw.dir/lib/aes_faster_c/aes.cpp.o
[ 88%] Building CXX object CMakeFiles/udp2raw.dir/lib/aes_faster_c/wrapper.cpp.o
[ 94%] Building CXX object CMakeFiles/udp2raw.dir/my_ev.cpp.o
[100%] Linking CXX executable udp2raw
[100%] Built target udp2raw
yancey@yancey-ubuntu:~/ttt/udp2raw/build$ rm ../git_version.h
yancey@yancey-ubuntu:~/ttt/udp2raw/build$ make
Consolidate compiler generated dependencies of target udp2raw
[  5%] Building CXX object CMakeFiles/udp2raw.dir/misc.cpp.o
/home/yancey/ttt/udp2raw/misc.cpp:7:10: fatal error: git_version.h: No such file or directory
    7 | #include "git_version.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:202: CMakeFiles/udp2raw.dir/misc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/udp2raw.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

in my test, I do have kept your code untouched, including the file(REMOVE makefile) when the problem happens, the origin makefile is already gone

wangyu- commented 1 year ago

also I think the file(REMOVE makefile) itself is too trick

Once we use cmake, cmake will generate Makefile, which has lower priority than makefile when running make command.

to deal with this problem, the standard way is to create a build folder, and run cmake -S .. -B . inside that folder

HiGarfield commented 1 year ago

to make it clear, here is my step to reproduce the problem:

git clone https://github.com/wangyu-/udp2raw.git
cd udp2raw
git checkout ec6fad552b9cd     # the commit with you change
mkdir build && cd build
cmake -S .. -B .
make
rm ../git_version.h
make

it shows:

yancey@yancey-ubuntu:~/ttt/udp2raw/build$ make
[  5%] Building CXX object CMakeFiles/udp2raw.dir/main.cpp.o
[ 11%] Building CXX object CMakeFiles/udp2raw.dir/lib/md5.cpp.o
[ 17%] Building CXX object CMakeFiles/udp2raw.dir/lib/pbkdf2-sha1.cpp.o
[ 23%] Building CXX object CMakeFiles/udp2raw.dir/lib/pbkdf2-sha256.cpp.o
[ 29%] Building CXX object CMakeFiles/udp2raw.dir/encrypt.cpp.o
[ 35%] Building CXX object CMakeFiles/udp2raw.dir/log.cpp.o
[ 41%] Building CXX object CMakeFiles/udp2raw.dir/network.cpp.o
[ 47%] Building CXX object CMakeFiles/udp2raw.dir/common.cpp.o
[ 52%] Building CXX object CMakeFiles/udp2raw.dir/connection.cpp.o
[ 58%] Building CXX object CMakeFiles/udp2raw.dir/misc.cpp.o
[ 64%] Building CXX object CMakeFiles/udp2raw.dir/fd_manager.cpp.o
[ 70%] Building CXX object CMakeFiles/udp2raw.dir/client.cpp.o
[ 76%] Building CXX object CMakeFiles/udp2raw.dir/server.cpp.o
[ 82%] Building CXX object CMakeFiles/udp2raw.dir/lib/aes_faster_c/aes.cpp.o
[ 88%] Building CXX object CMakeFiles/udp2raw.dir/lib/aes_faster_c/wrapper.cpp.o
[ 94%] Building CXX object CMakeFiles/udp2raw.dir/my_ev.cpp.o
[100%] Linking CXX executable udp2raw
[100%] Built target udp2raw
yancey@yancey-ubuntu:~/ttt/udp2raw/build$ rm ../git_version.h
yancey@yancey-ubuntu:~/ttt/udp2raw/build$ make
Consolidate compiler generated dependencies of target udp2raw
[  5%] Building CXX object CMakeFiles/udp2raw.dir/misc.cpp.o
/home/yancey/ttt/udp2raw/misc.cpp:7:10: fatal error: git_version.h: No such file or directory
    7 | #include "git_version.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:202: CMakeFiles/udp2raw.dir/misc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/udp2raw.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

in my test, I do have kept your code untouched, including the file(REMOVE makefile) when the problem happens, the origin makefile is already gone

I see. Creating git_version.h should be performed during make, rather than cmake.