no message
parent
86f198ffe8
commit
89f76d562f
114
CMakeLists.txt
114
CMakeLists.txt
|
@ -1,84 +1,40 @@
|
|||
cmake_minimum_required(VERSION 3.11)
|
||||
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
|
||||
)
|
||||
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 "
|
||||
)
|
||||
from conans import ConanFile, CMake, tools
|
||||
from conans import tools
|
||||
|
||||
add_custom_command (
|
||||
TARGET generallib POST_BUILD
|
||||
COMMAND ar rc libgeneral.a *.obj
|
||||
COMMENT "package library ar rc *.o "
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET generallib POST_BUILD
|
||||
COMMAND del *.o *.obj
|
||||
COMMENT "remove all step library"
|
||||
)
|
||||
# using GCC
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
message("using asm")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
message("using msvc")
|
||||
endif()
|
||||
class GenerallibConan(ConanFile):
|
||||
source_folder = "pkgsrc"
|
||||
name = "generallib"
|
||||
version = "1.0"
|
||||
license = "GPL"
|
||||
author = "caiyuzheng"
|
||||
url = "https://gitee.com/290198252/generallib"
|
||||
description = "a simple cpp basic library"
|
||||
exports_sources = "general*", "test*"
|
||||
generators = "cmake_find_package"
|
||||
|
||||
endif()
|
||||
def source(self):
|
||||
tools.rmdir("pkgsrc")
|
||||
git = tools.Git(folder=self.source_folder + "/pkgsrc")
|
||||
git.clone("https://gitee.com/290198252/generallib.git")
|
||||
|
||||
# copy header files
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
|
||||
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)
|
||||
|
||||
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})
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
print("path " + self.source_folder + " is where the package built")
|
||||
print("build env is ",tools.get_env("BUILD_ENV"))
|
||||
tools.rmdir(tools.unix_path(self.package_folder)+"/build")
|
||||
tools.mkdir(tools.unix_path(self.package_folder)+"/build")
|
||||
if tools.os_info.is_windows:
|
||||
print("current os windows")
|
||||
if tools.os_info.is_cygwin:
|
||||
print("cygwin build")
|
||||
if tools.get_env("BUILD_ENV")=="msys":
|
||||
print("msys build")
|
||||
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"))
|
||||
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake --build . ")
|
||||
|
||||
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)
|
||||
def requirements(self):
|
||||
self.requires("libevent/2.1.2", private=True, override=False)
|
21
conanfile.py
21
conanfile.py
|
@ -12,7 +12,7 @@ class GenerallibConan(ConanFile):
|
|||
exports_sources = "general*", "test*"
|
||||
def source(self):
|
||||
tools.rmdir("pkgsrc")
|
||||
git = tools.Git(folder=self.source_folder)
|
||||
git = tools.Git(folder=self.source_folder + "/pkgsrc")
|
||||
git.clone("https://gitee.com/290198252/generallib.git")
|
||||
|
||||
def package(self):
|
||||
|
@ -21,11 +21,18 @@ class GenerallibConan(ConanFile):
|
|||
|
||||
def build(self):
|
||||
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()
|
||||
print("path " + self.source_folder + " is where the package built")
|
||||
print("build env is ",tools.get_env("BUILD_ENV"))
|
||||
tools.rmdir(tools.unix_path(self.package_folder)+"/build")
|
||||
tools.mkdir(tools.unix_path(self.package_folder)+"/build")
|
||||
if tools.os_info.is_windows:
|
||||
print("current os windows")
|
||||
if tools.os_info.is_cygwin:
|
||||
print("cygwin build")
|
||||
if tools.get_env("BUILD_ENV")=="msys":
|
||||
print("msys build")
|
||||
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"))
|
||||
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake --build . ")
|
||||
|
||||
def requirements(self):
|
||||
self.build_requires("tool_win/0.1@user/stable")
|
||||
self.requires("libevent/2.1.2", private=True, override=False)
|
Loading…
Reference in New Issue