STM32-Template icon indicating copy to clipboard operation
STM32-Template copied to clipboard

Adding a CMakeLists.txt

Open arctangerines opened this issue 1 year ago • 0 comments

Hello! I have a CMakeLists.txt version of the Makefile and Makefile.common and I think it'd be a good idea to add it, some of my reasons are:

  1. A decent amount of people use IDEs for their projects, sure, Makefiles work well enough with IDEs but not always
    • And even if they don't use IDEs, a CMakeLists.txt does make life easier for debugging and suggestions/completions
  2. I think a CMakeLists.txt that can be used as a template is in line with what is taught/learned through the Discovering STM32 book
  3. And it gives the user freedom of choice!

Now, some details regarding the CMakeLists.txt file I have been using:

  • It is a single file that simulates both the Makefile and the Makefile.common, I am open to changing it from 1 file to 2 files that are closer to the current Makefile layout if it's truly wanted/needed
  • There are modifications that I know I'd have to make so its more of a template, namely:
    • Lines 14 to 16 which just link the library directly, instead I would add the LIBROOT so it matches the Makefile.common
    • Adding TOOLROOT as well since my compiler is available in the search path and installed system-wide but that is not the case for everyone
    • Organize the file a bit more since I was jumping between looking at what the Makefile and Makefile.common did and modifying or adding things as I needed them
    • As you can see on lines 29 to 35 we have to manually add the files, I would add variables so we shorten this
      • Example: ${PERIPH_SRC}/stm32f10x_gpio.c
      • Obviously the naming convention is up for discussion haha

Excited to hear what you think about this idea!

arctangerines avatar Feb 13 '24 20:02 arctangerines