Jelajahi Sumber

add cmake support and fix compile errors

broncotc 8 tahun lalu
induk
melakukan
ed6416a30d
5 mengubah file dengan 28 tambahan dan 7 penghapusan
  1. 17 0
      CMakeLists.txt
  2. 6 4
      encrypt.cpp
  3. 1 1
      log.cpp
  4. 1 1
      log.h
  5. 3 1
      main.cpp

+ 17 - 0
CMakeLists.txt

@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.7)
+project(udp2raw_tunnel)
+
+set(CMAKE_CXX_STANDARD 11)
+
+set(SOURCE_FILES
+        lib/aes.c
+        lib/md5.c
+        common.cpp
+        encrypt.cpp
+        log.cpp
+        main.cpp
+        network.cpp
+        )
+set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -static")
+set(CMAKE_LINK_LIBRARY_FLAG "-lrt")
+add_executable(udp2raw_tunnel ${SOURCE_FILES})

+ 6 - 4
encrypt.cpp

@@ -1,11 +1,13 @@
-#include <lib/aes.h>
-#include <lib/md5.h>
+extern "C"{
+    #include "lib/aes.h"
+    #include "lib/md5.h"
+}
 #include <string.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <encrypt.h>
-#include <common.h>
+#include "encrypt.h"
+#include "common.h"
 #include "log.h"
 
 //static uint64_t seq=1;

+ 1 - 1
log.cpp

@@ -1,4 +1,4 @@
-#include <log.h>
+#include "log.h"
 
 int log_level=log_info;
 

+ 1 - 1
log.h

@@ -44,7 +44,7 @@
 
 #include <sys/timerfd.h>
 #include <set>
-#include <encrypt.h>
+#include "encrypt.h"
 #include <inttypes.h>
 
 #include <sys/ioctl.h>

+ 3 - 1
main.cpp

@@ -1,7 +1,9 @@
 #include "common.h"
 #include "network.h"
 #include "log.h"
-#include "lib/md5.h"
+extern "C" {
+	#include "lib/md5.h"
+}
 
 char local_address[100]="0.0.0.0", remote_address[100]="255.255.255.255",source_address[100]="0.0.0.0";
 u32_t local_address_uint32,remote_address_uint32,source_address_uint32;