Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup project structure for the future #22

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 56 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.25)
set(PROJECT_VERSION "0.1.3")
project(zBassMusic VERSION ${PROJECT_VERSION})
set(PROJECT_VERSION_CMAKE "${PROJECT_VERSION}")
project(zBassMusic VERSION ${PROJECT_VERSION_CMAKE})

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

Expand All @@ -20,4 +21,57 @@ include(cmake/union-api.cmake)
include(cmake/gothic-api.cmake)
include(cmake/bass.cmake)

add_subdirectory(plugin)
add_library(plugin SHARED)
set_target_properties(plugin PROPERTIES
OUTPUT_NAME "zBassMusic"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")

string(TIMESTAMP BUILD_TIME "%Y-%m-%dT%H:%M:%S")
execute_process(COMMAND git symbolic-ref --short HEAD OUTPUT_VARIABLE BUILD_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git log --format=%H -n 1 OUTPUT_VARIABLE BUILD_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${CMAKE_CURRENT_BINARY_DIR}/version.rc" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/vdf/script.vdfs.in" "${CMAKE_BINARY_DIR}/script.vdfs")
configure_file("${CMAKE_SOURCE_DIR}/src/BuildInfo.h.in" "${CMAKE_BINARY_DIR}/src/BuildInfo.h" @ONLY)

file(GLOB_RECURSE PLUGIN_SOURCES "src/**.cpp" "${UNION_API_DIR}/union-api/Union/Memory.cpp")
target_sources(plugin PRIVATE ${PLUGIN_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/version.rc")

add_compile_options(plugin PRIVATE /W4 /WX)
target_compile_definitions(plugin PRIVATE _UNION_API_DLL __G1 __G1A __G2 __G2A)
target_include_directories(plugin PRIVATE "src/" "${CMAKE_BINARY_DIR}/src/")
target_link_libraries(plugin PRIVATE union-api gothic-api bass)

install(FILES $<TARGET_RUNTIME_DLLS:plugin> "${CMAKE_BINARY_DIR}/zBassMusic.dll" TYPE BIN)
install(FILES $<TARGET_RUNTIME_DLLS:plugin> "${CMAKE_BINARY_DIR}/UnionAPI.dll" TYPE BIN)
if(${BUILD_VDF})
install(FILES "${CMAKE_BINARY_DIR}/script.vdfs" DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(SCRIPT "${VDF_DIR}/vdf.cmake")
install(CODE "execute_process(COMMAND ${CMAKE_SOURCE_DIR}/vdf/GothicVDFS.exe /B \"${CMAKE_INSTALL_PREFIX}/script.vdfs\"
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")")
endif()

if(${BUILD_VDF})
string(REPLACE "build" "install" INSTALL_DIR "${CMAKE_BINARY_DIR}")
add_custom_target(plugin_vdf ALL
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${INSTALL_DIR}
DEPENDS plugin
COMMENT "Run install to build VDF")

if(DEFINED ENV{COPY_VDF_TARGET})
add_custom_target(copy_vdf ALL
COMMAND ${CMAKE_COMMAND} -E copy "${INSTALL_DIR}/zBassMusic.vdf" "$ENV{COPY_VDF_TARGET}"
DEPENDS plugin_vdf
COMMENT "Copy plugin to target directory: $ENV{COPY_VDF_TARGET}")
endif()
endif()

if(DEFINED ENV{COPY_DLL_TARGET})
add_custom_target(copy_dll ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/zBassMusic.dll" "$ENV{COPY_DLL_TARGET}/Autorun/zBassMusic.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/UnionAPI.dll" "$ENV{COPY_DLL_TARGET}/Autorun/UnionAPI.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bass.dll" "$ENV{COPY_DLL_TARGET}/bass.dll"
DEPENDS plugin
COMMENT "Copy plugin to target directory: $ENV{COPY_DLL_TARGET}")
endif()
8 changes: 4 additions & 4 deletions cmake/union-api.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(union-api STATIC)
add_library(union-api SHARED)
set_target_properties(union-api PROPERTIES
OUTPUT_NAME "UnionAPI"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
Expand All @@ -8,13 +8,13 @@ set_target_properties(union-api PROPERTIES
target_include_directories(union-api PUBLIC "${UNION_API_DIR}/union-api")
target_link_directories(union-api PUBLIC "${UNION_API_DIR}/union-api")

file(GLOB_RECURSE UNION_SOURCES "${UNION_API_DIR}/union-api/**.cpp")
file(GLOB_RECURSE UNION_SOURCES "${UNION_API_DIR}/union-api/union-api.cpp" "${UNION_API_DIR}/union-api/Union/Memory.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_LIB PRIVATE _UNION_API_BUILD)
target_compile_definitions(union-api PUBLIC WIN32 _DEBUG _CONSOLE _UNION_API_DLL PRIVATE _UNION_API_BUILD)
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
target_compile_definitions(union-api PUBLIC WIN32 NDEBUG _CONSOLE _UNION_API_LIB PRIVATE _UNION_API_BUILD)
target_compile_definitions(union-api PUBLIC WIN32 NDEBUG _CONSOLE _UNION_API_DLL 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 docs/options.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Options reference (.ini)
# OptionsType reference (.ini)
```ini
[BASSMUSIC]

Expand Down
Empty file added gothic-userapi/.gitkeep
Empty file.
6 changes: 0 additions & 6 deletions gothic-userapi/CGameManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/TMobOptPos.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/TNpcAIState.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/TNpcPerc.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/TNpcSlot.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIArrow.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIArrowBase.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAICamera.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIDrop.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIHuman.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIHuman_Stand.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAISound.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIVobMove.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAIVobMoveTorch.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAniCtrl_Human.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAniCtrl_Human_oTComboInfo.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCAskBox.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCBarrier.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCBinkPlayer.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCCSManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCCSPlayer.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCCSProps.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCCSTrigger.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCCollObjectCharacter.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCDoc.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCDocumentManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCDummyVobGenerator.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCEmitterKey.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCGame.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCGameInfo.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCGame_TObjectRoutine.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCGuilds.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCHelp.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCHelpScreen.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCInfo.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCInfoChoice.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCInfoManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCInfo_Tpd.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCInformationManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCItem.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCItemContainer.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCItemReactModule.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCLogEntry.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCLogManager.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCLogScreen.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCLogTopic.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCMOB.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCMagFrontier.inl

This file was deleted.

5 changes: 0 additions & 5 deletions gothic-userapi/oCMag_Book.inl

This file was deleted.

Loading