generallib/CMakeLists.txt

50 lines
1.8 KiB
CMake

cmake_minimum_required(VERSION 3.11)
project(generallib)
add_subdirectory(general)
SET(SRC_SDK sdk_main.c )#生成动态库需要至少包含一个源文件
add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK})
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 (
TARGET generallib POST_BUILD
COMMAND ar -x
${CMAKE_CURRENT_SOURCE_DIR}/libd/libgenerallib.a
COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/libd/libgenerallib.a"
)
add_custom_command (
TARGET generallib POST_BUILD
COMMAND ar rc libgeneral.a *.o *.obj
COMMENT "package library ar rc *.o *.obj"
)
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()
endif()