bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

Build Windows DLL's

Open madebr opened this issue 5 years ago • 11 comments

Hello

  • ~I reformatted the main CMakeList.txt + those in the src subfolder to use spaces as was done in #2221 (If this is undesired, let me know and I'll updated those)~
  • I kept everything in uppercase and used hard tabs in the cmake files
  • I also updated the minimum required CMake version to 3.0. CMake 3.0 is the oldest CMake version that is nicely documented on cmake.org. I believe this is a nice compromise. FYI 2.4.3 was released on 2006-07-31, 3.0 on 2014-06-10.
  • ~I have added a .editorconfig file that should automatically set source formatting properties~
  • Added support for BUILD_SHARED_LIBS on Windows. When building shared libraries, all symbols are automatically exported. This fixes #1391 #1570 #1794
  • ~I also fiddled a bit with the examples to be able to build these using shared libraries.~
  • On MSVC, the libraries in the examples, extras and tests folders are built as a static library by default. I focused on the main bullet3 libraries here.
  • Both static, shared and pybullet libraries are built and tested on Appveyor
  • ~I cannot reproduce the LNK4197 warnings on appveyor on a local Visual Studio 2017. So I assume these are fixed by MSVC.~ (I did not test mingw)
  • The cmake script exports targets that consumers can use. It allows the following:
find_package(Bullet CONFIG 2.89 REQUIRED)
add_executable(my_simulator ${SOURCES})
target_link_libraries(my_simulator PUBLIC Bullet::BulletDynamics Bullet::BulletCollision)

This will test whether bullet has version of at least 2.89 and if the Bullet library is of the same architecture (32 vs 64 bit). It will also automatically set the correct defines for linking to static/shared libraries and single/double precision.

madebr avatar Sep 01 '19 16:09 madebr

Thanks for the PR. There are a lot of changes and I will need to review each of them, not sure if/when I get to this.

erwincoumans avatar Sep 07 '19 16:09 erwincoumans

@erwincoumans Thanks for taking this PR in consideration. This PR is mainly about adding DLL support. I have another older tree (https://github.com/madebr/bullet3/tree/cmake_old_lots_rework) which modularizes the build system a bit. I would love to update that one once this pr is finished.

madebr avatar Sep 12 '19 21:09 madebr

I've been thinking. This pr is trying to solve two problems (poorly):

  • the bullet3 library is unable to compile and link as a dynamic library on Windows; and
  • the examples are very interdependent.

Therefore I propose the following:

  • fix the bullet3 linking in this pr (allow static and dynamic libraries; and
  • always compile the examples as static libraries.

madebr avatar Nov 13 '19 21:11 madebr

@erwincoumans I greatly simplified the pr and limited myself to:

  • adding static/shared support for MSVC on Windows
  • adding support for exporting targets (for consumers of bullet)
  • getting pybullet to build on appveyor

madebr avatar Nov 16 '19 22:11 madebr

Some questions:

  • Does anyone use INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES? CMake does not create distributable project files because it depends on the actual toolchain (visual studio version etc). (I would remove it)
  • I propose adding a namespace prefix to INSTALL_LIBS (BULLET_INSTALL_LIBS) because consumers who use bullet3 might want to install their own libs.
  • I uppercased every cmake function. This feels a bit like screaming. Wouldn't it make more sense to use downcase? The cmake documentation uses this.

madebr avatar Nov 16 '19 23:11 madebr

Hello!

Is there any status for this PR?

helynranta avatar Jul 31 '20 05:07 helynranta

@lerppana This pr set has become huge, too huge for merging. It reformats the code, simplifies things here and there, adds support for shared libraries on Windows and fixes some examples. That's why I extracted the formating to pr #2643. Once that gets merged, if ever, then I'll continue on the next task.

Is @erwincoumans still interested in this, and willing to review #2643? Because I don't see any feedback, I don't know whether it is worth the effort..

madebr avatar Aug 02 '20 00:08 madebr

Bullet is a great library, it deserves up to date build system. I hope this initiative moves forward 😊

helynranta avatar Aug 03 '20 13:08 helynranta

I strongly advise merging this PR. but I need to try branch in @madebr first to test.

jiangcaiyang avatar Aug 16 '20 09:08 jiangcaiyang

Hello @madebr , I can't run cmake --build %buildFolder% --config release --target install Because MSBuild tells me that project file install.vcxproj doesn't exist.

用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.7.0+b89cb5fde
版权所有(C) Microsoft Corporation。保留所有权利。

MSBUILD : error MSB1009: 项目文件不存在。
开关:install.vcxproj

jiangcaiyang avatar Aug 16 '20 09:08 jiangcaiyang

@jiangcaiyang Installation is disabled by default on non-makefile systems. You need to pass -DINSTALL_LIBS=ON to cmake when configuring to enable it.

madebr avatar Aug 17 '20 13:08 madebr