no message
parent
86f198ffe8
commit
89f76d562f
116
CMakeLists.txt
116
CMakeLists.txt
|
@ -1,84 +1,40 @@
|
||||||
cmake_minimum_required(VERSION 3.11)
|
from conans import ConanFile, CMake, tools
|
||||||
message( "current compiler " ${CMAKE_CXX_COMPILER_ID})
|
from conans import tools
|
||||||
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 "
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command (
|
class GenerallibConan(ConanFile):
|
||||||
TARGET generallib POST_BUILD
|
source_folder = "pkgsrc"
|
||||||
COMMAND ar rc libgeneral.a *.obj
|
name = "generallib"
|
||||||
COMMENT "package library ar rc *.o "
|
version = "1.0"
|
||||||
)
|
license = "GPL"
|
||||||
add_custom_command(
|
author = "caiyuzheng"
|
||||||
TARGET generallib POST_BUILD
|
url = "https://gitee.com/290198252/generallib"
|
||||||
COMMAND del *.o *.obj
|
description = "a simple cpp basic library"
|
||||||
COMMENT "remove all step library"
|
exports_sources = "general*", "test*"
|
||||||
)
|
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()
|
|
||||||
|
|
||||||
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
|
def package(self):
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
|
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)
|
def build(self):
|
||||||
file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*)
|
cmake = CMake(self)
|
||||||
file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
|
print("path " + self.source_folder + " is where the package built")
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
|
print("build env is ",tools.get_env("BUILD_ENV"))
|
||||||
message("include dir " ${INCLUDES})
|
tools.rmdir(tools.unix_path(self.package_folder)+"/build")
|
||||||
|
tools.mkdir(tools.unix_path(self.package_folder)+"/build")
|
||||||
file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*)
|
if tools.os_info.is_windows:
|
||||||
file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
|
print("current os windows")
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
|
if tools.os_info.is_cygwin:
|
||||||
message( "copy pattern library" ${PatternINCLUDES})
|
print("cygwin build")
|
||||||
file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h)
|
if tools.get_env("BUILD_ENV")=="msys":
|
||||||
file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
|
print("msys build")
|
||||||
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 -G\"MinGW Makefiles\" " + tools.unix_path(self.source_folder + "/pkgsrc"))
|
||||||
file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp)
|
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake --build . ")
|
||||||
message( "copy math library" ${MathINCLUDES})
|
|
||||||
add_custom_command(TARGET generallib PRE_LINK
|
def requirements(self):
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen)
|
self.requires("libevent/2.1.2", private=True, override=False)
|
||||||
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)
|
|
23
conanfile.py
23
conanfile.py
|
@ -12,7 +12,7 @@ class GenerallibConan(ConanFile):
|
||||||
exports_sources = "general*", "test*"
|
exports_sources = "general*", "test*"
|
||||||
def source(self):
|
def source(self):
|
||||||
tools.rmdir("pkgsrc")
|
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")
|
git.clone("https://gitee.com/290198252/generallib.git")
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
|
@ -21,11 +21,18 @@ class GenerallibConan(ConanFile):
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
# same as cmake.configure(source_folder=self.source_folder, build_folder=self.build_folder)
|
print("path " + self.source_folder + " is where the package built")
|
||||||
cmake.configure(source_folder="pkgsrc", build_folder="build")
|
print("build env is ",tools.get_env("BUILD_ENV"))
|
||||||
cmake.build()
|
tools.rmdir(tools.unix_path(self.package_folder)+"/build")
|
||||||
cmake.test()
|
tools.mkdir(tools.unix_path(self.package_folder)+"/build")
|
||||||
cmake.install()
|
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):
|
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