How to add compile sources to juce modules in 4.2?


#1

we have core code inside a juce module which is difficult to group in cpp files because it depends on libraries like Boost and CGAL which cause a lot a redefinitions and other issues. In the old module system we would put in the juce_module_info all our compile sources like

 "compile":         [{"file":"juce_icarus.cpp"},
  					{"file":"geom/NTMeshTree.cpp"},
					{"file":"geom/bvh/FastBVH.cpp"},
  					{"file":"geom//bvh/BvhBBox.cpp"},
  					{"file":"geom/NTTrimTextiles.cpp"},
  					{"file":"geom/NTBoundingBox.cpp"},
  					{"file":"geom/Curvature.cpp"},
					{"file":"geom/NTOverhangAnalysis.cpp"},
					{"file":"geom/NTUnitGenerator.cpp"},
					{"file":"geom/NTTrimLattice.cpp"},
					{"file":"geom/NTCurveTrimmer.cpp"},
					{"file":"geom/NTRandomPtsOnMesh.cpp"},
					{"file":"geom/NTGeometry2D.cpp"},
					{"file":"geom/NTSnapLinesToLines.cpp"},
					{"file":"geom/NTUnitManager.cpp"},
					{"file":"geom/NTUnitStats.cpp"},
					{"file":"geom/NTGeometry3D.cpp"},
					{"file":"geom/NTSolid.cpp"},

Is there any way to do something like this in the new module system? Right now it seems I can only add cpps that start with the module name, and are in the root folder.


#2

Yeah, the point of that is to make it obvious from the folder structure which files need to be compiled, rather than this being knowledge that’s hidden away inside the config.

At a guess from what you’ve got there, I’d expect that you could probably include all those cpp files from a single master cpp file in the root folder, which will simplify things and also speed up your compilation a lot.


#3

But thats thing, putting them in one cpp file causes compile errors. and the errors have to do with Boost code, which we dont want to change. Also for compile speed I think only clean builds are faster. Making a small one line change, would now have to recompile a bigger file.


#4

Bigger files make very little difference to compile speed. The thing that slows you down is having many compile units which all include the same headers (in particular the boost headers).

If you’re using boost, then definitely the best plan would be to have a single cpp which includes boost once, and then includes all your own code. And obviously keep boost out of your module’s public header files so that other code doesn’t have to indirectly include it.


#5

Ok thanks, I think I have this figured out