Merge branch 'master' of https://gitee.com/290198252/generallib into master

master
zcy 2021-03-08 12:02:35 +08:00
commit f190a8d0c5
1 changed files with 33 additions and 28 deletions

View File

@ -1,46 +1,51 @@
cmake_minimum_required(VERSION 3.11) 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) enable_language(CXX)
project(generallib) project(generallib)
add_subdirectory(general) add_subdirectory(general)
SET(SRC_SDK sdk_main.c test/src/heapsort/main.c)#
find_package(libevent REQUIRED)
set(EVENT__HAVE_LIBEVENT 1)
message(STATUS "libevent include: " ${libevent_INCLUDE_DIR})
message(STATUS "libevent lib: " ${libevent_LIBRARIES})
message(STATUS "libevent lib Dirs: " ${libevent_LIB_DIRS})
SET(SRC_SDK sdk_main.c )#
add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK}) add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK})
message("CMAKE_BINARY_DIR is " ${CMAKE_BINARY_DIR}) message("CMAKE_BINARY_DIR is " ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libd) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libd)
link_directories(general/third/lib) link_directories(${libevent_LIB_DIRS})
set_target_properties(generallib PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(generallib PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(generallib public target_link_libraries(generallib public
-Wl,--whole-archive -Wl,--whole-archive
libevent.a libevent.a
-Wl,--no-whole-archive -Wl,--no-whole-archive
) )
find_package(libevent)
message("current path is" ${CMAKE_CURRENT_SOURCE_DIR}) message("current path is" ${CMAKE_CURRENT_SOURCE_DIR})
IF (WIN32) IF (WIN32)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("using clang") #message("using clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("using gcc") #message("using gcc")
add_custom_command ( #add_custom_command (
TARGET generallib POST_BUILD # TARGET generallib POST_BUILD
COMMAND ar -x # COMMAND ar -x
${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a # ${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a
COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a " # COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a "
) #)
#add_custom_command (
add_custom_command ( # TARGET generallib POST_BUILD
TARGET generallib POST_BUILD # COMMAND ar rc libgeneral.a *.obj
COMMAND ar rc libgeneral.a *.obj # COMMENT "package library ar rc *.o "
COMMENT "package library ar rc *.o " #)
) #add_custom_command(
add_custom_command( # TARGET generallib POST_BUILD
TARGET generallib POST_BUILD # COMMAND del *.o *.obj
COMMAND del *.o *.obj # COMMENT "remove all step library"
COMMENT "remove all step library" #)
)
# using GCC # using GCC
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message("using asm") message("using asm")
@ -60,11 +65,11 @@ file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
message("include dir " ${INCLUDES}) message("include dir " ${INCLUDES})
file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*) file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*)
file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/pattern
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
message( "copy pattern library" ${PatternINCLUDES}) message( "copy pattern library" ${PatternINCLUDES})
file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h) file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h)
file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/encrypt
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp) file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp)
message( "copy math library" ${MathINCLUDES}) message( "copy math library" ${MathINCLUDES})