Skip to content

Commit

Permalink
compiler with shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Oct 23, 2024
1 parent ef05606 commit 1ffec75
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
11 changes: 10 additions & 1 deletion mock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@

include_directories(../)
file(GLOB_RECURSE SRC_FILES *.cpp)
add_library(tarsmock ${SRC_FILES})
add_library(tarsmock STATIC ${SRC_FILES})
add_library(tarsmock_shared SHARED ${SRC_FILES})
target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared)

add_dependencies(tarsmock tarsservant)
add_dependencies(tarsmock_shared tarsservant)
install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h")

install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

if (WIN32)
install(FILES $<TARGET_PDB_FILE:tarsmock_shared> DESTINATION bin)
endif()


14 changes: 13 additions & 1 deletion servant/libservant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

aux_source_directory(. DIR_SRCS)

add_library(tarsservant ${DIR_SRCS})
add_library(tarsservant STATIC ${DIR_SRCS})

add_dependencies(tarsservant COPY-SERVENT-TARS)

install(TARGETS tarsservant
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

add_library(tarsservant_shared SHARED ${DIR_SRCS})
target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL)
target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared)

add_dependencies(tarsservant_shared COPY-SERVENT-TARS)
install(TARGETS tarsservant_shared
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (WIN32)
install(FILES $<TARGET_PDB_FILE:tarsservant_shared> DESTINATION bin)
endif()
13 changes: 11 additions & 2 deletions tools/tarsparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ foreach(LEC_YACC_SRC ${DEPENDS_LEC_YACC_SRC_LIST})

endforeach()

add_library(${TARGETNAME} ${DIR_SRCS} ${DEPENDS_SRC_LIST})
add_library(${TARGETNAME} STATIC ${DIR_SRCS} ${DEPENDS_SRC_LIST})
add_library(${TARGETNAME}_shared SHARED ${DIR_SRCS} ${DEPENDS_SRC_LIST})

if(UNIX)
add_dependencies(${TARGETNAME} COPY-LEX-YACC)
endif(UNIX)

install(TARGETS tarsparse
install(TARGETS ${TARGETNAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(TARGETS ${TARGETNAME}_shared
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

if (WIN32)
install(FILES $<TARGET_PDB_FILE:tarsparse_shared> DESTINATION bin)
endif()

FILE(GLOB HEADERS "*.h")
install(FILES ${HEADERS} DESTINATION include/tarsparse)
24 changes: 23 additions & 1 deletion util/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,35 @@ message("----------------------------------------------------")
list(APPEND DIR_SRCS ${JUMP_SRC})
list(APPEND DIR_SRCS ${MAKE_SRC})

add_library(tarsutil ${DIR_SRCS})
add_library(tarsutil STATIC ${DIR_SRCS})
add_library(tarsutil_shared SHARED ${DIR_SRCS})
add_dependencies(tarsutil thirdparty)

target_link_libraries(tarsutil_shared mysqlclient)
target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT)

if (TARS_SSL)
if (WIN32)
#windows动态编译需添加依赖库
target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32)
#else ()
#linux动态编译未验证,暂时屏蔽
#target_link_libraries(${LIB_TAF_UTIL} ${LIB_SSL}.a ${LIB_CRYPTO}.a)
endif ()
endif()
add_dependencies(tarsutil_shared thirdparty)

install(TARGETS tarsutil
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(TARGETS tarsutil_shared
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (WIN32)
install(FILES $<TARGET_PDB_FILE:tarsutil_shared> DESTINATION bin)
endif()

IF(WIN32)
install(DIRECTORY epoll_windows/sys
DESTINATION include)
Expand Down

0 comments on commit 1ffec75

Please sign in to comment.