Skip to content

Conversation

@Ashish-Kumar-Dash
Copy link
Contributor

This PR addresses issue #10

What & Why

This PR implements Windows build compatibility for the cpp-sdk-appwrite project, addressing Issue #10 which requested extending the existing Unix-based Conan integration to Windows systems.

Original Requirement:

"Current System already has Conan integration with CMakeLists.txt for Unix based system. We need to do the same for Windows based system"

How - Technical Implementation

Core Approach:

  • Enhanced CMakeLists.txt with cross-platform compatibility while maintaining Unix functionality
  • Resolved Windows-specific build issues (OpenSSL, PkgConfig, CURL detection problems)
  • Integrated Conan 2.0 toolchain properly for MinGW builds
  • Created automated Windows build pipeline with installation to MinGW directories

Key Technical Solutions:

  1. Bypassed problematic dependencies (OpenSSL build errors) as advised by maintainer
  2. Made PkgConfig optional for Windows compatibility
  3. Fixed CMake-Conan integration by correctly locating toolchain files (build/Release/generators/)
  4. Implemented robust target linking with fallback mechanisms for CURL
  5. Created automated installation that places headers and libraries in MinGW directories

Files Created/Modified

File Purpose Status
CMakeLists.txt Enhanced with Windows compatibility, Conan integration, cross-platform support Modified
build_windows.bat Automated Windows build script using Conan + MinGW Created
install_windows.bat Installation script that places files in MinGW directories Created
conanfile.txt Configured dependencies for Windows builds Modified

File Purposes Explained:

  • build_windows.bat: One-command Windows build automation - handles Conan dependency installation, CMake configuration, and compilation
  • install_windows.bat: Fulfills the core requirement by installing headers to C:\MinGW\include\AppwriteSDK\ and libraries to C:\MinGW\lib\
  • Enhanced CMakeLists.txt: Cross-platform compatibility with proper Conan toolchain integration, Windows-specific configurations, and robust dependency handling

Testing Results

Build Success Evidence:

Terminal Output
Screenshot 2025-08-28 202109

Verification:

  • Conan dependencies resolved: libcurl, nlohmann_json, zlib
  • CMake configuration completed without errors
  • Static library built: libAppwriteSDK.a generated
  • Headers installed: 12 header files in MinGW include directory
  • Library installed: Static library in MinGW lib directory
  • Build artifacts created: Complete build directory with CMakeFiles, Makefile, etc.

Completed Requirements:

  • Windows build compatibility using existing Conan integration
  • MinGW directory installation (headers + libraries) as specifically requested
  • Cross-platform compatibility maintained (Unix builds unaffected)
  • Automated build process for Windows developers
  • Seamless Conan 2.0 integration

Impact

Windows developers can now:

  1. Build the SDK with a single command: ./build_windows.bat
  2. Install automatically to MinGW directories: ./install_windows.bat
  3. Use in projects with standard linking: g++ -o app.exe code.cpp -lAppwriteSDK

Kindly review and let me know if any changes are needed, @pooranjoyb @sristy17 . I'm keen to hear feedback because this has been a big learning curve for me.
Thank You

@pooranjoyb
Copy link
Owner

Thanks for the contribution; will surely look into it!!

@pooranjoyb pooranjoyb added touch-of-magic Smiles Guaranteed (enhancements) escalate-to-the-gods peak coding needed here level 3 GSSOC level 3 labels Aug 28, 2025
@pooranjoyb pooranjoyb linked an issue Aug 28, 2025 that may be closed by this pull request
@pooranjoyb pooranjoyb moved this to In Progress in C++ SDK Appwrite Aug 28, 2025
@Ashish-Kumar-Dash
Copy link
Contributor Author

Ashish-Kumar-Dash commented Aug 31, 2025

@pooranjoyb The build completes fine now and installs all the header files to the MinGW directories like they wanted, and I also cleaned up the nlohmann_json dependency .
There are some OpenSSL error messages that show up in the logs when Conan tries to build it as a dependency for libcurl, but those don't actually break anything - the main build works perfectly without them.
Terminal Output while building

Screenshot 2025-08-31 214434 Screenshot 2025-08-31 214423 Kindly review and let me know if any changes are needed, Thank you

@pooranjoyb
Copy link
Owner

pooranjoyb commented Sep 6, 2025

what i can see is that linux build is not pointing to the build dirs.

Moreover after the conan installation; why does it fetches the dependencies in the root of the project? Please fix it. Also lemme know if I'm running a wrong command for installation.
@Ashish-Kumar-Dash

these were the commands used to install the sdk in unix :

mkdir build && cd build
conan install .. --build=missing
cmake ..
make
sudo make install

Evidence :

image

@pooranjoyb
Copy link
Owner

Also please update the README.md with updated installation guidelines for both linux and windows.

@Ashish-Kumar-Dash
Copy link
Contributor Author

Ashish-Kumar-Dash commented Sep 10, 2025

updated the build system to fully support Windows (MinGW64) and Linux environments in a clean workflow, ensuring all Conan and CMake generated files stay inside the build/ directory rather than the project root. updated the readme too for user guidance for the commands to be used. kindly review and let me know if any changes are needed @pooranjoyb . tested on ubuntu and windows.

@pooranjoyb
Copy link
Owner

updated the build system to fully support Windows (MinGW64) and Linux environments in a clean workflow, ensuring all Conan and CMake generated files stay inside the build/ directory rather than the project root. updated the readme too for user guidance for the commands to be used. kindly review and let me know if any changes are needed @pooranjoyb . tested on ubuntu and windows.

Okay will check and retest.


add_library(AppwriteSDK STATIC ${SRCS})
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 11)

This should be 17 i guess, keeping the same as the current standard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have set the standard set as 17 only is there an issue?

Copy link

@SharonIV0x86 SharonIV0x86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ashish-Kumar-Dash I've reviewed the CMake changes, but I'm noticing some differenced between the screenshot in the PR description and the actual implementation.

Correct me if i'm wrong but from my understanding of the CMake file you've written, it appears the current configuration may not be compiling all the necessary source files into a proper static library. The logic seems to be designed for a header-only (INTERFACE) library approach when dummy.cpp is missing, rather than building the complete static library with all implementation files like Appwrite.cpp, Account.cpp, Query.cpp, etc.

CMakeLists.txt Outdated

# Create library - handle both dummy.cpp and header-only scenarios
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/dummy.cpp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only includes dummy.cpp but misses all the actual source files (Appwrite.cpp, Account.cpp, Query.cpp, etc.). Doesn't it need to include all implementation files like the existing CMake does?

CMakeLists.txt Outdated
install(DIRECTORY include/ DESTINATION /usr/local/include/AppwriteSDK)
install(FILES ${HEADERS} DESTINATION /usr/local/include/AppwriteSDK)
install(TARGETS AppwriteSDK ARCHIVE DESTINATION /usr/local/lib)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/dummy.cpp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt this conditional INTERFACE library approach incorrect for a static library. We need to explicitly specify STATIC library type and include all source files, not just dummy.cpp, the dummy file doesn't exist in the src folder

CMakeLists.txt Outdated
)
set(LIBRARY_TYPE "INTERFACE")
else()
add_library(AppwriteSDK ${SOURCES})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing explicit STATIC library type specification.

CMakeLists.txt Outdated
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
set(LIBRARY_TYPE "STATIC")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are declaring the LIBRARY_TYPE variable but in the code below its never being checked for its "STATIC" value

CMakeLists.txt Outdated
DESTINATION include/AppwriteSDK)

# Install library only if not header-only
if(NOT LIBRARY_TYPE STREQUAL "INTERFACE")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This INTERFACE library logic adds unnecessary complexity. Since we're building a static library, we should always install the target.

@Ashish-Kumar-Dash
Copy link
Contributor Author

Ashish-Kumar-Dash commented Sep 27, 2025

The CMake setup was updated to explicitly build a STATIC library including all source files from src/ and remove the previous INTERFACE logic. Added mandatory find_package(CURL REQUIRED) with robust linking to Conan-provided curl targets. The build now requires -DCMAKE_BUILD_TYPE for proper dependency resolution. After these changes, the project builds and installs cleanly with all dependencies correctly handled on Linux and Windows. Apologies for the late update as I was busy for my midsem exams. Kindly review @pooranjoyb @SharonIV0x86 . attached ss of the build
Screenshot from 2025-09-27 10-30-51

@SharonIV0x86
Copy link

The CMake setup was updated to explicitly build a STATIC....... ss of the build.

The million dollar question is, does it work on windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

escalate-to-the-gods peak coding needed here level 3 GSSOC level 3 touch-of-magic Smiles Guaranteed (enhancements)

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Build Compatibility for Windows

3 participants