Skip to content

Commit

Permalink
Merge pull request #75 from orbitersim/trigger_sound_build_cmake
Browse files Browse the repository at this point in the history
Trigger_sound_build_cmake branch
  • Loading branch information
mschweiger authored Aug 10, 2021
2 parents d9a448f + e3fff10 commit 84807e6
Show file tree
Hide file tree
Showing 19 changed files with 692 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Sound/XRSound/**/Debug/
Sound/XRSound/**/Release/
Sound/XRSound/**/x64/
Sound/XRSound/**/dist/
Sound/XRSound/**/Debug-with-OrbiterRelease/
Sound/XRSound/**/Release-with-OrbiterRelease/
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ project (Orbiter VERSION 21.7.24)
# Allow building targets as external projects
include(ExternalProject)

# Some functions to simplify debugging CMake scripts
include(CMakePrintHelpers)

# Support for including runtime libraries in packages
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
Expand All @@ -22,9 +25,11 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit build?
set(BUILD64 1)
set(ARCH "x64")
set(PLATFORM_STRING "x64")
else()
set(BUILD64 0)
set(ARCH "x86")
set(PLATFORM_STRING "Win32")
endif()

# Define directories and file paths for some common binaries
Expand Down Expand Up @@ -233,6 +238,12 @@ endif()
# ON
#)

option(
ORBITER_BUILD_XRSOUND
"Build XRSound module to enable sound in Orbiter"
ON
)

option(ORBITER_MAKE_DOC
"Create documentation"
OFF
Expand All @@ -243,6 +254,15 @@ option(ORBITER_MAKE_SDK_SAMPLES
OFF
)

if(ORBITER_BUILD_XRSOUND)
set(IRRKLANG_DIR
irrKlang_NOTFOUND
CACHE
PATH
"Root folder of irrKlang installation."
)
endif()

if (ORBITER_MAKE_DOC)

find_program(ODT_TO_PDF_COMPILER
Expand Down Expand Up @@ -368,6 +388,7 @@ add_subdirectory(Src)
add_subdirectory(Utils)
add_subdirectory(Orbitersdk)
add_subdirectory(OVP)
add_subdirectory(Sound)

if(ORBITER_MAKE_DOC)
add_subdirectory(Doc)
Expand Down
Binary file modified Doc/Credit.doc
Binary file not shown.
5 changes: 5 additions & 0 deletions Sound/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(ORBITER_BUILD_XRSOUND)

add_subdirectory(XRSound)

endif()
55 changes: 55 additions & 0 deletions Sound/XRSound/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# The irrKlang library location
if (BUILD64)
set(IRRKLANG_LIB_DIR "${IRRKLANG_DIR}/lib/Winx64-visualStudio")
set(IRRKLANG_BIN_DIR "${IRRKLANG_DIR}/bin/Winx64-visualStudio")
else()
set(IRRKLANG_LIB_DIR "${IRRKLANG_DIR}/lib/Win32-visualStudio")
set(IRRKLANG_BIN_DIR "${IRRKLANG_DIR}/bin/Win32-visualStudio")
endif()
set(IRRKLANG_LIB "${IRRKLANG_LIB_DIR}/irrKlang.lib")

if(EXISTS ${IRRKLANG_LIB})

set(ASSET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/XRSound/assets)
set(SOLUTION_DIR ${CMAKE_CURRENT_SOURCE_DIR}/XRSound/src)
set(IRRKLANG_DLL_DIR ${IRRKLANG_DIR})
# Deploy assets
file(GLOB config_files ${ASSET_DIR}/XRSound/*.cfg)

add_custom_target(XRSound_assets ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${ORBITER_BINARY_ROOT_DIR}/Doc
COMMAND ${CMAKE_COMMAND} -E make_directory ${ORBITER_BINARY_ROOT_DIR}/XRSound
COMMAND ${CMAKE_COMMAND} -E make_directory ${ORBITER_BINARY_SDK_DIR}/XRSound/
COMMAND ${CMAKE_COMMAND} -E copy ${config_files} ${ORBITER_BINARY_ROOT_DIR}/XRSound/
COMMAND ${CMAKE_COMMAND} -E copy ${ASSET_DIR}/XRSound/ReadMe.txt ${ORBITER_BINARY_ROOT_DIR}/XRSound/
COMMAND ${CMAKE_COMMAND} -E copy "${ASSET_DIR}/Doc/XRSound User Manual.pdf" ${ORBITER_BINARY_ROOT_DIR}/Doc/
COMMAND ${CMAKE_COMMAND} -E copy ${SOLUTION_DIR}/XRSoundLib/XRSound.h ${ORBITER_BINARY_SDK_DIR}/XRSound/
COMMAND ${CMAKE_COMMAND} -E copy ${IRRKLANG_BIN_DIR}/ikpMP3.dll ${ORBITER_BINARY_ROOT_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${IRRKLANG_BIN_DIR}/ikpFlac.dll ${ORBITER_BINARY_ROOT_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${IRRKLANG_BIN_DIR}/irrKlang.dll ${ORBITER_BINARY_ROOT_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${ASSET_DIR}/XRSound/Default ${ORBITER_BINARY_ROOT_DIR}/XRSound/Default
)

install(DIRECTORY ${ORBITER_BINARY_ROOT_DIR}/XRSound
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}
)
install(DIRECTORY ${ORBITER_BINARY_SDK_DIR}/XRSound
DESTINATION ${ORBITER_INSTALL_SDK_DIR}
)
install(DIRECTORY ${ORBITER_BINARY_ROOT_DIR}/XRSound/Default
DESTINATION ${ORBITER_BINARY_ROOT_DIR}/XRSound
)
install(FILES "${ORBITER_BINARY_ROOT_DIR}/Doc/XRSound User Manual.pdf"
DESTINATION ${ORBITER_INSTALL_DOC_DIR}/
)
install(FILES ${ORBITER_BINARY_ROOT_DIR}/ikpMP3.dll ${ORBITER_BINARY_ROOT_DIR}/ikpFlac.dll ${ORBITER_BINARY_ROOT_DIR}/irrKlang.dll
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/
)

add_subdirectory(XRSound)

else()

message(WARNING "irrKlang libraries not found: not building XRSound module.")

endif()
35 changes: 35 additions & 0 deletions Sound/XRSound/XRSound-lib-linktest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# XRSound-lib-linktest
This simple DLL solution is only so we can easily test the `XRSound.lib` and `XRSoundD.lib` build artifacts generated by the Orbiter CMake project. The .h and .lib include paths are all relative, so this project should be able to build successfully with no additional configuration, provided you did not move the project folder. No build artifacts from this project should be released for end users.

## Building this test app to verify the Orbiter CMake XRSound.lib and XRSoundD.lib build artifacts

Before attempting to build this test app, first build all four Orbiter build configurations using CMake:
* `x86-Debug`
* `x86-Release`
* `x64-Debug`
* `x64-Release`

Then open `XRSound-lib-linktest.sln`. You can test either one specific build target (see table below) by building and linking that configuration, or test all of them at once with `Build -> Batch Build -> click Select All -> Click Rebuild`.

In each of the `orbiter\out\build\*\Orbitersdk\XRSound\` folders created by Orbiter's CMake project, `XRSound.lib` should be a `Release` build and `XRSoundD.lib` should be a Debug build. This means there are a total of eight build combinations to test; this linktest project tests them all by creating a DLL compiled and linked with each of the following configurations:


|XRSoundLib-linktest Project Configuration |XRSoundLib-linktest Platform|...tests this generated XRSound lib file|
|----------------------------------------|:----------------------------:|----------------------------------------|
|Debug-with-OrbiterDebug|x86|orbiter\out\build\x86-Debug\Orbitersdk\XRSound\XRSoundD.lib|
|Release-with-OrbiterDebug|x86|orbiter\out\build\x86-Debug\Orbitersdk\XRSound\XRSound.lib|
|Debug-with-OrbiterRelease|x86|orbiter\out\build\x86-Release\Orbitersdk\XRSound\XRSoundD.lib|
|Release-with-OrbiterRelease|x86|orbiter\out\build\x86-Release\Orbitersdk\XRSound\XRSound.lib|
|Debug-with-OrbiterDebug|x64|orbiter\out\build\x64-Debug\Orbitersdk\XRSound\XRSoundD.lib|
|Release-with-OrbiterDebug|x64|orbiter\out\build\x64-Debug\Orbitersdk\XRSound\XRSound.lib|
|Debug-with-OrbiterRelease|x64|orbiter\out\build\x64-Release\Orbitersdk\XRSound\XRSoundD.lib|
|Release-with-OrbiterRelease|x64|orbiter\out\build\x64-Release\Orbitersdk\XRSound\XRSound.lib|

Note: it is not strictly necessary for all eight combinations to link successfully, since only the `OrbiterRelease x86` and `OrbiterRelease x64` build artifacts will ever be packaged up and released for end users. Therefore, only those these four build targets need to pass:

* Debug-with-OrbiterRelease x86
* Release-with-OrbiterRelease x86
* Debug-with-OrbiterRelease x64
* Release-with-OrbiterRelease x64

Having the the other four build configurations work as well would just a matter of convenience for developers linking with XRSound as they work in the Orbiter project tree, but it is not required.
43 changes: 43 additions & 0 deletions Sound/XRSound/XRSound-lib-linktest/XRSound-lib-linktest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XRSound-lib-linktest", "XRSound-lib-linktest\XRSound-lib-linktest.vcxproj", "{F320C36A-20EE-4F7D-88BA-0E5F78B09263}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug-with-OrbiterDebug|x64 = Debug-with-OrbiterDebug|x64
Debug-with-OrbiterDebug|x86 = Debug-with-OrbiterDebug|x86
Debug-with-OrbiterRelease|x64 = Debug-with-OrbiterRelease|x64
Debug-with-OrbiterRelease|x86 = Debug-with-OrbiterRelease|x86
Release-with-OrbiterDebug|x64 = Release-with-OrbiterDebug|x64
Release-with-OrbiterDebug|x86 = Release-with-OrbiterDebug|x86
Release-with-OrbiterRelease|x64 = Release-with-OrbiterRelease|x64
Release-with-OrbiterRelease|x86 = Release-with-OrbiterRelease|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterDebug|x64.ActiveCfg = Debug|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterDebug|x64.Build.0 = Debug|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterDebug|x86.ActiveCfg = Debug|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterDebug|x86.Build.0 = Debug|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterRelease|x64.ActiveCfg = Debug-with-OrbiterRelease|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterRelease|x64.Build.0 = Debug-with-OrbiterRelease|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterRelease|x86.ActiveCfg = Debug-with-OrbiterRelease|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Debug-with-OrbiterRelease|x86.Build.0 = Debug-with-OrbiterRelease|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterDebug|x64.ActiveCfg = Release|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterDebug|x64.Build.0 = Release|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterDebug|x86.ActiveCfg = Release|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterDebug|x86.Build.0 = Release|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterRelease|x64.ActiveCfg = Release-with-OrbiterRelease|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterRelease|x64.Build.0 = Release-with-OrbiterRelease|x64
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterRelease|x86.ActiveCfg = Release-with-OrbiterRelease|Win32
{F320C36A-20EE-4F7D-88BA-0E5F78B09263}.Release-with-OrbiterRelease|x86.Build.0 = Release-with-OrbiterRelease|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {235177CC-EFE7-4266-B425-2B6FE33C2266}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 84807e6

Please sign in to comment.