-
Notifications
You must be signed in to change notification settings - Fork 23
Add Windows Build Compatibility #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,106 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| project(AppwriteSDK CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 11) | ||
|
|
||
| include_directories(${CMAKE_BINARY_DIR}/conan/include) | ||
| link_directories(${CMAKE_BINARY_DIR}/conan/lib) | ||
|
|
||
| find_package(CURL REQUIRED) | ||
|
|
||
| set(SRCS | ||
| src/Appwrite.cpp | ||
| src/services/Account.cpp | ||
| src/services/Query.cpp | ||
| src/services/Databases.cpp | ||
| src/services/Messaging.cpp | ||
| src/services/Storage.cpp | ||
| src/services/Health.cpp | ||
| src/Utils.cpp | ||
| src/Validator.cpp | ||
| ) | ||
| cmake_minimum_required(VERSION 3.15) | ||
| project(AppwriteSDK VERSION 1.0.0 LANGUAGES CXX) | ||
|
|
||
| add_library(AppwriteSDK STATIC ${SRCS}) | ||
| # Set C++ standard | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| include_directories(include) | ||
| # Platform-specific configurations | ||
| if(WIN32) | ||
| set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
| add_definitions(-DWIN32_LEAN_AND_MEAN) | ||
| add_definitions(-DNOMINMAX) | ||
| endif() | ||
|
|
||
| target_link_libraries(AppwriteSDK CURL::libcurl) | ||
| if(NOT CONAN_TOOLCHAIN_FOUND) | ||
| message(WARNING "Conan toolchain not found, proceeding without it") | ||
| endif() | ||
|
|
||
| set_target_properties(AppwriteSDK PROPERTIES | ||
| ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib | ||
| ) | ||
| # Make PkgConfig optional for Windows compatibility | ||
| find_package(PkgConfig QUIET) | ||
|
|
||
| # Set CMAKE_PREFIX_PATH for Conan-generated files | ||
| set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/generators ${CMAKE_PREFIX_PATH}) | ||
|
|
||
| set(HEADERS | ||
| include/Appwrite.hpp | ||
| include/classes/Account.hpp | ||
| include/classes/Query.hpp | ||
| include/classes/Databases.hpp | ||
| include/classes/Messaging.hpp | ||
| include/classes/Storage.hpp | ||
| include/classes/Health.hpp | ||
| include/config/Config.hpp | ||
| include/enums/HttpStatus.hpp | ||
| include/exceptions/AppwriteException.hpp | ||
| include/Utils.hpp | ||
| include/Validator.hpp | ||
| # Include Conan's generated target files directly (only CURL now, no nlohmann_json) | ||
| include(${CMAKE_BINARY_DIR}/generators/CURL-config.cmake OPTIONAL) | ||
|
|
||
| # Alternative: Load all available Conan targets | ||
| file(GLOB CONAN_CONFIGS "${CMAKE_BINARY_DIR}/generators/*-config.cmake") | ||
| foreach(config_file ${CONAN_CONFIGS}) | ||
| include(${config_file}) | ||
| endforeach() | ||
|
|
||
| # Create library - handle both dummy.cpp and header-only scenarios | ||
| set(SOURCES | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/dummy.cpp | ||
|
||
| ) | ||
|
|
||
| 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) | ||
|
||
| add_library(AppwriteSDK INTERFACE) | ||
| target_include_directories(AppwriteSDK | ||
| INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| ) | ||
| set(LIBRARY_TYPE "INTERFACE") | ||
| else() | ||
| add_library(AppwriteSDK ${SOURCES}) | ||
|
||
| target_include_directories(AppwriteSDK | ||
| PUBLIC | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
| ) | ||
| set(LIBRARY_TYPE "STATIC") | ||
|
||
| endif() | ||
|
|
||
| # Install headers | ||
| install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ | ||
| DESTINATION include/AppwriteSDK) | ||
|
|
||
| # Install library only if not header-only | ||
| if(NOT LIBRARY_TYPE STREQUAL "INTERFACE") | ||
|
||
| install(TARGETS AppwriteSDK | ||
| ARCHIVE DESTINATION lib | ||
| LIBRARY DESTINATION lib | ||
| RUNTIME DESTINATION bin) | ||
| endif() | ||
|
|
||
| # Handle CURL target compatibility | ||
| set(CURL_TARGET "") | ||
| if(TARGET CURL::libcurl) | ||
| set(CURL_TARGET CURL::libcurl) | ||
| message(STATUS "Using CURL target: CURL::libcurl") | ||
| elseif(TARGET CURL::CURL) | ||
| set(CURL_TARGET CURL::CURL) | ||
| message(STATUS "Using CURL target: CURL::CURL") | ||
| else() | ||
| message(STATUS "No CURL target found, continuing without it") | ||
| endif() | ||
|
|
||
| # Link libraries - ONLY CURL (nlohmann_json removed as per Issue #19) | ||
| if(CURL_TARGET) | ||
| if(LIBRARY_TYPE STREQUAL "INTERFACE") | ||
| target_link_libraries(AppwriteSDK INTERFACE ${CURL_TARGET}) | ||
| else() | ||
| target_link_libraries(AppwriteSDK PUBLIC ${CURL_TARGET}) | ||
| endif() | ||
| endif() | ||
|
|
||
| # Windows-specific linking | ||
| if(WIN32) | ||
| if(LIBRARY_TYPE STREQUAL "INTERFACE") | ||
| target_link_libraries(AppwriteSDK INTERFACE ws2_32 wldap32 crypt32) | ||
| else() | ||
| target_link_libraries(AppwriteSDK PRIVATE ws2_32 wldap32 crypt32) | ||
| endif() | ||
| endif() | ||
|
|
||
| # Status messages | ||
| message(STATUS "AppwriteSDK configured successfully") | ||
| message(STATUS "Library type: ${LIBRARY_TYPE}") | ||
| message(STATUS "CURL target: ${CURL_TARGET}") | ||
| message(STATUS "nlohmann_json removed as per Issue #19") | ||
| message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| @echo off | ||
| echo AppwriteSDK Windows Build (Fixed) | ||
| echo ================================= | ||
|
|
||
| :: Ensure MinGW is in PATH | ||
| where gcc >nul 2>&1 | ||
| if %errorlevel% neq 0 ( | ||
| echo Error: GCC not found. Ensure MinGW is in your PATH. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| :: Clean build directory | ||
| if exist "build" rmdir /s /q "build" | ||
| mkdir build | ||
| cd build | ||
|
|
||
| :: Install dependencies with explicit output folder | ||
| echo Installing dependencies with Conan... | ||
| conan install .. --output-folder=. --build=missing -s build_type=Release | ||
|
|
||
| :: Verify toolchain file was created | ||
| if exist "conan_toolchain.cmake" ( | ||
| echo ✅ Found conan_toolchain.cmake | ||
| set "TOOLCHAIN_FILE=conan_toolchain.cmake" | ||
| ) else ( | ||
| echo ❌ conan_toolchain.cmake not found, listing build contents: | ||
| dir /b | ||
| echo Trying without toolchain file... | ||
| set "TOOLCHAIN_FILE=" | ||
| ) | ||
|
|
||
| :: Configure with CMake | ||
| echo Configuring with CMake... | ||
| if defined TOOLCHAIN_FILE ( | ||
| cmake .. -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=%TOOLCHAIN_FILE% -DCMAKE_BUILD_TYPE=Release | ||
| ) else ( | ||
| cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release | ||
| ) | ||
|
|
||
| if %errorlevel% neq 0 ( | ||
| echo ❌ CMake configuration failed | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| :: Build | ||
| echo Building... | ||
| cmake --build . --config Release | ||
|
|
||
| if %errorlevel% equ 0 ( | ||
| echo ✅ Build successful! | ||
| cd .. | ||
| call install_windows.bat | ||
| ) else ( | ||
| echo ❌ Build failed | ||
| pause | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| @PACKAGE_INIT@ | ||
|
|
||
| include(CMakeFindDependencyMacro) | ||
|
|
||
| find_dependency(CURL REQUIRED) | ||
| find_dependency(nlohmann_json REQUIRED) | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/AppwriteSDKTargets.cmake") | ||
|
|
||
| check_required_components(AppwriteSDK) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| [requires] | ||
| libcurl/8.10.1 | ||
| libcurl/7.87.0 | ||
|
|
||
| [generators] | ||
| CMakeDeps | ||
| CMakeToolchain | ||
|
|
||
| [layout] | ||
| cmake_layout | ||
| [options] | ||
| libcurl/*:shared=False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| @echo off | ||
| echo Installing AppwriteSDK to MinGW directories... | ||
|
|
||
| :: Find MinGW installation | ||
| for /f "tokens=*" %%i in ('where gcc') do set "GCC_PATH=%%i" | ||
| for %%i in ("%GCC_PATH%") do set "MINGW_BIN=%%~dpi" | ||
| set "MINGW_ROOT=%MINGW_BIN:~0,-5%" | ||
|
|
||
| echo MinGW Root: %MINGW_ROOT% | ||
|
|
||
| :: Install headers | ||
| set "INCLUDE_DIR=%MINGW_ROOT%\include\AppwriteSDK" | ||
| if not exist "%INCLUDE_DIR%" mkdir "%INCLUDE_DIR%" | ||
| xcopy /E /I /Y "include\*" "%INCLUDE_DIR%\" | ||
|
|
||
| :: Install libraries | ||
| copy /Y "build\*.a" "%MINGW_ROOT%\lib\" 2>nul | ||
|
|
||
| echo Installation complete! | ||
| echo Headers installed to: %INCLUDE_DIR% | ||
| echo Libraries installed to: %MINGW_ROOT%\lib\ | ||
| echo. | ||
| echo Test compilation: g++ -o test.exe test.cpp -lAppwriteSDK | ||
| pause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 17 i guess, keeping the same as the current standard.
There was a problem hiding this comment.
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?