48 lines
1.8 KiB
CMake
48 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
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})
|
|
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}/cmake-build-debug/libgenerallib.a
|
|
COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/cmake-build-debug/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() |