no message

master
zcy 2020-11-02 20:07:45 +08:00
parent 89f76d562f
commit c8488d3918
1 changed files with 81 additions and 36 deletions

View File

@ -1,40 +1,85 @@
from conans import ConanFile, CMake, tools cmake_minimum_required(VERSION 3.11)
from conans import tools message( "current compiler " ${CMAKE_CXX_COMPILER_ID})
message("current CXX compiler is " ${CMAKE_CXX_COMPILER})
message("current X compiler is " ${CMAKE_CXX_COMPILER})
message("current make is " ${CMAKE_MAKE_PROGRAM})
enable_language(CXX)
project(generallib)
add_subdirectory(general)
SET(SRC_SDK sdk_main.c test/src/heapsort/main.c)#
add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK})
message("CMAKE_BINARY_DIR is " ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libd)
link_directories(general/third/lib)
set_target_properties(generallib PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(generallib public
-Wl,--whole-archive
libevent.a
-Wl,--no-whole-archive
)
find_package(libevent)
message("current path is" ${CMAKE_CURRENT_SOURCE_DIR})
IF (WIN32)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("using clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("using gcc")
add_custom_command (
TARGET generallib POST_BUILD
COMMAND ar -x
${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a
COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a "
)
class GenerallibConan(ConanFile): add_custom_command (
source_folder = "pkgsrc" TARGET generallib POST_BUILD
name = "generallib" COMMAND ar rc libgeneral.a *.obj
version = "1.0" COMMENT "package library ar rc *.o "
license = "GPL" )
author = "caiyuzheng" add_custom_command(
url = "https://gitee.com/290198252/generallib" TARGET generallib POST_BUILD
description = "a simple cpp basic library" COMMAND del *.o *.obj
exports_sources = "general*", "test*" COMMENT "remove all step library"
generators = "cmake_find_package" )
# using GCC
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message("using asm")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("using msvc")
endif()
def source(self): endif()
tools.rmdir("pkgsrc")
git = tools.Git(folder=self.source_folder + "/pkgsrc")
git.clone("https://gitee.com/290198252/generallib.git")
def package(self): # copy header files
self.copy(pattern ="*.h", dst="include", src="general",keep_path=True) SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
self.copy(pattern ="*.hpp", dst="include", src="general",keep_path=True)
def build(self): set(COPYITEM inc)
cmake = CMake(self) file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*)
print("path " + self.source_folder + " is where the package built") file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
print("build env is ",tools.get_env("BUILD_ENV")) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
tools.rmdir(tools.unix_path(self.package_folder)+"/build") message("include dir " ${INCLUDES})
tools.mkdir(tools.unix_path(self.package_folder)+"/build")
if tools.os_info.is_windows: file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*)
print("current os windows") file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
if tools.os_info.is_cygwin: FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
print("cygwin build") message( "copy pattern library" ${PatternINCLUDES})
if tools.get_env("BUILD_ENV")=="msys": file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h)
print("msys build") file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake build -G\"MinGW Makefiles\" " + tools.unix_path(self.source_folder + "/pkgsrc")) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake --build . ") file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp)
message( "copy math library" ${MathINCLUDES})
def requirements(self): add_custom_command(TARGET generallib PRE_LINK
self.requires("libevent/2.1.2", private=True, override=False) 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)