From 86f198ffe8d6f2a0bce251ea7a2662af2e10e796 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Sat, 10 Oct 2020 12:24:12 +0800 Subject: [PATCH] =?UTF-8?q?cmake=20object=20=E9=A1=B9=E7=9B=AE=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81add=5Fcuscom=5Fcommand,=E5=9B=A0=E6=AD=A4?= =?UTF-8?q?=E5=B0=86=E5=A4=B4=E6=96=87=E4=BB=B6=E6=8B=B7=E8=B4=9D=E5=A4=96?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E5=8C=85=E8=A3=85=E5=BA=93=E7=9A=84cmakefile?= =?UTF-8?q?.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++- conanfile.py | 17 +++++++++++++---- general/CMakeLists.txt | 43 ------------------------------------------ 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d285fb..ba9af44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,4 +47,38 @@ IF (WIN32) message("using msvc") endif() -endif() \ No newline at end of file +endif() + +# copy header files +SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj) + +set(COPYITEM inc) +file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*) +file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) +message("include dir " ${INCLUDES}) + +file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*) +file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) +message( "copy pattern library" ${PatternINCLUDES}) +file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h) +file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) +file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp) +message( "copy math library" ${MathINCLUDES}) +add_custom_command(TARGET generallib PRE_LINK + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen) +message( "copy third library") +file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*) +file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/ + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) +message( "copy net ") + +file(GLOB NET ${PROJECT_SOURCE_DIR}/general/src/net/*.h) +file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) + +file(GLOB ALGORITHM ${PROJECT_SOURCE_DIR}/general/src/algorithm/*) +file(COPY ${ALGORITHM} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) diff --git a/conanfile.py b/conanfile.py index c0ea699..187a3c1 100644 --- a/conanfile.py +++ b/conanfile.py @@ -2,6 +2,7 @@ from conans import ConanFile, CMake, tools from conans import tools class GenerallibConan(ConanFile): + source_folder = "pkgsrc" name = "generallib" version = "1.0" license = "GPL" @@ -10,13 +11,21 @@ class GenerallibConan(ConanFile): description = "a simple cpp basic library" exports_sources = "general*", "test*" def source(self): - git = tools.Git(folder="third_build/libevent") - git.clone("https://gitee.com/mirrors/libevent.git") + tools.rmdir("pkgsrc") + git = tools.Git(folder=self.source_folder) + git.clone("https://gitee.com/290198252/generallib.git") def package(self): self.copy(pattern ="*.h", dst="include", src="general",keep_path=True) self.copy(pattern ="*.hpp", dst="include", src="general",keep_path=True) def build(self): - print("start build Dependency") - \ No newline at end of file + cmake = CMake(self) + # same as cmake.configure(source_folder=self.source_folder, build_folder=self.build_folder) + cmake.configure(source_folder="pkgsrc", build_folder="build") + cmake.build() + cmake.test() + cmake.install() + + def requirements(self): + self.build_requires("tool_win/0.1@user/stable") diff --git a/general/CMakeLists.txt b/general/CMakeLists.txt index e5da28a..f2a6f2e 100644 --- a/general/CMakeLists.txt +++ b/general/CMakeLists.txt @@ -37,46 +37,3 @@ aux_source_directory(src/pattern PaternSrc) add_library(General OBJECT ${DIRSRCS} ${PaternSrc} src/pattern/signleton.hpp src/pattern/cmd.hpp src/pattern/Observer.hpp src/pattern/stratergy.hpp "src/pattern/adapter.hpp" src/encrypt/base64.cpp src/encrypt/base64.h src/encrypt/aes.cpp src/encrypt/aes.h src/encrypt/rsa.cpp src/math/BigInt.hpp src/net/TcpClient.cpp src/net/TcpClient.h src/net/PackageReceiver.cpp src/net/PackageReceiver.h src/function/Timer.cpp src/function/btree.cpp src/function/btree.h src/algorithm/sorter.hpp) - -set(COPYITEM inc) -file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*) -file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -message("include dir " ${INCLUDES}) - -file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/src/pattern/*) -file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -message( "copy pattern library" ${PatternINCLUDES}) -file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/src/encrypt/*.h) -file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/src/math/*.hpp) -message( "copy math library" ${MathINCLUDES}) -file(COPY ${MathINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -file(GLOB EIGENLIBS ${PROJECT_SOURCE_DIR}/src/math/eigin/*) -message( "copy eigen library" ${EIGENLIBS}) -message( "copy third library") -file(GLOB THIRD ${PROJECT_SOURCE_DIR}/third/include/*) -file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/ - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -message( "copy net ") - -file(GLOB NET ${PROJECT_SOURCE_DIR}/src/net/*.h) -file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) - -file(GLOB ALGORITHM ${PROJECT_SOURCE_DIR}/src/algorithm/*) -file(COPY ${ALGORITHM} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) -IF (WIN32) -message("it is windows 32") -ELSEIF (UNIX) -add_custom_command( - TARGET General PRE_BUILD - COMMAND cp.exe -r - ${CMAKE_CURRENT_SOURCE_DIR}/src/math/Eigen - ${CMAKE_CURRENT_SOURCE_DIR}/obj/inc/ -) -ENDIF () \ No newline at end of file