diff --git a/client/SDL/common/res/CMakeLists.txt b/client/SDL/common/res/CMakeLists.txt index fe5a54887..cf5ad4cf1 100644 --- a/client/SDL/common/res/CMakeLists.txt +++ b/client/SDL/common/res/CMakeLists.txt @@ -106,10 +106,16 @@ if (SDL_USE_COMPILED_RESOURCES) endforeach() write_file(${FINIT} "}" APPEND) else() - set(SDL_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/FreeRDP) - if (WITH_BINARY_VERSIONING) - string(APPEND SDL_RESOURCE_ROOT "${PROJECT_VERSION_MAJOR}") - endif() + option(SDL_USE_VENDOR_PRODUCT_CONFIG_DIR "Use / path for resources" OFF) + set(SDL_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}) + if (SDL_USE_VENDOR_PRODUCT_CONFIG_DIR) + string(APPEND SDL_RESOURCE_ROOT "/${VENDOR}") + endif() + string(APPEND SDL_RESOURCE_ROOT "/${PRODUCT}") + + if (WITH_BINARY_VERSIONING) + string(APPEND SDL_RESOURCE_ROOT "${FREERDP_VERSION_MAJOR}") + endif() add_definitions(-DSDL_RESOURCE_ROOT="${SDL_RESOURCE_ROOT}") diff --git a/cmake/CommonConfigOptions.cmake b/cmake/CommonConfigOptions.cmake index 523b87bea..25ae9c060 100644 --- a/cmake/CommonConfigOptions.cmake +++ b/cmake/CommonConfigOptions.cmake @@ -3,6 +3,7 @@ option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON) option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON) option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON) option(WITH_BINARY_VERSIONING "Use binary versioning" OFF) +option(WITH_RESOURCE_VERSIONING "Use resource versioning" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" ON) # We want to control the winpr assert for the whole project diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index c3a08bf9f..b6be5d9fe 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -18,6 +18,17 @@ set(MODULE_NAME "freerdp") set(MODULE_PREFIX "FREERDP") +option(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR "Use / path for resources" OFF) +set(FREERDP_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}) +if (FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR) + string(APPEND FREERDP_RESOURCE_ROOT "/${VENDOR}") +endif() +string(APPEND FREERDP_RESOURCE_ROOT "/${PRODUCT}") + +if (WITH_RESOURCE_VERSIONING) + string(APPEND FREERDP_RESOURCE_ROOT "${FREERDP_VERSION_MAJOR}") +endif() + # CMake modules includes include(FindCairo) @@ -198,6 +209,13 @@ endif() AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" LIBFREERDP_SRCS) +if (WITH_RESOURCE_VERSIONING) + target_compile_definitions(${MODULE_NAME} PRIVATE -DWITH_RESOURCE_VERSIONING) +endif() +if (FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR) + target_compile_definitions(${MODULE_NAME} PRIVATE -DFREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR) +endif() + add_definitions(${LIBFREERDP_DEFINITIONS}) if (LIBFREERDP_COMPILE_OPTIONS) diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index 60acbbd6a..916b619aa 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -45,8 +45,7 @@ set(APPLE_SRCS include(CMakeDependentOption) cmake_dependent_option(WITH_KEYBOARD_LAYOUT_FROM_FILE "Use keyboard definitions from JSON file" OFF WITH_WINPR_JSON OFF) if (WITH_KEYBOARD_LAYOUT_FROM_FILE) - set(FREERDP_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/${PRODUCT}) - freerdp_definition_add(-DFREERDP_RESOURCE_ROOT="${FREERDP_RESOURCE_ROOT}") + freerdp_definition_add(-DFREERDP_RESOURCE_ROOT="${FREERDP_RESOURCE_ROOT}") freerdp_definition_add(-DWITH_KEYBOARD_LAYOUT_FROM_FILE) install(FILES KeyboardLayoutMap.json DESTINATION ${FREERDP_RESOURCE_ROOT}) diff --git a/libfreerdp/utils/helpers.c b/libfreerdp/utils/helpers.c index 34bfde71d..de0c762cd 100644 --- a/libfreerdp/utils/helpers.c +++ b/libfreerdp/utils/helpers.c @@ -21,17 +21,30 @@ #include #include +#include #include +#define STR(x) #x + char* freerdp_GetConfigFilePath(BOOL system, const char* filename) { eKnownPathTypes id = system ? KNOWN_PATH_SYSTEM_CONFIG_HOME : KNOWN_PATH_XDG_CONFIG_HOME; +#if defined(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR) char* vendor = GetKnownSubPath(id, FREERDP_VENDOR_STRING); +#else + char* vendor = GetKnownPath(id); +#endif if (!vendor) return NULL; - char* base = GetCombinedPath(vendor, FREERDP_PRODUCT_STRING); +#if defined(WITH_RESOURCE_VERSIONING) + char* verstr = FREERDP_PRODUCT_STRING STR(FREERDP_VERSION_MAJOR); +#else + char* verstr = FREERDP_PRODUCT_STRING; +#endif + + char* base = GetCombinedPath(vendor, verstr); free(vendor); if (!base) diff --git a/server/Sample/CMakeLists.txt b/server/Sample/CMakeLists.txt index 9a59d8bff..34f25b228 100644 --- a/server/Sample/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -32,11 +32,17 @@ if (CHANNEL_AINPUT_SERVER) list(APPEND SRCS sf_ainput.c sf_ainput.h) endif() -if (WITH_BINARY_VERSIONING) - set(SAMPLE_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/FreeRDP${FREERDP_VERSION_MAJOR}/images) -else() - set(SAMPLE_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/FreeRDP/images) +option(SAMPLE_USE_VENDOR_PRODUCT_CONFIG_DIR "Use / path for resources" OFF) +set(SAMPLE_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}) +if (SAMPLE_USE_VENDOR_PRODUCT_CONFIG_DIR) + string(APPEND SAMPLE_RESOURCE_ROOT "/${VENDOR}") endif() +string(APPEND SAMPLE_RESOURCE_ROOT "/${PRODUCT}") + +if (WITH_RESOURCE_VERSIONING) + string(APPEND SAMPLE_RESOURCE_ROOT "${FREERDP_VERSION_MAJOR}") +endif() +string(APPEND SAMPLE_RESOURCE_ROOT "/images") set(SAMPLE_ICONS test_icon.bmp diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 98aa46c31..6bdff7cf2 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -87,6 +87,8 @@ option(WITH_INTERNAL_RC4 "Use compiled in rc4 functions instead of OpenSSL/MBedT option(WITH_INTERNAL_MD4 "Use compiled in md4 hash functions instead of OpenSSL/MBedTLS" ${WITH_INTERNAL_MD4_DEFAULT}) option(WITH_INTERNAL_MD5 "Use compiled in md5 hash functions instead of OpenSSL/MBedTLS" ${WITH_INTERNAL_MD5_DEFAULT}) option(WITH_UNICODE_BUILTIN "Use built-in Unicode conversion (don't use system-provided libraries)" OFF) +option(WINPR_USE_LEGACY_RESOURCE_DIR "use a resource directory of /WinPR instead of /" ON) +option(WINPR_USE_VENDOR_PRODUCT_CONFIG_DIR "use a configuration /// subdirectory instead of /winpr" OFF) # This option MUST be off to avoid symbol conflicts when loading an external SSPI module library option(SSPI_DLL "Define and export SSPI API symbols for usage as a Windows SSPI DLL replacement" OFF) @@ -158,6 +160,24 @@ else() set(WINPR_VERSION_FULL "${WINPR_VERSION}") endif() +set(WINPR_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}) + +# Quite the compatiblity show here (newest to oldest): +# * [/]/[] +# * [/]/WinPR[] +# * /winpr +if (WINPR_USE_LEGACY_RESOURCE_DIR) + string(APPEND WINPR_RESOURCE_ROOT "/WinPR") +else() + if (WINPR_USE_VENDOR_PRODUCT_CONFIG_DIR) + string(APPEND WINPR_RESOURCE_ROOT "/${VENDOR}/") + endif() + string(APPEND WINPR_RESOURCE_ROOT "/${PRODUCT}") + if (WITH_RESOURCE_VERSIONING) + string(APPEND WINPR_RESOURCE_ROOT "${WINPR_VERSION_MAJOR}") + endif() +endif() + include(CheckTypeSize) check_type_size(ssize_t SSIZE_T) set(WINPR_HAVE_SSIZE_T ${HAVE_SSIZE_T}) diff --git a/winpr/include/config/build-config.h.in b/winpr/include/config/build-config.h.in index 53e6d38cc..4a9bfbba1 100644 --- a/winpr/include/config/build-config.h.in +++ b/winpr/include/config/build-config.h.in @@ -20,6 +20,4 @@ #define WINPR_PROXY_PLUGINDIR "${WINPR_PROXY_PLUGINDIR}" -#cmakedefine WINPR_USE_VENDOR_PRODUCT_CONFIG_DIR - #endif /* WINPR_BUILD_CONFIG_H */ diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index 725a8227e..e9cdb7790 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -167,6 +167,13 @@ list(REMOVE_DUPLICATES WINPR_INCLUDES) AddTargetWithResourceFile(${MODULE_NAME} FALSE "${WINPR_VERSION}" WINPR_SRCS) +if (WITH_RESOURCE_VERSIONING) + target_compile_definitions(${MODULE_NAME} PRIVATE -DWITH_RESOURCE_VERSIONING) +endif() +if (WINPR_USE_VENDOR_PRODUCT_CONFIG_DIR) + target_compile_definitions(${MODULE_NAME} PRIVATE -DWINPR_USE_VENDOR_PRODUCT_CONFIG_DIR) +endif() + if (APPLE) set_target_properties(${MODULE_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE) endif() diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 8a6f39c09..cd1c8c5bb 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -17,8 +17,6 @@ winpr_module_add(path.c shell.c) -option(WINPR_USE_VENDOR_PRODUCT_CONFIG_DIR "use a configuration /// subdirectory instead of /winpr" OFF) - if (MSVC OR MINGW) winpr_library_add_public(shlwapi) endif() diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index fd8fa3440..c6929697a 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -26,6 +27,8 @@ #include #include +#define STR(x) #x + #define PATH_SLASH_CHR '/' #define PATH_SLASH_STR "/" @@ -1190,7 +1193,12 @@ char* winpr_GetConfigFilePath(BOOL system, const char* filename) char* vendor = GetKnownSubPath(id, WINPR_VENDOR_STRING); if (!vendor) return NULL; - char* base = GetCombinedPath(vendor, WINPR_PRODUCT_STRING); +#if defined(WITH_RESOURCE_VERSIONING) + const char* prod = WINPR_PRODUCT_STRING STR(WINPR_VERSION_MAJOR); +#else + const char* prod = WINPR_PRODUCT_STRING; +#endif + char* base = GetCombinedPath(vendor, prod); free(vendor); #else char* base = GetKnownSubPath(id, "winpr"); diff --git a/winpr/libwinpr/timezone/CMakeLists.txt b/winpr/libwinpr/timezone/CMakeLists.txt index 6fd3b07b2..a05ec028d 100644 --- a/winpr/libwinpr/timezone/CMakeLists.txt +++ b/winpr/libwinpr/timezone/CMakeLists.txt @@ -23,7 +23,7 @@ endif() include(CMakeDependentOption) cmake_dependent_option(WITH_TIMEZONE_FROM_FILE "Use timezone definitions from JSON file" OFF WITH_WINPR_JSON OFF) if (WITH_TIMEZONE_FROM_FILE) - set(WINPR_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/WinPR) + winpr_definition_add(-DWINPR_RESOURCE_ROOT="${WINPR_RESOURCE_ROOT}") winpr_definition_add(-DWITH_TIMEZONE_FROM_FILE)