Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ install(FILES
${CMAKE_INSTALL_INCLUDEDIR}/libmodplug
)

if (NOT WIN32)
if(WIN32)
if(MSVC)
set(LIBS_PRIVATE "-luser32")
elseif(MINGW OR CYGWIN)
# mingw
set(LIBS_PRIVATE "-lstdc++")
endif()
else()
set(LIBS_PRIVATE "-lstdc++ -lm")
endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
Expand All @@ -173,4 +182,3 @@ if (NOT WIN32)
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif (NOT WIN32)
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ MODPLUG_LIBRARY_VERSION=1:0:0

AC_SUBST(MODPLUG_LIBRARY_VERSION)

case "${host_os}" in
cygwin*|mingw*)
LIBS_PRIVATE="-lstdc++"
;;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong: mingw and cygwin are gcc-based and need -lstdc++ (same with the cmake side.)

Copy link
Author

@mcmtroffaes mcmtroffaes Jul 9, 2021

Choose a reason for hiding this comment

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

Good catch. What should be the correct host_os that corresponds to cmake's WIN32 an msvc build?

Copy link
Contributor

@sezero sezero Jul 9, 2021

Choose a reason for hiding this comment

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

I think cmake sets MSVC for msvc environment.

If it were me, I'd do something like the following for win32 case in cmake:

if(WIN32)
  set(LIBS_PRIVATE "-luser32")
  if(MINGW OR CYGWIN)
    set(LIBS_PRIVATE "${LIBS_PRIVATE} "-lstdc++")
  endif()
else()
  [....]

Copy link
Author

Choose a reason for hiding this comment

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

Ok, perhaps we can assume that autotools won't be used with msvc (although it's possible with msys2). For cmake, I've updated the patch to check with MSVC. I'll see if I can run a test with mingw.

*)
LIBS_PRIVATE="-lstdc++ -lm"
;;
esac

AC_SUBST(LIBS_PRIVATE)

AC_CONFIG_FILES([Makefile
src/Makefile
libmodplug.pc])
Expand Down
2 changes: 1 addition & 1 deletion libmodplug.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: The ModPlug mod file playing library.
Version: @VERSION@
Requires:
Libs: -L${libdir} -lmodplug
Libs.private: -lstdc++ -lm
Libs.private: @LIBS_PRIVATE@
Cflags: -I${includedir}