Skip to content

Commit

Permalink
fix sdk build
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Sep 10, 2024
1 parent 92a8a5e commit 8a6dcc7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion c-api/Log.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <sstream>
#include "../cpp-sdk/ICore.h"
#include "cpp-sdk/ICore.h"

namespace cs {
class Log
Expand Down
36 changes: 31 additions & 5 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,55 @@ set(CSHARP_MODULE_DEFS
# -DDEBUG_CLIENT
)

# cpp-sdk
if(NOT ALTV_CSHARP_CPP_SDK)
set(ALTV_CSHARP_CPP_SDK ../)
else()
set(ALTV_CSHARP_DEINIT_CPPSDK 1)
endif()

file(GLOB_RECURSE PROJECT_SOURCE_FILES "src/*.h" "src/*.cpp")
file(GLOB_RECURSE CAPI_FILES "../c-api/*.h" "../c-api/*.cpp")

if(WIN32 AND (MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_definitions(/MP)
endif()

if(DYNAMIC_BUILD)
set(SDK_PROJECT_NAME csharp-alt-sdk)
include(../cpp-sdk/CMakeLists.txt)
set(SDK_PROJECT_NAME alt-sdk-csharp)
if(NOT TARGET ${SDK_PROJECT_NAME})
include(${ALTV_CSHARP_CPP_SDK}/cpp-sdk/CMakeLists.txt)
endif()

if(DYNAMIC_BUILD)
add_library(${TARGET_NAME} SHARED "${PROJECT_SOURCE_FILES}" "${CAPI_FILES}")
target_compile_definitions(${PROJECT_NAME} PRIVATE
${CSHARP_MODULE_DEFS}
-DALTV_CSHARP_SHARED
)
include_directories(${TARGET_NAME} PRIVATE "src" "thirdparty" "..")
add_dependencies(${TARGET_NAME} csharp-alt-sdk)
else()
add_library(${TARGET_NAME}-static STATIC "${PROJECT_SOURCE_FILES}" "${CAPI_FILES}")
target_compile_definitions(${PROJECT_NAME}-static PRIVATE
${CSHARP_MODULE_DEFS}
)
include_directories(${TARGET_NAME}-static PRIVATE "src" "thirdparty" ${ALTV_CSHARP_CPP_SDK})
# add_dependencies(${TARGET_NAME}-static csharp-alt-sdk)
endif()


if(ALTV_CSHARP_DEINIT_CPPSDK)
if(CMAKE_HOST_WIN32)
add_custom_command(TARGET ${PROJECT_NAME}-static
PRE_BUILD
COMMAND cmd /C "tools\\deinit-cppsdk.bat"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
else()
if(EXISTS "../cpp-sdk/SDK.h")
add_custom_command(TARGET ${PROJECT_NAME}-static
PRE_BUILD
COMMAND "git submodule deinit -f ../cpp-sdk"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endif()
endif()
endif()
6 changes: 6 additions & 0 deletions client/tools/deinit-cppsdk.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off

if EXIST ../cpp-sdk/SDK.h (
echo alt:V C# - Using external cpp-sdk, deiniting local cpp-sdk
git submodule deinit -f ../cpp-sdk
)

0 comments on commit 8a6dcc7

Please sign in to comment.