wgois / OIS

Official OIS repository. Object oriented Input System
https://wgois.github.io/OIS/
zlib License
254 stars 86 forks source link

Update CMakeLists.txt #89

Closed Kreijstal closed 8 months ago

Kreijstal commented 8 months ago

fix #88 Simply adds conditions for when it is being compiled from mingw, and get the appropiate libraries

Summary of changes

  1. Added MinGW Condition: Introduced a condition to check if the build environment is MinGW using ${CMAKE_CXX_PLATFORM_ID}.

    if ("${CMAKE_CXX_PLATFORM_ID}" STREQUAL "MinGW")
        ...
    endif()
  2. Specified Library Paths for MinGW: Within the new MinGW condition, set the paths for the DirectX libraries (libdinput8.a, libxinput.a, libdxguid.a) directly using the $ENV{MSYSTEM_PREFIX} environment variable.

    set(DINPUT8_LIBRARY "$ENV{MSYSTEM_PREFIX}/lib/libdinput8.a")
    set(XINPUT8_LIBRARY "$ENV{MSYSTEM_PREFIX}/lib/libxinput.a")
    set(DXGUID_LIBRARY  "$ENV{MSYSTEM_PREFIX}/lib/libdxguid.a")
  3. Added Checks for Library Existence: For added robustness, checks were inserted to ensure that the specified libraries actually exist on the file system.

    if (NOT EXISTS ${DINPUT8_LIBRARY})
        MESSAGE(FATAL_ERROR "Could not locate dinput8 DirectX library")
    endif()
    ...
  4. Explicitly Linked Libraries for MinGW: Modified the target_link_libraries section to include a condition for MinGW, linking the libraries directly.

    target_link_libraries(OIS "$ENV{MSYSTEM_PREFIX}/lib/libdinput8.a" "$ENV{MSYSTEM_PREFIX}/lib/libxinput.a" "$ENV{MSYSTEM_PREFIX}/lib/libdxguid.a")

These changes aim to correctly configure and build the project when using MinGW, overriding any other settings that might point to incorrect paths for the DirectX libraries.

Kreijstal commented 8 months ago

the command changes to cmake -G "MSYS Makefiles" -H. -B./build

Ybalrid commented 8 months ago

looks good to me