generallib/CMakeLists.txt

49 lines
1.5 KiB
CMake
Raw Normal View History

2020-02-06 18:00:41 +00:00
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
2020-02-10 13:46:47 +00:00
)
2020-04-24 12:39:29 +00:00
message("current path is" ${CMAKE_CURRENT_SOURCE_DIR})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("using clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("using gcc")
# using GCC
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message("using asm")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("using msvc")
endif()
IF (WIN32)
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"
)
endif()