Przeglądaj źródła

refactor: deps均使用原生CMakeLists.txt构建项目

SongZihuan 3 lat temu
rodzic
commit
937143bcac

+ 1 - 1
CMakeLists.txt

@@ -7,7 +7,7 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)  # 设置输出路径
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
 
-set(BUILD_SHARED_LIBS TRUE)  # 默认编译动态库
+set(BUILD_SHARED_LIBS ON)  # 默认编译动态库
 
 IF(Build_Memory)
     add_definitions(-DBUILD_MEM=1)

+ 2 - 6
src/CMakeLists.txt

@@ -1,13 +1,9 @@
-IF (MSVC)
-    # 编译dlfcn-win32
-    add_subdirectory(deps/dlfcn)
-ENDIF()
-
+add_subdirectory(deps/dlfcn)
 add_subdirectory(tool)
 add_subdirectory(deps/cjson)
 add_subdirectory(deps/regex)
 
-set(libary af_tool af_json  af_regex)
+set(libary af_tool af_json af_regex)
 
 add_subdirectory(core)
 

+ 3 - 1
src/deps/README

@@ -14,4 +14,6 @@ url: https://github.com/dlfcn-win32/dlfcn-win32
 
 * regex依赖库
 该库用于处理正则表达式
-封装自`pcre2`库
+封装自`pcre2`库
+git子模块: pcre2
+url: https://github.com/PhilipHazel/pcre2

+ 8 - 4
src/deps/cjson/CMakeLists.txt

@@ -1,10 +1,14 @@
-project(cJson LANGUAGES C)
-add_library(cJson STATIC cJSON/cJSON.c)
-
+set(BUILD_SHARED_LIBS OFF)
+set(CJSON_BUILD_SHARED_LIBS OFF)
+set(ENABLE_CJSON_TEST OFF)
+set(CMAKE_C_STANDARD) # cJSON支持C90标准 (若set(CMAKE_C_STANDARD 90)在mingw上会报错)
+add_subdirectory(cJSON)
 
 project(af_json LANGUAGES C)
+set(CMAKE_C_STANDARD 11)
+
 add_library(af_json tool.c)
 set_target_properties(af_json PROPERTIES OUTPUT_NAME "aFunJson")
-target_link_libraries(af_json af_tool cJson)
+target_link_libraries(af_json af_tool cjson)
 
 install(TARGETS af_json)

+ 0 - 3
src/deps/cjson/README

@@ -6,8 +6,5 @@
 ./cJSON文件夹是git子模块
 tool.c是用于对该模块的封装
 
-只使用`cJSON`在`cJSON.c`和`cJSON.h`文件
-使用`CMakeLists.txt`再编译该库
-
 项目url: https://github.com/DaveGamble/cJSON
 子模块: https://github.com/aFun-org/cJSON

+ 9 - 3
src/deps/dlfcn/CMakeLists.txt

@@ -1,3 +1,9 @@
-project(dl LANGUAGES C)
-add_library(dl dlfcn-win32/src/dlfcn.c)
-install(TARGETS dl)
+#project(dl LANGUAGES C)
+#add_library(dl dlfcn-win32/src/dlfcn.c)
+#install(TARGETS dl)
+
+IF (MSVC)
+    # 编译dlfcn-win32
+    set(BUILD_SHARED_LIBS OFF)
+    add_subdirectory(dlfcn-win32)
+ENDIF()

+ 0 - 3
src/deps/dlfcn/README

@@ -5,8 +5,5 @@
 提供msvc下posix的dl动态库
 ./dlfcn-win32文件夹是git子模块
 
-只使用`dlfcn-win32`在`src/dlfcn.c`和`src/dlfcn.h`文件
-使用`CMakeLists.txt`再编译该库
-
 项目url: https://github.com/dlfcn-win32/dlfcn-win32
 子模块: https://github.com/aFun-org/dlfcn-win32

+ 2 - 5
src/deps/regex/README

@@ -5,8 +5,5 @@
 提供正则表达式编译和匹配
 ./pcre2文件夹是git子模块
 
-只使用`dlfcn-win32`在`src/dlfcn.c`和`src/dlfcn.h`文件
-使用`CMakeLists.txt`再编译该库
-
-项目url: https://github.com/dlfcn-win32/dlfcn-win32
-子模块: https://github.com/aFun-org/dlfcn-win32
+项目url: https://github.com/PhilipHazel/pcre2
+子模块: https://github.com/aFun-org/pcre2