patrislav1 / cubemx.cmake

Script collection to build CubeMX projects with CMake and debug them with VSCode
The Unlicense
35 stars 10 forks source link

Python errors when IOC file not found #1

Closed BenBE closed 3 years ago

BenBE commented 3 years ago

When the main CMakeLists.txt references a CubeMX project file that does not exist, the Python script throws stacktraces about the file not existing, instead of some plain small error line that CMake could pick up and prematurely abort configuration.

Steps to reproduce:

  1. Rename CMakeLists-example.txt to CMakeLists.txt
  2. mkdir build
  3. cd build
  4. cmake ..

Expected behaviour: Clear indication that cmake aborts after the first signs the project file does not exist.

Actual Result: Loads of python backtraces and cmake continuing along …

user@host:~/cubemx.cmake (master[origin])$ cp CMakeLists-example.txt CMakeLists.txt 
user@host:~/cubemx.cmake (master[origin])$ mkdir build
user@host:~/cubemx.cmake/build (master[origin])$ cd build/
user@host:~/cubemx.cmake/build (master[origin])$ cmake ..
-- Found Python3: /usr/bin/python3.8 (found version "3.8.5") found components: Interpreter 
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
Traceback (most recent call last):
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 60, in <module>
    iocConf = loadIOC(args.iocFile)
  File "/home/user/cubemx.cmake/cmake/cubemx-cmake.py", line 9, in loadIOC
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/cubemx.cmake/cubemx_project.ioc'
CMake Error at CMakeLists.txt:11 (project):
  project PROJECT called with incorrect number of arguments

CMake Error at CMakeLists.txt:14 (cubemx_target):
  cubemx_target Function invoked with incorrect arguments for function named:
  cubemx_target

CMake Error at CMakeLists.txt:15 (target_compile_options):
  Cannot specify compile options for target "PRIVATE" which is not built by
  this project.

-- Configuring incomplete, errors occurred!
See also "/home/user/cubemx.cmake/build/CMakeFiles/CMakeOutput.log".