Skip to content

Commit

Permalink
Upgrade dependencies and make the plugin compile
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmacha committed May 10, 2024
1 parent 3bd3c4c commit 0a0eb25
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.25)
set(PROJECT_VERSION "0.0.20")
if(DEFINED ENV{PROJECT_VERSION})
set(PROJECT_VERSION "$ENV{PROJECT_VERSION}")
endif()
project(zBassMusic VERSION ${PROJECT_VERSION})
project(zBassMusic VERSION "0.0.20")

option(BUILD_VDF "Build .VDF file with plugin" ON)

Expand Down
16 changes: 7 additions & 9 deletions cmake/gothic-api.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
set(GOTHIC_API_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/gothic-api-working-dir")

file(MAKE_DIRECTORY ${GOTHIC_API_WORKING_DIR})
file(COPY "${GOTHIC_API_DIR}/" DESTINATION ${GOTHIC_API_WORKING_DIR})
file(COPY "${GOTHIC_USERAPI_DIR}/" DESTINATION "${GOTHIC_API_WORKING_DIR}/ZenGin/Gothic_UserAPI")

add_library(gothic-api INTERFACE IMPORTED)
target_include_directories(gothic-api INTERFACE "${GOTHIC_API_WORKING_DIR}")
target_link_directories(gothic-api INTERFACE "${GOTHIC_API_WORKING_DIR}")
target_sources(gothic-api INTERFACE "${GOTHIC_API_WORKING_DIR}/ZenGin/zGothicAPI.cpp")
target_include_directories(gothic-api INTERFACE
"${GOTHIC_USERAPI_DIR}"
"${GOTHIC_API_DIR}"
"${GOTHIC_API_DIR}/ZenGin/Gothic_UserAPI"
)
target_link_directories(gothic-api INTERFACE "${GOTHIC_API_DIR}")
target_sources(gothic-api INTERFACE "${GOTHIC_API_DIR}/ZenGin/zGothicAPI.cpp")
6 changes: 3 additions & 3 deletions cmake/union-api.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(union-api SHARED)
add_library(union-api STATIC)
set_target_properties(union-api PROPERTIES
OUTPUT_NAME "UnionAPI"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
Expand All @@ -12,9 +12,9 @@ file(GLOB_RECURSE UNION_SOURCES "${UNION_API_DIR}/union-api/**.cpp")
target_sources(union-api PRIVATE ${UNION_SOURCES})

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
target_compile_definitions(union-api PUBLIC WIN32 _DEBUG _CONSOLE _UNION_API_DLL PRIVATE _UNION_API_BUILD)
target_compile_definitions(union-api PUBLIC WIN32 _DEBUG _CONSOLE _UNION_API_LIB PRIVATE _UNION_API_BUILD)
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
target_compile_definitions(union-api PUBLIC WIN32 NDEBUG _CONSOLE _UNION_API_DLL PRIVATE _UNION_API_BUILD)
target_compile_definitions(union-api PUBLIC WIN32 NDEBUG _CONSOLE _UNION_API_LIB PRIVATE _UNION_API_BUILD)
else()
message(FATAL_ERROR "Invalid $CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not in range [Debug, Release]")
endif()
2 changes: 1 addition & 1 deletion dependencies/gothic-api
Submodule gothic-api updated from c8f10e to e9ca20
2 changes: 1 addition & 1 deletion dependencies/union-api
Submodule union-api updated from ad38ad to 346853
5 changes: 1 addition & 4 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/NH.ico" DESTINATION "${CMAKE_CURRENT_BINA
file(GLOB_RECURSE PLUGIN_SOURCES "src/**.cpp")
target_sources(plugin PRIVATE ${PLUGIN_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/version.rc")

target_compile_definitions(plugin PRIVATE _UNION_API_DLL __G1 __G2A)
target_compile_definitions(plugin PRIVATE _UNION_API_LIB __G1 __G2A)
target_include_directories(plugin PRIVATE "src/")
target_link_libraries(plugin PRIVATE union-api gothic-api bass)

add_custom_command(TARGET plugin PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${GOTHIC_USERAPI_DIR} "${GOTHIC_API_WORKING_DIR}/ZenGin/Gothic_UserAPI")

install(FILES $<TARGET_RUNTIME_DLLS:plugin> "${CMAKE_BINARY_DIR}/zBassMusic.dll" TYPE BIN)
install(FILES "${CMAKE_BINARY_DIR}/script.vdfs" DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(SCRIPT "${VDF_DIR}/vdf.cmake")
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/Gothic/CMusicSys_Bass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ namespace GOTHIC_NAMESPACE
{
myMusicPtr->Ready = true;

NH::Log::Info("CMusicSys_Bass", Union::StringUTF8::Format("%z ready, size ", path) + Union::StringUTF8(read));
NH::Log::Info("CMusicSys_Bass", Union::StringUTF8::Format("%z ready, size ", path.ToChar()) + Union::StringUTF8(read));
}

myMusicPtr->Loading = false;
myFile->Close();

auto loadingTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - loadingStart).count();

NH::Log::Debug("CMusicSys_Bass", Union::StringUTF8::Format("%z loading took %I ms", path, loadingTime));
NH::Log::Debug("CMusicSys_Bass", Union::StringUTF8::Format("%z loading took %I ms", path.ToChar(), loadingTime));
}, std::move(file), &musicFileRef).detach();
}
else
Expand Down
1 change: 0 additions & 1 deletion vdf/vdf.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun")
file(COPY "${CMAKE_INSTALL_PREFIX}/bin/UnionAPI.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun")
file(COPY "${CMAKE_INSTALL_PREFIX}/bin/zBassMusic.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun")
file(COPY "${CMAKE_INSTALL_PREFIX}/bin/bass.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun")

0 comments on commit 0a0eb25

Please sign in to comment.