CMake and JUCE 6 - What is CMake and Why Should I Use It?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
right here we go for life hey what's up everybody shall we get a will actually just give a couple more minutes till everybody shows up yeah great yes Spider Man I love that game Final Fantasy have you played Final Fantasy yet no I haven't played final fundas in years yeah finally the the new Final Fantasy is really good I haven't I've been so into spider-man because spider-man's actually been in my in my collection for a couple years but I didn't actually start playing it until a couple months ago and I couldn't believe I couldn't believe how long I've just been kind of sleeping on it but Final Fantasy is really good that's that's the next one that I'm going to do after I think after I after I finish all the spider-man extensions it's also feels like so natural like you know I've had people you know come to my house and they never played the game and you give them the controller and you're like start playing and they immediately get sucked into it yeah and this because you feel like you're you're you're spider-man when you're playing it yeah and and what's yes is it's crazy no matter how long you're on the game you discover moves that you that you've never actually done before as well yes yeah cool all right it's five o'clock so I guess we should get started hey what's up everybody we're here live with our good friend al Amir from xfer how's it going - yeah I'm great and it's really exciting here on a Friday afternoon to talk about see make and talk about juice and audio programming it's a great time to be an audio development right now and we had a discussion earlier today on the discord by the way real quick announcement if you want to get involved in audio development or you want to talk with other audio developers or learn more about audio development come join our community over at the audio programmer comm forward slash community and we have developers of all different levels meeting each other helping each other without audio development all different types of audio development as well not just C++ so come join us the audio programmer comm forward slash community and how does that sound sound like a radio announcer yeah I've had a couple years of practice now so so yeah so so we had this discussion earlier today with with Ruben who's from the juice team and of course juice six if you don't know is going to officially support see make and there are a lot of people including myself that don't really know a lot about see make and how to get into it why do I need to use it and the basics around it and he al is with us to show us around and start getting us into the hello world of see make so I'll step back and let you take it away yeah yeah alright let's talk about why does something like see make exists before we even talk about like how to use it so when we're talking about we're all C++ programmers and the the concept of a build in C++ especially a cross-platform build is a very difficult one in general and has been for four years if you've ever used you know something like you know like a JavaScript or Python or something usually you have just a few source files and you just put them into a project or a library and it's pretty easy to just get them to compile on any machine pretty much as long as you have using javascript and you have a node environment or a reaction vironment basically you have what it takes and usually there's a package manager and that you have npm or whatever tool is in python so it's pretty easy to just take some source files get the thing to run and there's not all of this right but it's not really the case in C and C++ a build is something very complicated and to build on other types of machines is in its end or on its own like a very elusive topic I know a lot of you know experienced programmers who have no idea how to build their own code on a different platform like they'd have no idea how to even start so let's why is this so complicated so a C program or C++ program is not just some code it's actually a bunch of separately compiled units which are basically like each CPP file each of those has been compiled by the compiler and then it all comes together with something called the linker that takes it all together and makes your program or plugin or whatever it is that you have but a big part of the program is not just your code it's other people's code it's libraries maybe system libraries so it could be all kinds of things that are happening in the build their needs we describe somehow to the computer so if you've ever learned C++ and you see box plus usually there's some sort of a build system you're already using without knowing about it like if you use Xcode there's the Xcode system using Visual Studio there's the Visual Studio build system Linux have has make files there's all kinds of other build systems but usually you have something like some project file where you know you open up a visual studio you load your cpp files and then you click compile and it kind of knows what to do mm-hm but that only works with that one system that you're using right now okay you cannot take a visual studio project from Windows and build a Mac plug-in or app or something that's not possible you can't take a make file in Linux and wait for it kind of hope for it to compile in Mac just not gonna work and if you just import all the C files this that would only work if the project is really simple like you'll never be able to build an audio plug-in by just grabbing the C files usually a build is really complex really a build will be like different files will build for different platforms different libraries maybe there's some steps that are happening in the build like copying files from somewhere to some other place for this program to run so this is a problem many people try to solve in different ways so many companies would just make their own build system like some companies will just write some Python scripts that the developers are running and that script would just be like huge you know if statements right if it's Windows do this if it's Mac do this if it's on an iPhone app or do something else so it'll be like a big switching that can represents this code and if you if you've been writing plug-ins or audio audio software there's a great tool called the producer that does this and the producer the producer is also essentially a master build system yeah you load some code files into it and you pick a template and you say you want a VST or audio unit plug in and you give some properties properties to the thing like if it's an app you might say that this thing needs uh you know microphone access etc etc and the producer essentially is a program built by juice that's generating all the different build projects for you like it exports something for Xcode something for Visual Studio etc and eventually you end up with something that you can build on your machine or on any machine so that's good but but the producer only solves the problem for a very very specific use case it only solves a problem first of all if you're using juice second of all it only solved the problem if you want to do things that the producer was designed to do and we'll we'll show some use cases soon for things the producer was not designed to do so if you want that to happen in your build like there's no way for you to make it happen unless it's going to change which is hard like it's a very complicated program because because if you want to add some features the producer you're gonna have to work on all the different if statements if it's Linux to this iOS to this like it's it's it's it's very low-level work it's very hard and unless you're an expert or something it's very hard to to do this so so that's where something like seam a came in simi Keys existed for quite a few years but it's becoming very very popular in the last few hmm and what it is is a very simple language of sorts very very simple much simpler than any you know then Python or Java sphere or something in just a very simple language that can generate all the different build systems like so Simek internally knows about what it takes to build on Linux and what it takes to build in Visual Studio and it can take what you describe for it like in the producer and just create a build for you hmm so that's basically what it is that's a problem it was trying to solve and now if you'll go to some libraries online - just don't get hub and look for libraries look for boost look for SDL look for almost any kind of library that's build and c and c++ almost all the popular libraries now switch to using that because it's a much more flexible system than all the sorry did all the different build system that existed before and it's not specific for you know there's no one system that's specific for boost or something it's the same system for juice boost or if you want to use both of them so you can just combine description of what it is I'm gonna ask a question that I know some people must be thinking so if you're working on Mac with your using C make will you be able to build for Windows if you're building on a Mac machine using seeming so Simek is is much dumber than this question if you know what I mean like the answer generally speaking is no like it you will not be able to write code click build in a Mac and have it built for Windows like you'll actually need a Windows machine with a Windows compiler yeah but you will not have to be the person who's configuring that compiler which you would be unless you have a cross-platform system ok right so if you so for example if you didn't have something like the producer and I work in companies that didn't have the producer or used juice so some of what these companies did was whenever you added a file like say I say I needed to add one more CPP file to my project what I would need to do is go to the Mac computer add that thing click Save then boot the other windows computer drag the same file into Visual Studio save that and then commit the thing to get mm-hmm and if we have a Linux build I'd also have to do the thing on a third machine which is a Linux machine like you'd actually have to drag the file manually to each of them what glue directory you did need to do 3 times so even if you don't even want to build but somebody eventually will want to build on another machine you will have to get another machine mmm it's quite hard what does that do when you Mac so you say you have to manually drag it what does it do that is so specific to that operating system yeah so so if you look at like I'll talk about something like Xcode right Xcode has I'm gonna simplify this right but Xcode has a project file which is essentially a data file an XML or something like that and it's got a bunch of data on how to build like it's got data on the source files got data on build steps if it needs to copy things which libraries to link and you know if you open the settings the build settings page in Xcode there's a bunch of build settings of like which compiler Flags you need and which compiler Flags in debug and release like it's somebody complicated page yeah so the Xcode project basically has that just has tons of data which is it descent which it needs to generate the things for you okay so so uh but one of this stuff is the list of files right like this one thing that's there so you drag something there what xcode does is it saves that thing into some big file mmm and then when you click build it knows to kind of gather all the list of files and send those to the compiler yeah but that thing is only specific to xcode it will never work in any other system there's no you can't go to Visual Studio code and say open the Xcode project the movie not windows yeah especially if use a different ID and a different compiler and like the it's it's very specific to only that way of working yeah not to mention even on even in Xcode you might have different settings for an iPhone app and a Mac app right mm-hmm and Xcode does not really know how to share these settings in us in a clean way you're gonna have to define what's shared and what's not shared mm-hmm it's not very easy yeah so basically that so when I say that about C make C make is batch basically of from our language that describes what like for you the user what do you want to have happened mmm describes the build and then it you can make it export a build system that you that you want to use like Xcode for example you can see you can go but but because it's one layer above Xcode and in the hierarchy it also knows about Windows or about iOS like you can make it you can translate it to anything without rewriting everything manually by hand mm-hmm okay interesting which is essentially what the producer is doing just to be clear and the producer is that but but meant for a very limited scope of applications yeah okay great yeah shall we shall we take a look also we have Reuben Thomas from the juice team that's joined us in the chat as well so hey Reuben he's been nice enough to join us so if you have si make questions of any sort of complexity or situation I imagine that Reuben will probably be able to answer your questions so feel free to ask if you're in the chat yes it's important to note that I'm not a si make expert Reuben is actually a real expert he works the juice team he knows he's very well versed in the world of CMake he's been I believe the person in charge to do the the new si make integration in juice six which we will talk about quite a lot mm-hm the reason why I'm talking here and is because just because I'm I'm interested in see make for my own users know I needed see make for what we do it extra I needed to see make for my own personal projects I needed some features that it has so I learned a bit about it and I learned enough about it to maybe talk to you about but I'm I'm not an expert and I probably will need to mention this in many many times throughout this video because some things I just learned how to do by asking people like Reuben or Elaine Martin who made fruit which is another see make library for juice mm-hmm so a lot of what I learned was just reading online or talking to them just trying to figure out how to do things that I needed to do yeah and I and I think one thing that I'd like to emphasize as well as that you don't need to be an expert in order to use he make and that this is this is designed to show you that hey it's it's relatively straightforward to get into and that that's the reason why we have people like Elaine and Reuben and people like that to help make things easier for for us to to be able to use and do what we concentrate on doing which is building products exactly and the reason why a lot of the C++ world outside of juice has moved to see make is because for most things you probably need to know just the very base like you don't need to be it's not it's not I mean you might want to learn more if you're the person in charge of some complicated build system but if you're just building you know your app your plugin or even a few even more than a few apps and plugins you just need to know a few commands yeah you don't need to know much more like it's not it's not gonna fall Ernie curved other than using you know or it's not so much it's not so different from using the build system you're already using like like like Xcode that's great cool shall we look at some code yep yep all right so can you see my screen here yep I can see you can see myself I'm gonna start my favorite IDE which is sea lion I am going to show a bit later on how to translate everything I'm doing also to to Xcode we can also do a video later on visual studio and windows tools I just don't want to load too many tools at the same time but one of the reasons why I like sea lion is that like a lot of modern IDE s it has native C make support some IDs need a command that will translate from C make to that IDE but cilium does not so it's like that the translation is is basically flax like you do something in C make it will build and that's it mm-hmm so I'm just gonna start a new project in Ceylon which will automatically generate so let's pick us call this like something like hello world C make and the real like that the the template that Ceylon provides when you're creating a new project is actually the hello world of C make like it basically Auto generates it so let's see what happens I'm creating a new project it's gonna build it let's loaded and so what what see make generated for me can you see this the right side here my the left side story of my screen yep so basically see me just generated or sea lion story generated two files one is main.cpp which is the code file you're seeing right now let's put it a bit larger and the other thing is a file called C make lists docx txt which is basically an a/c make instruction file that would be the equivalent of an Xcode project that you would normally see Anna who got Nicole base so this code is quite obvious I think most people learn C++ have seen this this kind of code right this is just hello world let's build it and see if that we're actually getting hello world mmm great typing my password to debug and we got hello world perfect now let's see how how would do we describe the build of this project so this is the C make list built it okay so there's four commands here pretty much the first one is requiring a version of C make to run this mmm-hmm because you're gonna need some version of C make install did you probably need one that supports the commands that you're gonna be calling so this specifies the version mmm-hmm you have the name of the project right in this case it's HelloWorld C make you have the version of C++ the C make c XX standard so this is c pass pass 14 i could do 11 for c++ 11 I could do 17 it's possible with my compiler if it supports 20 I haven't checked but it that's just the language specification and this is really the most interesting command here it's add executable so this means that I want this program to be an executable the Cron's like an exe file and this is the name of that target that's gonna be created for this executable and this is the names of sources right in this case its main dot CPP mm-hmm so this is like the simplest build you can do like it basically says here's a file build this into an executable and this and this is good enough to to be translated into any build system I can use this file and which I'm I'm I'm actually gonna gonna try so I'm actually gonna go to my terminal and I'm gonna type something I'm gonna actually type the C make command so I can turn this into an Xcode project for example mm-hmm so what I'm gonna do is type C make minus G this means generate then Xcode and the other other things I have to do is basically tell it's the source directory so where are where are basically where is the C make list dot txt file that it needs to convert so it's gonna be just right here where I am and I need to create some build directory bill the bill directory is all the temporary files that are gonna be created during the build mm-hmm so I'm just gonna call it build run it take a second to check that I have everything takes and check my compiler blah blah blah and it finished now let's see what he generated for me let's go to this folder hello world CMake and I have a build folder created by CMake and I have an Xcode project in here I can open it and it's basically ready to go let's click build let's switch to this target called hello world see make and built and it ran so that's basically all that I needed to do here we go hello world right so that's how I eat rent I took one thing from the from C make and translate it into this other world I could have also done if I was on Windows call the same command like C make minus G and do Visual Studio and you can even specify like versions of your ID like it has exporters for like Visual Studio 2017 2015 it knows all the different IDs and can generate the right project for for whatever you need so this can this is very useful if you have different developers they're working with and they all have different versions or different development systems if you describe your build correctly they can build and run your program with no additional configuration mm-hmm so this is this is the hello world yeah so so to summarize what you're saying so C make essentially I think a lot of people that may have worked in juice before may just assume that when you pull down a juice project and you happen to be using sea lion instead of Xcode or Visual Studio that just because the source files happen to be the same that it will just automatically build for you and that's not the case that fortunately that the producer is actually doing work in the background to ensure that no matter what that you're building in that it will actually build correctly so see make does essentially the same thing it translates it will translate your source code so that you can use it in whatever IDE that you need to use it it but it can also do more than that can it yeah yes but it is true that the producer for most simple project is the way to go I personally think that a producer is an amazing tool probably the best one I've seen of its kind for you know for the sea puss-puss world so if you're just starting out you're building a plug-in or an app or something in juice you probably want to use a producer just because this is a very clean safe way to do things it works it's very well tested there's absolutely no reason to not use it for you know when you're just starting out like it's so simple there it has a button that says open in Xcode right or open in Visual Studio it's got these like graphic helpers from whatever you need so that part is great it's fantastic so so I just want to say that it's uh it's not uh it's switching to another build system needs to come from from a need basically from meeting something else to be done mm-hmm so and I mean the the first thing is that many people don't want to just use juice for a juice app many people want to have juice built as a part of something else that you're doing like they have you know they have a project that's that they've done with other libraries and they just want to use juice for the audio side or they wanted you use juice for the graphics utilities they have like some people have different requirements so that's where that the complication in a build system starts to come to play great so let's continue first of all let's see if there's interesting questions here or interesting comments by bayi Rubin or somebody who knows more than I do these they're mostly C++ questions nothing nothing related to C make just yet right so so Ruben is saying and it's very right about it say that the cmakelists is very similar to the juicer projects right it's the see make list basically becomes when you're working in an a/c make project that becomes your master right that's your master file that you're you're editing and if you're before make changes to the bill that's the fault like you'll have to change as every user of this file every platform you're gonna build on will actually generate things for that system like you don't have to so and that's may think very similar to how you work in the producer okay so let's switch back to my screen and let's and let's start talking about more complicated projects right so so first of all I mean I don't want to go for on forever on doing on doing console application so I'm actually gonna switch up to to doing a juice project which is more interesting to I guess people watching this channel okay I actually have another question while we're while you're doing that so so see me is this something that you download you have to you have to install it do you have to how do you actually kind of get ignacy make yeah so that's a that's a really good question you know in some systems like if you already have Visual Studio or I think some of IDs just install see make even if you even if you don't explicitly do something if it's not installed by any chance you can't install it like on a Mac if you have brew you can just type you know brew install see make if you're using homebrew on Windows you can just download it like you go to see make that see me graph or a great think and you just click download and you can download it if you happen to not have it how do you know if you have it or not by the way you go to your command line or terminal or whatever it is you have a new-type seaming and if you don't have it then you'll see that it doesn't exist yeah that's basically on many cases it will just exist because a lot of tools just bring it with them there mm-hmm so so what's the command to see if you have seen make already see me oh just just type see make and if you won't have it then it will just say command not found or whatever it is your system says when you type an error so you just install it it comes with the with a GUI tool and a command like tool basic great so uh yeah so so these are like the general the general ideas about si make but and see me kiss other commands to describe common things in your build like the list of sources libraries you want to link include directories if you have sources from different directories and I will actually show examples of those now and we switch to juice so maybe I will I'll just stop for a second by saying sorry stop by saying that juice did not have native C make support up until very very recently mm-hmm and this is something that's actually coming out now for juice 6 mm-hmm so I was really hoping that use will roll this feature out I'm very happy about it so it's something that is not in the official juice version from the website just yet but it exists if you go to juice on github and grab the juice 6 branch I will actually just I will I will now show an example how to do this but this is something that's that's pretty new it just came out very recently and it's in testing stages but I've already set up just a few examples to how to bring up basic projects using juice 6 and see make to show how to get started with it great ok so so back to business so on my github I made a public repository if I go to github I made a public puzzle called juice see make repo prototype we should probably maybe copy the link somewhere but if you just look up this thing juicy make repo prototype or look up my name al Amir music you will find it it's one of the few public repos that I have and this is a prototype just to show one way to have a see make setup with juice so it's it's not a library it's not some magic thing it's just saying if you want to copy paste some parts of it to get set up quickly maybe this will help you that's this is my idea to when I created this so it so to use this by the way you don't actually need juice six installed this repo we set up in a way where if you have it and you have C make it will get whatever it needs to run including juice with the correct version so you don't even need to install juice from anywhere to use this ah right so what I'm gonna do is I'm just gonna clone this I'm gonna copy the the address and I mean I can go to it basically the command line and just type get clone I'm using sea lions the sea lion has a kind of load from github things I can just copy this but this will essentially call git clone which you can go there is no get sub-modules on this there is nothing complicated about the settings this is like the most straightforward git project you can set up great so I'm just gonna clone this and this will take a couple of seconds and when you load this when I listen sea lion salon rule will immediately start to configure this and you see that this is doing something there's a step now that says updating juice from get here at the bottom and this is a build stuff that I created you're gonna see in a second how I did it it's just a couple of C make commands what I did was I added a step to my build process that before the ìbe project is even built I forced it to go to github grab juice from the right branch and install it on my computer and I just did it so there would be no install cost that I won't have to start explaining somebody or myself how to install juice this will make sure that I have it installed I can actually bring in any library I want I can you know if I'm using SDL or any kind of boost library I can just do that bring the sources have them installed done I don't need to think about how to install this and that's all finished and now I have a bunch of targets that I have that I can build right let's pick up something like the GUI app templates let's just build it and it immediately knows how to build what to build I didn't have to do anything to change this other than having a see make supported IDE this this by the way will work as is using Visual Studio code if you have the C make extension this will work in Visual Studio the 2019 that has C make built-in L so it just built which is really nice like that usually if I'd use the producer I would have to point the producer to where juices I did not have to do this here this is done automatically by some custom steps that have that have I've setup using scenic so what's going on here how did this work what's happening so this is my folder it's got a bunch of different sub folders in it and this is my cmakelists file this this is basically describing the way this is built and let's see if we can just read this and under stand s the first thing I the first thing I'm doing is similar to my to our hello world is I'm just setting up the minimum version of C Meg that's required to build this and I have the name of the project which is called juice C make Reaper next thing I'm including a Simic fowl with some common functions that I made we'll see that file in a bit and I'm using something called include which is very similar to C++ and Glee this just brings in some other text file that has other C make commands now I'm calling basically the only function here that I wrote it's called update from get so this is the command that's bringing juice from github like I'm you see the dime actually specifying the the juice address here and I'm giving it a name the name is juice it's just a name that I decided to give this library or maybe it's the real name of the library and u6 is the gift branch because I'm using the juice six branch next I have a couple of build options which I will explain in a second yeah I got a question really quick yes where did you where did you find the command update from get how did you where did you get that from so I wrote this command and I will show you in a just go over this fall I will actually show how I rode this command it's very simple okay it's a yes C make just like it's really a language like you can actually write functions so for example if you have something that you're doing in every project like let's say every project you have is gonna be using juice instead of just typing a bunch of commands every time you can just have one function that does its okay so you can basically specify things that you were doing more than once and put them in a function okay so these are of options that have added these are options that allow you to build like the juice examples and the juice extras from the build they're currently turned off and and these are all these commands are called ads subdirectory and what they do is that they're basically adding another see make lists from that subdirectory so for example I have a directory called apps that also has a configuration file similar to this one so I'm just adding that and you can chain different projects this way for example I'm also doing add subdirectory to juice juice source directory mm-hmm these little curly braces and their dollar sign are indicating that this is a variable so I'm using a variable here because only after I'm grabbing juice from gets this variable will know where juice is on your computer because it's possible that will it will be in different places in different computers mm-hmm so this gets still dynamically by wherever the gift command installed it and from then on the build process knows where juices so there's no problem to just all right so this is like the top outline of what what's happening here you so you mentioned this command called update from get right so let's see this command this command is by the way in a file here called get functions which I basically just wrote a couple of functions in to to just simplify the process of repeating this if I need to mm-hmm so here you can call you can write macros or functions macros and functions are slightly different in C make but they're basically the same concept like they're basically like you know like a function that we know from from any language a macro and a function are only different in the sense that a function has its own scope and macro works on the scope that it was on the bass alone the global scope so if you have variables you want to set that are that are gonna be set everywhere for example in this case I'm setting up this juice source directory in all the juice variable where juice is so that way in that case III think at least that I need to use a macro but but but that's that that's basically the same thing a macro and a function in terms of purpose so these are just C make commands so these are just stuff that if you go and look on looking Google and how to do how to fetch something from gates these are basically the the commands like yeah III made it a function because I wanted this to be generic you don't have to write this as a function but I found that bringing stuff from git is something that I do quite often with all kinds of libraries so I I wanted to have a clean function that I can just call to say give me that library and not worry about it any longer so this calls just a few functions and doing you know declaring which repository this is and grabbing the properties and then populating this basically grabbing the thing from get and there's also a couple of messages messages is just like C out right this is just to print to the user that I'm updating so this so this is like a this is a custom a way to do a custom function but honestly most people will probably not use these custom functions right most of all problem don't care so much about custom functions they just want to have a build going with existing functions so let's go back to my top my top list thing so I have the gifts process which I wanted to add and then I'm adding all the different sub directories so I'm adding my I'm adding the juice folder I'm adding the modules folder and then the apps and the plugins folder so each of those like let's look at the apps subdirectory for example it has a few projects in it there is a each one of those is a juice project and in it there's a cmakelists that is very very simple all it does is adds four projects just for different projects that exist under this tree one of them is that so for example I have a console app test let's run the console app template and it built and this thing shows hello world so now let's look at how the console app is being built alright so this this is this is a the text file that defines a a way to build a juice console application so this is this is more complicated than building the hello world C++ application because this also has juice so in this console application you can use you know juice files or juice events or okay I believe this also includes stuff like juice timer and other classes that you might want to near your cost it come from juice so what am I doing here I have the same boilerplate as before I have the project and the version of the project right on top mm-hmm here I'm setting some variable because I just wanted to say that the target name the name of the the name of this project is the same as the project name but I can actually just manually type and say that the target name is console app or something in this particular case I decided it's gonna be exactly the same as a project name so I'm grabbing the variable C make variable called project name which is console F templates and setting this in the target but I could just manually type this as well if I want you mm-hmm so the next two statements are juice provided functions so these are function that you're getting if you're if you're getting juice and you're importing juice into C make you will automatically have access to those functions so all of the juice provided functions like I believe start with a juice underscore so you know that they come from juice if you if you look for them they're in a file called I think juice utils dot C make so this is a file that comes inside the repository does there's really good documentation in the juice repo if you read so which explains the names of the functions but but it's but in this case there's just a few that you have to know so juice add console app where it says give me an app with this name right the name is the same target name which is the name of the project which is console app templates so I'm just using the very the same variable for the name and here I'm given the product name which is the name that will show up in the you know in the window and stuff like that hmm so uh and so this this will generate an app for me with the correct settings for a for a console app based on juice the other command is juice generate juice header if you've used juice you're familiar with juice header H yeah so juice editor reg is an auto-generated file that the producer used to generate for you this is doing a similar similar action right this is just generates that the death H file for you so you can include it the other three commands here are just standard C make commands one is the target sources so this just has main.cpp but if I had other CPP's I would just add them right here these are the compiled definitions so these are all kinds of definitions the juice might one like here I'm turning off web browser and curl which are just default to settings you can there's all kinds of different settings that you might want to enable like build flags and stuff most times you might not want to touch this at all and this is where you're specifying which libraries you want to link um so here I'm linking with for for libraries three of those are just special libraries that use made so that I will have all the recommended warning LTO there's a link link time optimization and config Flags so these are basically flags the libraries that juice set up that will just configure all kinds of flags for me so that I won't have to to do those this is this very simpler similar from for this is a very much like using a producer templates right mm-hm really template already fills out some things for you so this basically does this under the hood and here I'm specifying that I'm gonna link with juice core like that which are the core libraries if I wanted to build an audio application I might want to do something like juice audio utils which is the juice audio library so what thing one thing that I mentioned from-from ribbon from the juice team mentioned is that the generate header command is mostly for backwards compatibility with old producer projects and that in newer projects he would advise against using it as the resulting designs are cleaner yes and he's right about that I just don't want to you know start a start going over everything but he but he's right like you this is something that that now there are now more modern ways on structuring your projects without it the reason I'm showing I like showing this is because a lot of people are already familiar and have other projects that have you the huge juice header so this is needed to support you know let's say you ported a juice console app into this you would have to have this command for the project to work okay so it's quite important this is always confusing to some people like I know that I poured it a lot of old projects into see make when it came out so this is something that I needed to know because otherwise you get weird error messages that you're you can't you can't tell mm-hmm but he's right that that is the probably should be you know as time moves along and and the ANSI make is more widely adopted I hope there will be less need on on having this command at all right so this is the example of like a very very simple application right and if I wanted to add files to this application let's say now I have this main.cpp file right this is by the way my main juice the entire code for the juice application yeah logger it writes the log like let's say that I wanted to add another CPP file in here like let's say one if you do something like let's uh let's have another you know header and source files let's call them something like my class right so if I build a class here and maybe I wanted to move this function into or create a function in another piece of code right like whatever I know something like void do something and then maybe have something like this right so so let's say that I wanted to have this this function called and ran from from my main.cpp I would need to tell the project that this file is a part of the build so I would need to go to see make list ext and say that just like I have main dot CPP file I also have the my class does CV file in the build you don't have to specify header files by the way because they because header files are not really a part of a built header files are usually included by the CPP files so if I'm building my class CPP and you see there's a function here and so usually my class dot CPP would include my class dot H mm-hmm so basically I don't need to tell the build system my class dot H exists the code for my class or H would get brought up regardless nice so now that I've done this let's go to main dot CPP and maybe I will include my class dot H and maybe I will do this function called but was that function how did I call it that's right I had a class called my class and it has a function called do something so now I can create this my class class of type C and do-si-do something mm-hmm and now because I've informed the build system of this this should build and call hello world and doing something here mm-hmm so and just like we've done before if I will go now and call the C make terminal command here I can generate this project for each individual build system that any developer is running on mm-hmm let's look at something more complicated let's look at the GUI app templates so the GUI app templates looks like this there's a few more things but it's essentially the same so instead of doing a juice add console app I'm doing a juice add GUI app which is pretty much the same just with a different sorry different different function name mm-hmm I'm calling juice January juice January juice header again and here I have a few more files here I have the main dot CPP file I have main component and I have main window so these are the different CPP files that my source files including so yes bill those and here's this GUI app example mm-hmm if you look at the code code is not very interesting all it is is a main component that has a label then a customized inheriting from label and adding the text hello world mm-hmm just if justified to center with the font with the size of 20 and this is really pretty much the juice regular caplet this is very similar to the producer mm-hmm I've modified this very slightly to fit my liking but these these are just templates yes III either them add those to my repository because many times I like to start with the template I like to start by copy pasting you know template off the GUI app type and just start banging out you know components and graphic objects mm-hmm so you can literally copy paste this including the C make file change the name right like for example if I wanted to write another if I wanted to add have this add another app I can just copy paste this to let's call it special GUI app right mm-hmm if I add this to get I will not add this to get want to commit this special thing in the apps subdirectory I will add this directory so it will get added to the build this is called special GUI app and I will change the name let's call this special GUI app and once i got this and i and i refresh the project basically if i was on the on on xcode or something i would just have to run the see may command again this would refresh the project for me just like a resave in the producer mm-hmm and now I should have a special GUI app here under my targets that can be built and run and I can just keep going and and work with my new great app nice yeah so we have a question from Tim or do you have any tips for building friend linking libraries with C make and is linking a pre-built library any different yeah so there's a few ways to link different libraries first of all you can just link libraries and get link libraries if it's pre-built you can literally just put the name here you might need to specify the directory of that library like there's also something called Ruben can correct me i think it's called target link directories so you have a command where you're saying here are the directories to search for to search for death those libraries like you can just add those so I believe the syntax I'm not harmless ensure is something like this like the name of the targets in this case this could have be been special GUI app or or the variable name and then I could just say something like this is gonna be under seem a current list here like under under this project slash libs right for example if you have lips the lips target here and then once you do this you can just write the name of the of the library right here you can do something like SDL - if you if that library exists there you can just do that okay it's very very simple you don't even have to worry about it this is a dot Lib file for Windows or a file format you don't worry about this you just write the name of the library okay nice yeah that's it's very very simple to to bring in libraries into into Simek so usually a very straightforward process any other questions before I keep going yeah yeah I see you saw ribbons top comment just there you can use yeah yes and everything woman is saying is very important stuff is basically saying there are indeed other ways you can do this you can use the sea makers commands to do like something like fine package there's it's it's ways to bring in packages or to look for them on your computer and there's there are also ways to kind of tell the user for example the programmer if the Packer is not found like you can say if the package is not found like show an error message to the programmer saying hey you need to install whatever libraries you're missing like it's a it's a it's very good because it helps the programmer know what they're missing if it's not an automated process like I have here mmm-hmm nice yeah so let's show something cooler let's go talk about a plugin great right so so I've made a template for a plug-in here this is really just the juice plug-in templates let's have a look at it so let's build it let's build a standalone plugin for example mm-hmm see that it's it's building and there's no build errors first so a plug-in very much like a juice F has a juice add function so just like we had juice add sorry juice add GUI app do sad console app we also had juice add plugin the juice add plugin is a bit more complicated because it has all kind of plug-in characteristics and this is similar to the plug-in options we have in the producer window mm-hmm so you can see here that there's all kinds of settings like the name the company name for the plug-in yes important stuff is this plug-in a synth needs MIDI inputs needs MIDI output is MIDI effect copy plug-in after build right yeah stuff like that the plug-in manufacturer code very important if you want to you know test and distribute your plugin mm-hmm and the format's right here you have au vs t3 and standalone if you have those libraries you can also add a ax if you have a license you can also add you know VST too but these are just these are really just the options you need other than that it's all pretty much the same like it's all very pretty similar I have the target sources the processor the editor and every other custom source files you might add and then I'm linking against juice audio utils right I talked to you before that juice score is usually for just the basics of juice audio utils if you want all the audio funk audio functionality mm-hmm so I'm adding this as well as all the recommended just recommended flags and this will basically work as is right you can see that here in Silla and i have all the targets i have the VST three i have the au target i can just click it and go and start debugging your logic or something this should pretty much work as as as much as you used to mm-hmm now i have another another situation here which is if you have shared code in different projects so let's say i have functions that I wrote that I want to use in many of my plugins this is a very common issue you know you once you have more than one plugin you can get sick of writing the same functions over and over again mm-hm it's a it's not very useful to copy/paste things all over the place because then your code is becoming unmaintainable so there there's there are all kinds of ways you can share code so one of the ways in juice is to use something called a juice module I believe you had a tutorial about juice modules on the channel right that's correct yeah our friend madcap music gave that tutorial there you go so uh I don't want to go too much about about juice modules as its explained in that other one but essentially it's code that you might want to share so here I have shown an example in my repository off I just made a module so that people can just cut copy paste this example module and do their own mm-hmm but essentially a module is just a collection of headers and CPP files so for example I wanted to show an example off a white noise oscillator that I wrote and I wanted to see how I can fetch it from my shared library instead of writing it into every single product because I might have many products that need white noise mm-hmm so here I what I did was I have a modules subfolder just like I have let's go back to my top top cmakelists the top folder so just like I have apps and plugins I also have modules just it's basically just a folder of shared code mm-hmm so here I have in my modules folder I have a cmakelists text that's like I have in any folder and here I'm calling a function called juice add modules this is very much like a juice add console app mm-hmm I believe there's also juice add module with the one and and then when you can call this with multiple modules mm-hmm it's possible that I have I have redundant calls here but but essentially I'm just adding the different modules that I have in a module let's go look at this shared processing code module a module has some declarations I'm sure math can cover this in his videos I won't go too much into the module header stuff but really I'm just including two things one is juice audio utils which is the juice audio utils library and I'm also declaring this as a dependency this is this is actually important because this will signal both the producer or see make whatever it is that I'm using to create the project which which other libraries are needed to link against this mm-hmm and yeah and the other thing that becomes is including white noise dot H which is my header file that has this white noise oscillator class yeah same thing with my CPP file it just includes the header file that goes along with it and the one CPP called white noise CPP that has the interesting parts implementations of the three functions that this oscillator has mm-hmm this oscillator by the way is not very interesting it's probably not the best oscillator this is just like something I wrote in ten seconds so I can have any kind of oscillator to to show for mmm so let's see how is this used so I haven't I have an example here called shared sorry I haven't WMA plugins called plug-in with custom module very original name let's look at the source code for this the source code is this is just basically a basic plugin processor code and what I'm doing is I'm just adding this class that I have called white noise oscillator I'm adding an instance of this class in my in my plugin processor mm-hmm and in my applying processor CPP all I'm doing like all I'm doing this has any kind of content is calling white noise dot process this is the only important function in this class and first of all let's run this and see from what I've done is gonna be working speakers from outgoing same let's set up outputs here you go oops this is loved right sorry about that that was very loud that was very loud it's okay hopefully I didn't ruin the ears of everybody on this channel anyway so uh so uh hmm so my idea was I wanted to create this so that I don't want to rewrite white noise every time like I want to have access to this white noise I might make 50 synthesizers I don't want to redo my work so so now that I have this so let's see how this is set up in my cmakelists dot txt file this is gonna be pretty much identical to the previous plugin cmakelists file but now instead of linking into the juicy details I'm linking against my own shared processing code and that module already knows to bring in that it's dependencies this month already knows to bring in juice along with it so I don't need to specify the juice libraries that I'm working against that's pretty cool yep so this is this is like a very simple way when you're building when you're starting to build on a repo you're adding projects this is like my my very straightforward way to to recycle code to reuse code any questions before I move on to something even cooler yeah so I'm not sure if you're covering this later but there was a question about adding binary data so so we had talked about the binary builder and images and outside assets so how do you how do you do that okay so here so this is uh this would be the last example I show because I feel like I've been talking for a while but so in the repo I have let me show you this example first and then it will analyze how this works so I have this folder here and this folder has it's called automatic binary data data and it has a couple of images under it one is one looks like this and the other looks like this you can see that I'm very very creative with my graphic design today yeah you really should not be looking to get my graphic design to layers so what I've done I've created a Simek project and this is really like for example a feature that you can use that will exist in seaming but will not exist if you're using like the producer mm-hmm so many like for example when I'm working I'm adding a lot of binary data files like images XML files all kinds of you know maybe WAV files like I'll have all kinds of resources that I'm adding to the build mm-hmm and when I was using the producer I had to drag those manually right here to drag them into the producer re saving the producer and then rebuild your project and it's very easy to forget some of these steps right sometimes work would you change the images list or something and you forget to add it or forget to remove it and things don't work as you want to so let's have a look at this template project and what it does hmm so I'm just finishing to build this yeah well while he's finishing just another reminder if you have questions or if you are looking to get started in C make or just want to hang out with other audio developers be sure to join us on the audio programmer comm forward slash community and that will link us to the discord where you can connect with us and we can help each other out so check out some people this is the app by the way the app shows both images kind of one above the other and let's say that this I wanted this app to automatically show the list of images in my binary that data right let's say that I let's say that I was I might want to I don't want to code every image that I'm adding adding to my binary data I want to go back save save the producer save the project type this go to the Chane - like I don't want to do all this boilerplate we'll all we're all I want to do is add an image and so uh let's see let me show what this code does so let's let's find another image maybe I will just print screen this part of the screen we're talking yeah so I'm just gonna I just made a screenshot of us should appear in my desktop here it is we changed the name to the audio programmer okay and now I'm just gonna copy paste like literally I'm just gonna copy this into the images folder copied yeah get done now let me rebuild this project I might need to do a clean build for this to work yes I want into uh first clean or just rebuild basically so I need to clean and then build again and other than doing the clean you will now notice that that build actually managed to follow that this folder has changed mm-hmm and the code managed to follow that this has change let's look at the new code they're just built here it is um sorry encounter because I was I forgot to I need to clean the entire and to clean this images the images target not the actual target I was not paying attention if anybody has any seemed eight questions feel free to ask in the chat by the way we have Reuben from the juice team joining us that can answer any see make question and big shout out to Danielle Daniels from Foley finest audio has joined us as well just rebuild and so normally would you be doing this in the command line then yeah I think I just made a mistake what was a mistake I made I just see something stupid here see them um my my magical example did not work as I planned because we build right mighty space we build but anyway the point was I was gonna say is that Wow you oh just this okay so what is gonna say is that what I have here is I have a see make file mm-hmm that keeps track off that folder like it knows to keep track of that folder and just add whatever is there to build whenever I whenever I rebuild the projects perhaps I just need to reload the project is probably what I forgot to do see all right sorry that's what I forget to you anything I need to click rebuild here yes that's your brick here you go yes that's perfect okay so basically every what I forget to do is if I was using the command line I just needed to call the seam a command again no I forgot to do which is when I click here see make reload mm-hmm this is it's basically just calling the seaming command again like this is just a shortcut for that and here I have our image already in code so I didn't change any of the of my code just this is the only change that I've made I didn't have to change either the code or the C make project nice and this is one of the cool stuff so that you can do in C make is you can have it automatically search for stuff and prepare stuff for you nice so for example I wrote a function here let's look at my my C make file is here is very very similar to the GUI app we make but what I but I also added a custom function so this is a function that does something called globbing so this is just goes through a directory and it actually will also go through the subdirectories because it's it's it's a globe recurse command mm-hmm and it's adding anything with the extension off jpg JPEG like this and PNG into a variable mm-hmm after it fits its version this if it had any images to see if not images string equal to nothing basically it asks if there are any images mmm then it creates a target called whatever name the the plug-in is images it uses a juice function called juice a binary data data it adds the file and then it does target link libraries little links together the images with the binary data into my plugin great and later on I just call my function so I say add images from directory this is my function to the target name in this case the target name is the same as my sir it's the same as my project name my automatic binary data and it's let's try let's try this with another image now that I am NOT blacking out so let's love another screen capture amazing capture I'm going to scream capture for example my mixer so here I amazing rme mixer being screen captured let's see this image being added here it is this calling mixer and I'm going to copy it into the images folder call the CMake command this is what I forget to do before we make again and now the build should keep track of what has changed and everything is working great I'm actually gonna show how this works in code too like how does the clear here is so in my code in the C++ code what I did was I called a function that this is something called get binary data assets that loops over everything that's in binary data mm-hmm and pushes it into a vector I have a vector of some structs that has all the information of the binary data which is in this case the data and the size and later in my main component I have a vector of unique pointer of image component which is a juice built-in component a very useful one mm-hmm and in my constructor I am grabbing that vector get binary data images so whatever is gonna be there during the build will get built and added so my code will not have to change if I'm adding any more images no I don't have images and the list will show up this is actually really useful for example if you have WAV files mm-hmm if you have a list of WAV files and you want to just populate that list from whatever you have like I say you has a plug-in that has samples for example like a sampler you might want to use something like this to just populate that list of samples that you've decided to ship in your data and that way you can change this folder without any coaching wow this is something cool that cannot be done in the you know that's really cool so Ruben said I think if you add configure depends to the global command you can avoid the manual reconfigure step right yes yeah I mean again as I've said from the beginning he's easy is right I probably should have show some more tips on how to do this or they are very they're probably much more efficient and better ways to do everything that I've been showing these are just like very practical examples that I'm I'm making from my own use yep with expert or at my home so it's not necessarily like the you know the the most like efficient you know list words for a CMake project yeah hopefully you get the idea like that the idea is that once you define your build in kind of like you defined code with what's between project what's gonna be common to everything that you do because if you have things that are repeating like repeating actions you can just write functions in C make for those mm-hmm or have variables for things that are setting just to give you an example if all if you have 50 plugins and they're all from the same manufacturer right you have a manufacturer name you don't have to type it all the time you can just use a variable so that lets say your company name changes or you decide that you know your company names in a plugin should show instead of showing you know maybe instead of showing x4 it should show extra records mm-hmm you just change a variable name and that's it it will change everything in the in the hierarchy of plugins so you don't have to go through each and every plug-in and make sure that it's changed it's fine for if you decided to that all your plugins should now be linked or maybe have an include directory for new shared code that you decided to add no probably just add it to the same place and all the plugins will have it thanks you have all this power of control your build other people do things like have a post build step that does things like you can do you can do have post build steps that may be signs that that's code sign to your code see you can have you can have unit tests integrated into your code there's other kinds of other things you can now do without depending on the producer or your build system having that option mm-hmm great yeah so we have a question from Michael is this your modular framework I'm not sure if I understand that question it's my modular framework no this is not a modular framework this is this is just a this is a oh maybe we should say for people who just joined so this is a public posit Ori that I have on github if you go on to AOL Amir github maybe just I'm just yeah great ooh I am working on all kinds of all kinds of like things internally that I'm doing for my own project so for extra like I have all kinds of like libraries than writing for me work yeah so so I guess I guess that I should I guess that I should mention that or as PL has said earlier in this tutorial if you might have missed it that for most people the producer is probably the way to go in terms of what you need to do this is more for people that may have larger code bases where you have a number of plugins that you're building across or that you need to build or you have shared code where people are using some people are using Visual Studio but other people are using Xcode and you have other libraries that you want to use that you don't necessarily do siz n't necessarily at the center of what you're building this these are use cases for using C make rather than using the producer but if you're typically just building your app in juice and juice is at the very center of what you're looking to do then the producer will be able to serve most of your needs so yes exactly [Music] exactly so this is I mean obviously this is an advanced way of setting up but it also adds R of options because for example if you use if you wanna code with something that isn't supported by the producer like Visual Studio code or something you this is this is the way to do it there's no like if you can just automatically start coding in juice in Visual Studio code without yeah same for other other kinds of IDs like now you know if you want to use something a cute creator more oh but basically now almost every IDE is either supporting Simek natively or there's an exporter for it and by using C make - G whenever IDE name is so it's it's it also opens up a lot of options for developers who are used to working in in a different environment right yeah I know that for example sea lion I mean juice does have a sea lion exporter that exists but it didn't have all functionality that the Xcode exporter had so I what I did for a long time was edit on sealion but then switched to Xcode just to get a very stable build mm-hmm because and I'm guessing that's just because it's very hard for the juice team to always keep track on the latest IDs and the different functions needed to have a build but with C make it's actually very simple it's very it's very simple to say here's how juice will build correctly on all platforms and juice doesn't have to maintain every IDE problem yeah that's really interesting mark says thanks for the contribution to the live stream that we did a few weeks ago and that was that was a lot of fun as well yeah great absolutely yeah the questions from anybody in the chat answer seems seems like everybody satisfied of ready to go off into the world of C make and yeah I'm I'm I'd like to check it out as well very soon and yeah I think this seems like a natural place for us to wrap up so this will this will actually be available online after we're finished as well so if you're like me and forget quite easily then you can go back and you can review and you can watch it and double time or half time and get it just keep repeating it until you get it and always like I said before feel free if you get lost to put a comment in the comments or to join us on the discord and we will be able to to help you out but thank you if you're actually pulling through or going through with you know working see make definitely read the documentation the juice has provided in in the juice six branch that documentation is better than any explanation that I can do I'm not an expert like I must have one way of doing things that kind of worked but it's much better to just really the commutation or maybe talk to people like Ruben or others in discord in the juice forum I mean hopefully my examples will be like a bridge for people who have no idea to how to even start to just start like you just grab the repo load it or type the command yeah that's it but there's like if you want to dive deeper into it there's there's better knowledge than my examples for sure yeah yeah and also another great resource of course for Fugees questions is the g's forum and they're it's a great resource especially if you're looking for a specific if you have a specific problem even outside of c make and you need to search for how to do something let's say you want to learn how to create a delay and you have no idea where to get started juice forum is a great resource where you can just go hit the search function type juice delay and somebody will likely have asked the question that you're wondering about so so yeah so thank you very much and thank you very much for ribbon for joining us as well in the in the live chat thanks for contributing your time and we will continue on this discussion as well I think at some point I'm going to maybe do a hello world from scratch with C baked and and maybe that'll help people along as well so yes we'll wrap up here thank you again yeah for your time and do and we will see you again soon
Info
Channel: The Audio Programmer
Views: 3,199
Rating: 4.8878503 out of 5
Keywords:
Id: FKVK7TyEJ5g
Channel Id: undefined
Length: 90min 12sec (5412 seconds)
Published: Fri May 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.