MADEAPPS / newton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.
http://www.newtondynamics.com
Other
928 stars 183 forks source link

newton-4.00 cmake style is directory based instead of target based. #323

Open jonesmz opened 7 months ago

jonesmz commented 7 months ago

The newton-4.00 folder has CMakeLists.txt files which are not easy to consume by other code.

The type is written in terms of applying (repeatedly) includes, compiler definitions, and link libraries, to the current directory and subdirectorys.

The maintainers of the CMake program strongly recommend against this style (to the point where there was a recent ticket (sometime in the last 6 months, give or take) in their bug tracker about removing it entirely), and instead recommend attaching everything to targets.

For example:

in newton-4.00/sdk/dNewton, the library is defined as building with

include_directories(.)
include_directories(../dCore)
include_directories(../dTinyxml)
include_directories(../dProfiler)
include_directories(../dCollision)

include_directories(dJoints/)
include_directories(dModels/)
include_directories(dIkSolver/)
include_directories(dParticles/)
include_directories(dModels/dVehicle/)
include_directories(dModels/dCharacter/)

But none of these include directories are exposed as public properties of the library, which is defined with add_library(${projectName} ...) (Static, or Shared, depending on build settings). This means that projects trying to use newton have no way to access the header files, or compilation flags without constructing their own list of includes and compilation flags, which may not be 100% accurate, especially after an update.

It would help greatly if newton-4.00 would adopt a target-centric cmake configuration instead. Otherwise I'm still stuck on 3.14.