![clion makefile clion makefile](https://resources.jetbrains.com/help/img/idea/2020.1/cl_filewatchers_makefilechange_example2result.png)
Let's open the makefile, and I will talk about it in some phrases. Figuring out the makefile is helpful for us to comprehend what the compiler is doing when we compile the project. Since we use armgcc compiler, we go to that folder in the ble_app_hrs project, a Makefile is there. Let go deeper into the example you want to build. That is, easy to write, right? Now we enter the complicated part. Set(ARM_TOOLCHAIN_PATH /usr/local/gcc-arm-none-eabi-6-2017-q2-update/bin)Īdd_subdirectory("examples/ble_peripheral/ble_app_hrs/pca10056/s140/armgcc") # Indicate the toolchain path in your system # CMakeList must have a minimum required version in the root file In the root CMakeList.txt file, we need to set some variables. I choose a multiple layer structure to manage every sub cmakelist files, that makes the compiling structure more clearly.
#Clion makefile code
CMakeLists.txt is like your code file, can be an entire file or many separated files. Then, create a new empty 'CMakeLists.txt' in the SDK root directory. In CLion, choose File -> Open, open the SDK folder you have extracted. The first thing we are going to do, is to write a feasible CMakeLists.txt, which is used by CMake tools in CLion. Then extract the compressed file to a folder, like nRF5SDK in your home directory.ĬLion is a brilliant product for developers to build their product on a cross-compiling platform, a lot of features of CLion make your developing work faster and easier, yeah, the IAR and Keil are not smart yet, but anyway, those two products are easier for you to compile and download, they are excellent products.ĬLion uses CMake to help you create the correct compiling file, the Makefile, then build and link all the output files to the target file you want, like the hex file and binary file we needed in the embedded system development. The SDK version I used is nRF5_SDK_15.1.0.
#Clion makefile download
Download the nRF52 SDK from Nordic website. And activate the product.Īfter the system is ready, we are going to the first step. It seems that we don't have a chance to use it in this project.ĭownload the latest version of CLion of Jetbrain. The ARM Toolchain I used is: gcc-arm-none-eabi-6-2017-q2-update.Īlso, my GCC and G++ versions in Ubuntu 18.04 have been downgraded to 4.8.5. Make sure you have downloaded the ARM compiling toolchain and set the environment variable. My OS is Ubuntu 18.04 LTS, which is installed in a Dell XPS laptop. Hopefully, we can make the project together, and more clear for developers to build their own cross-compiling platform.
![clion makefile clion makefile](https://img-blog.csdnimg.cn/20190128112527203.png)
I think the first version is not tiny, but it's easy to read, modify and transplant in your project. Right now, using CLion with the CMakeList can compile the hex and binary file successfully. Target is the name created in the first step, and XX.bin is the file to be executed after make.After days of figuring out how CMake works, I try to write a CMakeList.txt myself, and decide to put my progress on this community. The second step is to build: run->edit configuatation When compile_commands.json is opened with CLion, open this file directly, and the entire directory will be opened.ģ.1 Debug by creating a new CMakeLists.txt, because I did not perform this operation, the specific details are for everyone to explore.compile_commands.json just allows you to jump when editing the source code, it has no effect on compiling and running.CMakeLists.txt and compile_commands.json files should not coexist, originally this json file is only used to configure the project (Configure Projects).Only use Clion to open the compile_commands.json file will automatically open the entire project.Delete the CMakeLists.txt file manually made before.In fact, you can directly open compile_commands.json and follow the prompts to open the project file. It is found that the Build icon is gray, and Sync cannot be viewed. You may see it in a few seconds, and then display the "Compiler Info" tab in the "Build" tool window, telling you that everything is complete (you can see any errors or in the "Sync" tab caveat) ). Compiledb -nf make generates compile_commands.json on the makefile in the shell.Īccording to the previous article: After opening the project, CLion will detect the compile_commands.json file and view its project information.