Skip to content

Commit

Permalink
fix windows enableshard and ssl compiler error
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Oct 27, 2024
1 parent b4c09dc commit 26d99a8
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 31 deletions.
4 changes: 0 additions & 4 deletions cmake/BuildTarsCpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ macro(build_tars_server MODULE DEPS)
target_link_libraries(${MODULE} ${LIB_HTTP2} ${LIB_PROTOBUF})
endif()

# if(TARS_GPERF)
# target_link_libraries(${MODULE} ${LIB_GPERF})
# endif(TARS_GPERF)

SET(MODULE-TGZ "${CMAKE_BINARY_DIR}/${MODULE}.tgz")
SET(RUN_DEPLOY_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-deploy-${MODULE}.cmake")
FILE(WRITE ${RUN_DEPLOY_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/deploy/${MODULE})\n")
Expand Down
8 changes: 6 additions & 2 deletions cmake/Thirdparty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ if (TARS_GZIP)
link_directories(${GZIP_DIR_LIB})

if (WIN32)
set(LIB_GZIP "libz")
set(LIB_GZIP "zlib")

ExternalProject_Add(ADD_${LIB_GZIP}
URL http://cdn.tarsyun.com/src/zlib-1.2.11.tar.gz
Expand Down Expand Up @@ -302,7 +302,11 @@ if (TARS_HTTP2)
link_directories(${NGHTTP2_DIR_LIB})
link_directories(${NGHTTP2_DIR_LIB64})

set(LIB_HTTP2 "nghttp2_static")
if(ENABLE_SHARED)
set(LIB_HTTP2 "nghttp2")
else()
set(LIB_HTTP2 "nghttp2_static")
endif()

if (WIN32)
ExternalProject_Add(ADD_${LIB_HTTP2}
Expand Down
20 changes: 10 additions & 10 deletions mock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h")

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

if(ENABLE_SHARED)
add_library(tarsmock_shared SHARED ${SRC_FILES})
target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL)
target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared)
add_dependencies(tarsmock_shared tarsservant_shared)
# if(ENABLE_SHARED)
# add_library(tarsmock_shared SHARED ${SRC_FILES})
# target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL)
# target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared)
# add_dependencies(tarsmock_shared tarsservant_shared)

install(TARGETS tarsmock_shared 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()
# if (WIN32)
# install(FILES $<TARGET_PDB_FILE:tarsmock_shared> DESTINATION bin)
# endif()

endif()
# endif()
8 changes: 4 additions & 4 deletions mock/DbHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

static ObjectsCache _objectsCache;

CDbHandle::SetDivisionCache CDbHandle::_setDivisionCache;
std::map<int, CDbHandle::GroupPriorityEntry> CDbHandle::_mapGroupPriority;
std::mutex CDbHandle::_mutex;
static CDbHandle::SetDivisionCache _setDivisionCache;
static std::map<int, CDbHandle::GroupPriorityEntry> _mapGroupPriority;
static std::mutex _mutex;

//key-ip, value-组编号
map<string, int> CDbHandle::_groupIdMap;
map<string, int> _groupIdMap;
//key-group_name, value-组编号
//map<string, int> CDbHandle::_groupNameMap;

Expand Down
18 changes: 9 additions & 9 deletions mock/DbHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef map<string, ObjectItem> ObjectsCache;
*/
class UTIL_DLL_API CDbHandle
{
private:
public:
struct GroupPriorityEntry
{
std::string sGroupID;
Expand Down Expand Up @@ -199,14 +199,14 @@ class UTIL_DLL_API CDbHandle

vector<EndpointF> getEpsByGroupId(const vector<EndpointF> & vecEps, const GroupUseSelect GroupSelect, const set<int> & setGroupID, ostringstream & os);

protected:
// protected:

static std::mutex _mutex;
//set划分缓存
static SetDivisionCache _setDivisionCache;
//优先级的序列
static std::map<int, GroupPriorityEntry> _mapGroupPriority;
//分组信息
static map<string,int> _groupIdMap;
// UTIL_DLL_API static std::mutex _mutex;
// //set划分缓存
// UTIL_DLL_API static SetDivisionCache _setDivisionCache;
// //优先级的序列
// UTIL_DLL_API static std::map<int, GroupPriorityEntry> _mapGroupPriority;
// //分组信息
// UTIL_DLL_API static map<string,int> _groupIdMap;
};

11 changes: 10 additions & 1 deletion servant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ macro(complice_tars OUT_DEPENDS_LIST HEADER INCLUDE)
set(TARS_IN ${FILE})
set(TARS_H ${NAME_WE}.h)

if(ENABLE_SHARED AND TARS_SSL)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS tars2cpp ${FILE}
COMMAND ${CMAKE_COMMAND} -E env PATH=${CMAKE_BINARY_DIR}/src/openssl/bin/ ${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}
COMMENT "${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}")
else()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS tars2cpp ${FILE}
COMMAND ${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}
COMMENT "${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}")

endif()

list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H})

#设置需要清除的文件
Expand Down
3 changes: 3 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function(tars2language TARGET)

target_link_libraries(${TARGET} tarsutil tarsparse)

if(TARS_SSL AND ENABLE_SHARED)
target_link_libraries(${TARGET} ${LIB_SSL} ${LIB_CRYPTO})
endif()
install(TARGETS ${TARGET}
RUNTIME DESTINATION tools)
endfunction()
Expand Down
5 changes: 4 additions & 1 deletion util/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ if(ENABLE_SHARED)
endif()

if(TARS_HTTP2)
target_link_libraries(tarsutil_shared nghttp2)
target_link_libraries(tarsutil_shared nghttp2)
endif()
if(TARS_GZIP)
target_link_libraries(tarsutil_shared ${LIB_GZIP})
endif()
add_dependencies(tarsutil_shared thirdparty)

install(TARGETS tarsutil_shared
Expand Down

0 comments on commit 26d99a8

Please sign in to comment.