Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ffcfda9
build(cmake): minimal fixes for transitive restbed headers, i2pcommon…
jolavillette May 18, 2026
5edeb5f
SAVE: Toutes les modifications courantes (Universel + Windows)
jolavillette May 19, 2026
df1642b
Fix jsonapi generator and OpenSSL macro collisions
jolavillette May 19, 2026
ef67686
Fix RNP include paths and jsonapi recompilation cache in CMake
jolavillette May 19, 2026
31efa37
Merge Windows changes: integrate WS2/IOCP linkage and dlfcn support
jolavillette May 19, 2026
39df2f2
build(cmake): support dynamic plugin linkage by exposing RNP directories
jolavillette May 19, 2026
39e4dad
Merge branch 'CMakeMigration-Modular' into CMakeMigration-Modular-Win…
jolavillette May 19, 2026
ed94151
Build: WIN32: use FetchContent restbed 4.8 with bundled ASIO instead …
jolavillette May 20, 2026
60e127e
build: encapsulate RNP and PGP dependencies as PUBLIC targets
jolavillette May 20, 2026
4ccd1b5
Merge branch 'CMakeMigration-Modular' into CMakeMigration-Modular-Win…
jolavillette May 20, 2026
c9804e8
build: use target_compile_options instead of global CMAKE_CXX_FLAGS
jolavillette May 21, 2026
7a5d75b
Merge branch 'CMakeMigration-Modular' into CMakeMigration-Modular-Win…
jolavillette May 21, 2026
ad0dcf6
build: fix deprecation warning encapsulation and set default RS_WARN_…
jolavillette May 21, 2026
0d5f63a
Merge branch 'CMakeMigration-Modular' into CMakeMigration-Modular-Win…
jolavillette May 21, 2026
dc0347b
build: disable LTO on Windows to bypass GCC 15 thunk link bug
jolavillette May 22, 2026
72041cf
cmake: configure libretroshare as DLL on Windows and restrict exporte…
jolavillette May 24, 2026
62d1c60
Merge branch 'master' into CMakeMigration-Modular
jolavillette May 24, 2026
f4434ef
Merge branch 'CMakeMigration-Modular' into CMakeMigration-Modular-Win…
jolavillette May 24, 2026
31a5b27
Merge branch 'master' into CMakeMigration-Modular-Windows
jolavillette May 25, 2026
f98b61f
CMake: Dynamically find RNP include paths to support macOS and custom…
jolavillette May 31, 2026
b61af2c
Merge branch 'master' into CMakeMigration-Modular-Windows-MacOS
jolavillette May 31, 2026
b60973c
fix(build): conditionally compile I2P SAMv3 support and link sam3 lib…
jolavillette Jun 1, 2026
e7086b2
fix(cmake): add missing target_include_directories for system rapidjson
jolavillette Jun 1, 2026
e38be45
Address PR review: link heavy cryptographic dependencies (RNP, Botan)…
jolavillette Jun 2, 2026
6a1d720
Address PR review: set RS_WARN_DEPRECATED back to ON
jolavillette Jun 2, 2026
1f54e95
tempory fixes following gio comments on github
jolavillette Jun 2, 2026
2225487
tempory fixes #2 following gio comments on github
jolavillette Jun 2, 2026
8e42c18
CMake: build librnp as a subdirectory + Windows build fixes
jolavillette Jun 3, 2026
8d09daf
fix(cmake): apply WIN32_LEAN_AND_MEAN to the static lib too and drop …
jolavillette Jun 3, 2026
29a6dd3
fix(cmake): use explicit --exclude-libs list instead of ALL on Windows
jolavillette Jun 4, 2026
b38ba51
fix(cmake): address PR review comments for Windows build
jolavillette Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 119 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ include(GNUInstallDirs)
set(FETCHCONTENT_QUIET OFF)
include(FetchContent)

if(WIN32)
# Force Unicode mappings for Windows API (fixes MoveFileEx and similar errors)
add_definitions(-DUNICODE -D_UNICODE)
endif()

option(
RS_SQLCIPHER
"SQLCipher encryption for GXS database"
Expand Down Expand Up @@ -227,8 +232,20 @@ if(RS_LIBRETROSHARE_SHARED)
## Ensure statically linked libraries such as openpgpsdk are compiled with
## PIC Which is needed for shared library
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# We must use an explicit list of heavy 3rd-party archives instead of "ALL" for --exclude-libs.
# Using "ALL" also hides symbols from CMake's internal objects.a archive (created by WINDOWS_EXPORT_ALL_SYMBOLS),
# which prevents libretroshare from exporting its own core C++ symbols, causing massive linkage errors downstream.
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--export-all-symbols,--exclude-libs,libbitdht.a:librnp.a:libsexpp.a:libudp-discovery.a:librestbed.a:libsqlcipher.a:libbotan-2.a:libbotan-3.a:libz.a:libbz2.a")
Comment thread
G10h4ck marked this conversation as resolved.
endif()
endif()
endif(RS_LIBRETROSHARE_SHARED)



if(RS_ANDROID)
# As of today Android NDK libc++ doesn't support std::filesystem properly,
# in a very confusing manner the headers have the function declarations but
Expand All @@ -245,6 +262,25 @@ else()
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
endif()

if(WIN32)
target_compile_definitions(
${PROJECT_NAME} PUBLIC
Comment thread
G10h4ck marked this conversation as resolved.
WINDOWS_SYS
# Forces the Windows API to use wide-char variants (e.g. MoveFileExW)
UNICODE
_UNICODE
# Prevents <windows.h> from pulling in <wingdi.h> which #defines ERROR
NOGDI
# Prevents <windows.h> from defining min/max macros that break std::min/max
NOMINMAX
# Prevents <windows.h> from pulling in <wincrypt.h> which shadows OpenSSL X509 types
NOCRYPT
Comment thread
G10h4ck marked this conversation as resolved.
# Prevents <windows.h> from including extra headers and polluting the namespace
WIN32_LEAN_AND_MEAN
WIN_DLL_EXPORT )
target_link_libraries(${PROJECT_NAME} PUBLIC ws2_32 winmm iphlpapi)
endif()

## As of today libretroshare doesn't hide implementation details properly so it
## is necessary to flag all implementation headers as public
target_include_directories(
Expand Down Expand Up @@ -297,21 +333,24 @@ target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
################################################################################

if(RS_RNPLIB)
# Add RNP build directories to linker search path
target_link_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../supportlibs/librnp/Build/src/lib
${CMAKE_CURRENT_BINARY_DIR}/../supportlibs/librnp/Build/src/libsexpp
)

# Link libraries by name, including RNP libs and dependencies first
# librnp
set(SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_TESTING OFF)
set(BUILD_SHARED_LIBS OFF)
set(DOWNLOAD_GTEST OFF)
set(ENABLE_DOC OFF CACHE BOOL "Disable librnp docs" FORCE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/librnp" "${CMAKE_CURRENT_BINARY_DIR}/librnp")
set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS})

target_link_libraries(${PROJECT_NAME} PRIVATE
rnp # Link by name
librnp
sexpp
)

target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/librnp/include"
"${CMAKE_CURRENT_BINARY_DIR}/../supportlibs/librnp/Build/src/lib"
"${CMAKE_CURRENT_BINARY_DIR}/librnp/src/lib"
)
else()

Expand Down Expand Up @@ -387,6 +426,9 @@ find_path(
if(EXISTS "${RS_RAPIDJSON_INCLUDE}")
message( STATUS
"RapidJSON found in system at ${RS_RAPIDJSON_INCLUDE}" )
target_include_directories(
${PROJECT_NAME}
PUBLIC "${RS_RAPIDJSON_INCLUDE}" )
elseif(EXISTS "${RAPIDJSON_DEVEL_DIR}/CMakeLists.txt")
message( STATUS
"RapidJSON found in development dir at ${RAPIDJSON_DEVEL_DIR}" )
Expand Down Expand Up @@ -430,19 +472,16 @@ if(RS_JSON_API)
JSONAPI_GENERATOR_EXECUTABLE
"${JSONAPI_GENERATOR_SOURCE_DIR}/jsonapi-generator.py" )

file(
COPY "src/jsonapi/jsonapi-generator-doxygen.conf"
DESTINATION "${JSON_API_GENERATOR_WORK_DIR}" )

file(
APPEND
"${JSON_API_GENERATOR_DOXYFILE}"
"OUTPUT_DIRECTORY=${JSONAPI_GENERATOR_OUTPUT_DIR}\n"
file(READ "src/jsonapi/jsonapi-generator-doxygen.conf" DOXYFILE_CONTENT)
string(APPEND DOXYFILE_CONTENT
"\nOUTPUT_DIRECTORY=${JSONAPI_GENERATOR_OUTPUT_DIR}\n"
"INPUT=${CMAKE_CURRENT_SOURCE_DIR}/src/\n"
"EXCLUDE="
" ${CMAKE_CURRENT_SOURCE_DIR}/src/tests"
" ${CMAKE_CURRENT_SOURCE_DIR}/src/unused"
" ${CMAKE_CURRENT_SOURCE_DIR}/src/unfinished\n" )
" ${CMAKE_CURRENT_SOURCE_DIR}/src/unfinished\n"
)
file(WRITE "${JSON_API_GENERATOR_DOXYFILE}" "${DOXYFILE_CONTENT}")

add_custom_command(
OUTPUT
Expand All @@ -465,6 +504,8 @@ if(RS_JSON_API)

set(BUILD_TESTS OFF CACHE BOOL "Do not build restbed tests")
set(BUILD_SSL OFF CACHE BOOL "Do not build restbed SSL support")
set(BUILD_SHARED_LIBRARY ${RS_LIBRETROSHARE_SHARED})
set(BUILD_SHARED_LIBS ${RS_LIBRETROSHARE_SHARED})

set(RESTBED_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/restbed/")
if(RS_ANDROID)
Expand All @@ -473,7 +514,10 @@ if(RS_JSON_API)
## should be sent upstream.
## Restbed is therefore compiled by Android toolchain preparation script
target_link_libraries(${PROJECT_NAME} PRIVATE restbed)
elseif(EXISTS "${RESTBED_DEVEL_DIR}/CMakeLists.txt")
elseif(NOT WIN32 AND EXISTS "${RESTBED_DEVEL_DIR}/CMakeLists.txt")
## On Windows, skip the local submodule: recent restbed HEAD requires
## system ASIO (not available by default on MSYS2/MinGW). Fall through
## to FetchContent which downloads restbed 4.8 with bundled ASIO.
Comment thread
G10h4ck marked this conversation as resolved.
message( STATUS
"Restbed submodule found at ${RESTBED_DEVEL_DIR} using it" )
add_subdirectory(
Expand All @@ -483,10 +527,14 @@ if(RS_JSON_API)
# EXCLUDE_FROM_ALL prevent executing install directives from included
# dependencies see https://stackoverflow.com/a/64900982

set(RESTBED_TARGET restbed-static)
if(TARGET restbed-shared AND BUILD_SHARED_LIBS)
set(RESTBED_TARGET restbed-shared)
endif()

target_include_directories(
${PROJECT_NAME} PRIVATE "${RESTBED_DEVEL_DIR}/source/" )
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/../supportlibs/restbed")
target_link_libraries(${PROJECT_NAME} PRIVATE restbed)
${PROJECT_NAME} PUBLIC "${RESTBED_DEVEL_DIR}/source/" )
target_link_libraries(${PROJECT_NAME} PRIVATE ${RESTBED_TARGET})
else()
message( WARNING
"FetchContent restbed, will be installed if you run make install")
Expand All @@ -498,13 +546,29 @@ if(RS_JSON_API)
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
TIMEOUT 10
# EXCLUDE_FROM_ALL # Available only in CMake >= 3.28
# PATCH_COMMAND applies hotfixes to restbed before building:
# 1. Removes /wd4251 (MSVC-specific flag) that breaks GCC/Clang builds.
# 2. Bumps CMake minimum version to 3.5.0 to suppress deprecation warnings in CMake >= 3.27.
PATCH_COMMAND sed -i -e "s|/wd4251||g" -e "s|VERSION 3.1.0|VERSION 3.5.0|g" CMakeLists.txt
)
FetchContent_MakeAvailable(restbed)

set(RESTBED_TARGET restbed-static)
if(TARGET restbed-shared AND BUILD_SHARED_LIBS)
set(RESTBED_TARGET restbed-shared)
endif()

target_include_directories(
${PROJECT_NAME} PRIVATE ${restbed_SOURCE_DIR}/source/ )
target_link_libraries(${PROJECT_NAME} PRIVATE restbed-static)
${PROJECT_NAME} PUBLIC ${restbed_SOURCE_DIR}/source/ )
target_link_libraries(${PROJECT_NAME} PRIVATE ${RESTBED_TARGET})
if(WIN32)
if(TARGET restbed-static)
target_link_libraries(restbed-static PUBLIC ws2_32 winmm iphlpapi mswsock)
endif()
if(TARGET restbed-shared)
target_link_libraries(restbed-shared PUBLIC ws2_32 winmm iphlpapi mswsock)
endif()
endif()
endif()


Expand Down Expand Up @@ -676,8 +740,6 @@ endif(RS_ANDROID)

################################################################################

set( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations" )
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_NO_WARN_DEPRECATED )

set(V_VERSION_SET OFF)

Expand All @@ -690,9 +752,14 @@ else()
set(V_GIT_DESCRIBE_OUTPUT "")
set(V_GIT_DESCRIBE_REGEXP "^v([0-9]+).([0-9]+).([0-9]+)(.*)\n$")

set(V_GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git")
set(V_GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
endif()

execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --long --match v*.*.*
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
WORKING_DIRECTORY "${V_GIT_DIR}"
OUTPUT_VARIABLE V_GIT_DESCRIBE_OUTPUT )

if(V_GIT_DESCRIBE_OUTPUT MATCHES "${V_GIT_DESCRIBE_REGEXP}")
Expand Down Expand Up @@ -721,6 +788,22 @@ if(V_VERSION_SET)
PUBLIC RS_EXTRA_VERSION="${RS_EXTRA_VERSION}" )
endif(V_VERSION_SET)

# Define the libretroshare specific version hash (submodule hash)
set(V_LIB_GIT_HASH "")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 --always --dirty
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE V_LIB_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE )

if(V_LIB_GIT_HASH STREQUAL "")
set(V_LIB_GIT_HASH "[version not available]")
endif()

target_compile_definitions(
${PROJECT_NAME}
PUBLIC RS_LIB_VERSION_HASH="${V_LIB_GIT_HASH}" )

################################################################################

# TODO: Use generator expressions instead of CMAKE_BUILD_TYPE see
Expand All @@ -735,7 +818,11 @@ if(RS_ANDROID AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET ${PROJECT_NAME} PROPERTY VISIBILITY_INLINES_HIDDEN ON)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
# Note: Disabling LTO (Interprocedural Optimization) on Windows is necessary for RetroShare
# because enabling it causes the MinGW linker (ld) to run out of memory or exhaust the maximum
# number of exported symbols, or emit "multiple definition" errors during LTO code generation.
# While this makes the binary fatter and slower, it prevents fatal build failures.
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT WIN32)
Comment thread
G10h4ck marked this conversation as resolved.
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
endif()

Expand All @@ -755,3 +842,7 @@ if(RS_CPPTRACE_STACKTRACE)
target_compile_definitions(
${LIBRARY_NAME} PRIVATE RS_JEREMY_RIFKIN_CPPTRACE )
endif(RS_CPPTRACE_STACKTRACE)

if(RS_USE_I2P_SAM3)
target_link_libraries(${PROJECT_NAME} PRIVATE sam3)
endif()
39 changes: 24 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,14 @@ else()
list(APPEND RS_IMPLEMENTATION_HEADERS pgp/openpgpsdkhandler.h)
endif()

#./plugins/dlfcn_win32.cc
#./plugins/dlfcn_win32.h
#./plugins/pluginmanager.h
#./plugins/rscacheservice.h
#./plugins/rspqiservice.h

if(WIN32)
list(APPEND RS_SOURCES plugins/dlfcn_win32.cc)
list(APPEND RS_IMPLEMENTATION_HEADERS plugins/dlfcn_win32.h)
endif()

list(
APPEND RS_SOURCES
plugins/pluginmanager.cc )
Expand Down Expand Up @@ -338,10 +340,14 @@ list(
pqi/pqistreamer.h
pqi/pqithreadstreamer.h
pqi/sslfns.h )

#./pqi/pqissli2psam3.cpp
#./pqi/pqissli2psam3.h

if(RS_USE_I2P_SAM3)
list(APPEND RS_SOURCES
pqi/pqissli2psam3.cpp
)
list(APPEND RS_IMPLEMENTATION_HEADERS
pqi/pqissli2psam3.h
)
endif()
list(
APPEND RS_SOURCES
rsitems/rsbanlistitems.cc
Expand Down Expand Up @@ -475,11 +481,15 @@ list(
serialiser/rstlvmaps.h
serialiser/rstlvstring.h
serialiser/rstypeserializer.h )

# ./services/autoproxy
#./services/autoproxy/p3i2psam3.cpp
#./services/autoproxy/p3i2psam3.h

if(RS_USE_I2P_SAM3)
list(APPEND RS_SOURCES
services/autoproxy/p3i2psam3.cpp
)
list(APPEND RS_IMPLEMENTATION_HEADERS
services/autoproxy/p3i2psam3.h
)
endif()
list(
APPEND RS_SOURCES
services/autoproxy/rsautoproxymonitor.cc
Expand Down Expand Up @@ -617,13 +627,12 @@ list(
util/rsnet.cc
util/rsnet_ss.cc
util/rsstacktrace.cc
util/rsthreads.cc )

# util/i2pcommon.cpp
# util/i2pcommon.h
util/rsthreads.cc
util/i2pcommon.cpp )

list(
APPEND RS_IMPLEMENTATION_HEADERS
util/i2pcommon.h
util/argstream.h
util/contentvalue.h
util/cxx11retrocompat.h
Expand Down
20 changes: 11 additions & 9 deletions src/jsonapi/jsonapi-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,17 @@ def processFile(file):
orderedParamNames.append(pName)

for tmpPN in memberdef.findall('.//parametername'):
tmpParam = paramsMap[tmpPN.text]
tmpD = tmpPN.attrib['direction'] if 'direction' in tmpPN.attrib else ''

if 'in' in tmpD:
tmpParam._in = True
hasInput = True
if 'out' in tmpD:
tmpParam._out = True
hasOutput = True
pName = getText(tmpPN)
if pName in paramsMap:
tmpParam = paramsMap[pName]
tmpD = tmpPN.attrib['direction'] if 'direction' in tmpPN.attrib else ''

if 'in' in tmpD:
tmpParam._in = True
hasInput = True
if 'out' in tmpD:
tmpParam._out = True
hasOutput = True

# Params sanity check
for pmKey in paramsMap:
Expand Down
6 changes: 5 additions & 1 deletion src/pqi/sslfns.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* libretroshare/src/pqi: sslfns.h *
* *
* libretroshare: retroshare core library *
Expand Down Expand Up @@ -28,6 +28,10 @@

/******************** notify of new Cert **************************/

/* OpenSSL's X509_NAME and X509_EXTENSIONS types collide with macros of the
* same name defined by Windows' <wincrypt.h>. We rely on WIN32_LEAN_AND_MEAN
* (set by the build system) to keep <windows.h> from pulling in <wincrypt.h>,
* rather than #undef-ing those macros here. */
#include <openssl/evp.h>
#include <openssl/x509.h>

Expand Down
1 change: 1 addition & 0 deletions src/retroshare/rstor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class RsTorManagerEventCode: uint8_t
TOR_MANAGER_STOPPED = 0x06,
};


// Status of the Tor hidden service setup/loaded by RS

enum class RsTorHiddenServiceStatus: uint8_t {
Expand Down
Loading
Loading