generallib/CMakeLists.txt

50 lines
1.9 KiB
CMake
Raw Normal View History

2020-02-06 18:00:41 +00:00
cmake_minimum_required(VERSION 3.11)
2020-09-30 03:43:43 +00:00
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)
project(generallib)
add_subdirectory(general)
2020-05-09 00:32:36 +00:00
SET(SRC_SDK sdk_main.c test/src/heapsort/main.c)#生成动态库需要至少包含一个源文件
add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK})
2020-09-30 03:43:43 +00:00
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
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 (WIN32)
2020-04-24 14:55:52 +00:00
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
2020-09-30 03:43:43 +00:00
COMMAND ar -x
${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a
COMMENT "package library ar -x ${CMAKE_CURRENT_SOURCE_DIR}/libd/libevent.a "
2020-04-24 14:55:52 +00:00
)
2020-04-24 14:55:52 +00:00
add_custom_command (
TARGET generallib POST_BUILD
COMMAND ar rc libgeneral.a *.obj
COMMENT "package library ar rc *.o "
2020-04-24 14:55:52 +00:00
)
add_custom_command(
TARGET generallib POST_BUILD
2020-09-30 03:43:43 +00:00
COMMAND del *.o *.obj
2020-04-24 14:55:52 +00:00
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()
2020-04-24 12:39:29 +00:00
endif()