cmake object 项目不支持add_cuscom_command,因此将头文件拷贝外移到包装库的cmakefile.txt

master
zcy 2020-10-10 12:24:12 +08:00
parent eec2be16ee
commit 86f198ffe8
3 changed files with 48 additions and 48 deletions

View File

@ -47,4 +47,38 @@ IF (WIN32)
message("using msvc")
endif()
endif()
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)

View File

@ -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")
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")

View File

@ -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 ()