fix:conanfile
This commit is contained in:
		| @@ -1,7 +1,8 @@ | |||||||
| cmake_minimum_required( VERSION 3.28) | cmake_minimum_required( VERSION 3.28) | ||||||
| project(Logging) | project(logging) | ||||||
|  |  | ||||||
| enable_testing() | option(TEST "是否启动单元测试" ON) | ||||||
|  | option(SHARED "是否编译为动态库" OFF) | ||||||
|  |  | ||||||
| set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) | set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) | ||||||
| set(ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) | set(ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) | ||||||
| @@ -13,7 +14,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include) | |||||||
| add_subdirectory(src) | add_subdirectory(src) | ||||||
|  |  | ||||||
| #测试单元 | #测试单元 | ||||||
| if (SKIPTEST) | if (TEST) | ||||||
| else() |     enable_testing() | ||||||
|     add_subdirectory(tests) |     add_subdirectory(tests) | ||||||
| endif() | endif() | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								conanfile.py
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								conanfile.py
									
									
									
									
									
								
							| @@ -1,11 +1,8 @@ | |||||||
| from conan import ConanFile | from conan import ConanFile | ||||||
| from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout | from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout | ||||||
| from conan.tools.files import copy, get | from conan.tools.files import copy | ||||||
| from conan.tools.build import check_min_cppstd |  | ||||||
| from conan import tools |  | ||||||
| import os | import os | ||||||
|  |  | ||||||
|  |  | ||||||
| class loggingRecipe(ConanFile): | class loggingRecipe(ConanFile): | ||||||
|     name = "logging" |     name = "logging" | ||||||
|     version = "0.2.3" |     version = "0.2.3" | ||||||
| @@ -16,11 +13,11 @@ class loggingRecipe(ConanFile): | |||||||
|     topics = ("logging", "C", "simple", "easy-to-use", "log","Logging") |     topics = ("logging", "C", "simple", "easy-to-use", "log","Logging") | ||||||
|  |  | ||||||
|     settings = "os", "compiler", "build_type", "arch" |     settings = "os", "compiler", "build_type", "arch" | ||||||
|     options = {"shared": [True, False], "fPIC": [True, False]} |     options = {"shared": [True, False], "fPIC": [True, False],"test":[True,False]} | ||||||
|     default_options = {"shared": False, "fPIC": True} |     default_options = {"shared": False, "fPIC": True,"test":True} | ||||||
|  |  | ||||||
|  |  | ||||||
|     exports_sources = "include/*", "CMakeLists.txt", "src/*" |     exports_sources = "include/*", "CMakeLists.txt", "src/*", "tests/*" | ||||||
|  |  | ||||||
|     def config_options(self): |     def config_options(self): | ||||||
|         if self.settings.os == "Windows": |         if self.settings.os == "Windows": | ||||||
| @@ -30,8 +27,6 @@ class loggingRecipe(ConanFile): | |||||||
|         if self.options.shared: |         if self.options.shared: | ||||||
|             self.options.rm_safe("fPIC") |             self.options.rm_safe("fPIC") | ||||||
|  |  | ||||||
|  |  | ||||||
|      |  | ||||||
|     def layout(self): |     def layout(self): | ||||||
|         cmake_layout(self) |         cmake_layout(self) | ||||||
|  |  | ||||||
| @@ -39,18 +34,16 @@ class loggingRecipe(ConanFile): | |||||||
|         deps = CMakeDeps(self) |         deps = CMakeDeps(self) | ||||||
|         deps.generate() |         deps.generate() | ||||||
|         tc = CMakeToolchain(self) |         tc = CMakeToolchain(self) | ||||||
|         tc.variables["SKIPTEST"]=True |         tc.variables["TEST"] = True if self.options.test else False | ||||||
|         if self.options.shared: |         tc.variables["SHARED"] = True if self.options.shared else False | ||||||
|             tc.variables["SHARED"] = True |  | ||||||
|         else: |  | ||||||
|             tc.variables["SHARED"] = False |  | ||||||
|         tc.generate() |         tc.generate() | ||||||
|  |  | ||||||
|     def build(self): |     def build(self): | ||||||
|         cmake = CMake(self) |         cmake = CMake(self) | ||||||
|         cmake.configure() |         cmake.configure() | ||||||
|         cmake.build(target="Logging") |         cmake.build() | ||||||
|  |         if self.options.test: | ||||||
|  |             cmake.test() | ||||||
|  |  | ||||||
|     def package(self): |     def package(self): | ||||||
|         copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) |         copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) | ||||||
| @@ -62,4 +55,4 @@ class loggingRecipe(ConanFile): | |||||||
|         copy(self, pattern="*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) |         copy(self, pattern="*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) | ||||||
|  |  | ||||||
|     def package_info(self): |     def package_info(self): | ||||||
|         self.cpp_info.libs = ["Logging"] |         self.cpp_info.libs = ["logging"] | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| project(Logging) | project(logging) | ||||||
|  |  | ||||||
| aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC) | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC) | ||||||
| aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/handler SRC) | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/handler SRC) | ||||||
|   | |||||||
| @@ -4,11 +4,11 @@ enable_testing() | |||||||
|  |  | ||||||
| #测试简单基本应用 | #测试简单基本应用 | ||||||
| add_executable(${PROJECT_NAME}simple test_simple.c) | add_executable(${PROJECT_NAME}simple test_simple.c) | ||||||
| target_link_libraries(${PROJECT_NAME}simple Logging) | target_link_libraries(${PROJECT_NAME}simple logging) | ||||||
| add_test(test_simple ${CMAKE_SOURCE_DIR}/bin/${PROJECT_NAME}simple) | add_test(test_simple ${CMAKE_SOURCE_DIR}/bin/${PROJECT_NAME}simple) | ||||||
|  |  | ||||||
|  |  | ||||||
| #测试拦截器 | #测试拦截器 | ||||||
| add_executable(${PROJECT_NAME}interceptor test_interceptor.c) | add_executable(${PROJECT_NAME}interceptor test_interceptor.c) | ||||||
| target_link_libraries(${PROJECT_NAME}interceptor Logging) | target_link_libraries(${PROJECT_NAME}interceptor logging) | ||||||
| add_test(test_interceptor ${CMAKE_SOURCE_DIR}/bin/${PROJECT_NAME}interceptor) | add_test(test_interceptor ${CMAKE_SOURCE_DIR}/bin/${PROJECT_NAME}interceptor) | ||||||
		Reference in New Issue
	
	Block a user