diff --git a/CMakeLists.txt b/CMakeLists.txt index 877cfe023ae..e5cd2ee5369 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ endif() option(lto "Enables link-time optimizations for release builds" ${LTO_DEFAULT}) +# option(bundled-cwalk "Build the included version of CWalk instead of looking for one on the system." ON) + include(compiler) include(os) @@ -165,6 +167,29 @@ if(client OR server) add_subdirectory(src) endif() +# if(client OR overlay) +# if(bundled-cwalk) +# add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk" EXCLUDE_FROM_ALL) +# if(overlay-xcompile) +# # Just check for this header file while using a 32bit target as a really small and incomplete check whether g++-multilib seems to be +# # installed. If we don't find it, we can assume it's not there but if we do find it, we still don't know. Thus we still print the +# # message about the 32bit target potentially failing due to missing g++-multilib. +# CHECK_INCLUDE_FILE("sys/cdefs.h" FOUND_CDEFS "-m32") +# if(NOT FOUND_CDEFS) +# message(FATAL_ERROR "Can't find the 32bit version of sys/cdefs.h - did you install g++-multilib?") +# else() +# message(STATUS "\nIf the 32 bit overlay library fails to compile, make sure the requirements are installed (\"g++-multilib\" package on Debian-based distributions).\n") +# endif() + + +# add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk_x86" EXCLUDE_FROM_ALL) +# set_target_properties(cwalk PROPERTIES COMPILE_OPTIONS "-m32" LINK_OPTIONS "-m32") +# endif() +# else() +# find_pkg(Cwalk REQUIRED) +# endif() +# endif() + if(g15 AND WIN32) add_subdirectory("helpers/g15helper") endif() diff --git a/overlay/ipc_utils.c b/overlay/ipc_utils.c index 061d8c6e9c2..1f8c7b423a9 100644 --- a/overlay/ipc_utils.c +++ b/overlay/ipc_utils.c @@ -4,7 +4,7 @@ // Mumble source tree or at . #include "ipc_utils.h" -#include +// #include #include #ifdef _WIN32 @@ -20,6 +20,11 @@ # include #endif +// can't trust POSIX's nor Window's PATH_MAX constants +// see: https://eklitzke.org/path-max-is-tricky +// https://stackoverflow.com/a/56385296 +const int MUMBLE_MAX_PATH = 1024; + char *getRuntimePath__() { char *path = NULL; @@ -27,12 +32,14 @@ char *getRuntimePath__() { char buffer[MUMBLE_MAX_PATH]; char *xdgRuntimeDir = getenv("XDG_RUNTIME_DIR"); if (xdgRuntimeDir == NULL || !xdgRuntimeDir) { - char uid[10]; - sprintf(uid, "%d", getuid()); + // char uid[10]; + // sprintf(uid, "%d", getuid()); xdgRuntimeDir = "/run/user/"; - cwk_path_join(xdgRuntimeDir, uid, buffer, sizeof(buffer)); + // cwk_path_join(xdgRuntimeDir, uid, buffer, sizeof(buffer)); + snprintf(buffer, sizeof(buffer), "%s/%d", xdgRuntimeDir, getuid()); } - size_t path_len = cwk_path_join(xdgRuntimeDir, "mumble", buffer, sizeof(buffer)); + // size_t path_len = cwk_path_join(xdgRuntimeDir, "mumble", buffer, sizeof(buffer)); + int path_len = snprintf(buffer, sizeof(buffer), "%s/mumble", xdgRuntimeDir); // if (path_len != strlen(buffer)) // buffer is too small. Result is truncated if ((path = malloc(path_len)) == NULL) @@ -76,7 +83,8 @@ char *getAndCreateOverlayPipePath__() { #else overlapyPipeFile = "MumbleOverlayPipe"; #endif - size_t path_len = cwk_path_join(runtimePath, overlapyPipeFile, buffer, sizeof(buffer)); + // size_t path_len = cwk_path_join(runtimePath, overlapyPipeFile, buffer, sizeof(buffer)); + int path_len = snprintf(buffer, sizeof(buffer), "%s/%s", runtimePath, overlapyPipeFile); // if (path_len != strlen(path)) // path is too small. Result is truncated if ((path = malloc(path_len)) == NULL) diff --git a/overlay/ipc_utils.h b/overlay/ipc_utils.h index a303bb3f35e..2fc91d0cb33 100644 --- a/overlay/ipc_utils.h +++ b/overlay/ipc_utils.h @@ -6,11 +6,6 @@ #ifndef MUMBLE_OVERLAY_IPC_UTILS_H__ #define MUMBLE_OVERLAY_IPC_UTILS_H__ -// can't trust POSIX's nor Window's PATH_MAX constants -// see: https://eklitzke.org/path-max-is-tricky -// https://stackoverflow.com/a/56385296 -const int MUMBLE_MAX_PATH = 1024; - char *getRuntimePath__(); char *getAndCreateOverlayPipePath__(); diff --git a/overlay_gl/CMakeLists.txt b/overlay_gl/CMakeLists.txt index 9951c70c22d..63512d269db 100644 --- a/overlay_gl/CMakeLists.txt +++ b/overlay_gl/CMakeLists.txt @@ -13,7 +13,13 @@ if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STRE endif() endif() -add_library(overlay_gl SHARED "overlay.c") +set(OVERLAY_SOURCES + "${CMAKE_SOURCE_DIR}/overlay/ipc_utils.c" + "overlay.c" +) +add_library(overlay_gl SHARED ${OVERLAY_SOURCES}) + +# target_link_libraries(overlay_gl PRIVATE cwalk) set_target_properties(overlay_gl PROPERTIES @@ -37,22 +43,13 @@ if(NOT APPLE) ) if(overlay-xcompile) - # Just check for this header file while using a 32bit target as a really small and incomplete check whether g++-multilib seems to be - # installed. If we don't find it, we can assume it's not there but if we do find it, we still don't know. Thus we still print the - # message about the 32bit target potentially failing due to missing g++-multilib. - CHECK_INCLUDE_FILE("sys/cdefs.h" FOUND_CDEFS "-m32") - if(NOT FOUND_CDEFS) - message(FATAL_ERROR "Can't find the 32bit version of sys/cdefs.h - did you install g++-multilib?") - else() - message(STATUS "\nIf the 32 bit overlay library fails to compile, make sure the requirements are installed (\"g++-multilib\" package on Debian-based distributions).\n") - endif() - set_target_properties(overlay_gl PROPERTIES OUTPUT_NAME "mumbleoverlay.x86_64" ) - add_library(overlay_gl_x86 SHARED "overlay.c") + add_library(overlay_gl_x86 SHARED ${OVERLAY_SOURCES}) + # target_link_libraries(overlay_gl_x86 PRIVATE cwalk) target_compile_definitions(overlay_gl_x86 PRIVATE @@ -77,6 +74,7 @@ if(NOT APPLE) set_target_properties(overlay_gl_x86 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + # LINK_FLAGS -m32 OUTPUT_NAME "mumbleoverlay.x86" VERSION ${CMAKE_PROJECT_VERSION} ) diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index 88001dd213a..5b62e71458f 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -26,7 +26,6 @@ option(bundled-speex "Build the included version of Speex instead of looking for option(rnnoise "Use RNNoise for machine learning noise reduction." ON) option(bundled-rnnoise "Build the included version of RNNoise instead of looking for one on the system." ${rnnoise}) option(bundled-json "Build the included version of nlohmann_json instead of looking for one on the system" ON) -option(bundled-cwalk "Build the included version of CWalk instead of looking for one on the system." ON) option(manual-plugin "Include the built-in \"manual\" positional audio plugin." ON) @@ -513,15 +512,7 @@ else() find_pkg("nlohmann_json" REQUIRED) endif() -if(bundled-cwalk) - add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk" EXCLUDE_FROM_ALL) - target_link_libraries(mumble_client_object_lib PUBLIC cwalk) - install_library(cwalk mumble_client) -else() - find_pkg(Cwalk REQUIRED) - target_link_libraries(mumble_client_object_lib PUBLIC cwalk) -endif() - +# target_link_libraries(mumble_client_object_lib PUBLIC cwalk) target_link_libraries(mumble_client_object_lib PUBLIC nlohmann_json::nlohmann_json) find_pkg("SndFile;LibSndFile;sndfile" REQUIRED)