imgtec-riscv / catapult-sdk

Imagination Technologies Catapult SDK RISC-V Software Development Kit
Other
9 stars 0 forks source link

CMake error when building code example #13

Closed kunjsong01 closed 1 week ago

kunjsong01 commented 2 weeks ago

Describe the bug When building examples/apps/hello CMake failed in the configuration step :

[proc] Executing command: /opt/imgtec/catapult-sdk/Helpers/build/bin/cmake -S/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello -B/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build -G Ninja
[proc] The command: /opt/imgtec/catapult-sdk/Helpers/build/bin/cmake -S/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello -B/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build -G Ninja exited with code: 1
[main] Configuring project: hello 
[driver] Removing /Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build/CMakeCache.txt
[driver] Removing /Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build/CMakeFiles
[proc] Executing command: /opt/imgtec/catapult-sdk/Helpers/build/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DSEMIHOSTING:STRING=ON -DLINUX:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DPLATFORM=RTXM2200MODEL -DCMAKE_MAKE_PROGRAM=/opt/imgtec/catapult-sdk/Helpers/build/bin/ninja --no-warn-unused-cli -S/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello -B/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is AppleClang 15.0.0.15000309
[cmake] -- The ASM compiler identification is AppleClang
[cmake] -- Found assembler: /Library/Developer/CommandLineTools/usr/bin/cc
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- @@ PLATFORM=RTXM2200MODEL
[cmake] -- @@ CMAKE_TOOLCHAIN_FILE=
[cmake] -- Configuring incomplete, errors occurred!
[cmake] CMake Error at /Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/riscv-sw-common/Common.cmake:51 (get_filename_component):
[cmake]   get_filename_component called with incorrect number of arguments
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:10 (include)
[cmake] 
[cmake] 
[proc] The command: /opt/imgtec/catapult-sdk/Helpers/build/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DSEMIHOSTING:STRING=ON -DLINUX:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DPLATFORM=RTXM2200MODEL -DCMAKE_MAKE_PROGRAM=/opt/imgtec/catapult-sdk/Helpers/build/bin/ninja --no-warn-unused-cli -S/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello -B/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build -G Ninja exited with code: 1
[main] Configuring project: hello 
[proc] Executing command: /opt/imgtec/catapult-sdk/Helpers/build/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DSEMIHOSTING:STRING=ON -DLINUX:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DPLATFORM=RTXM2200MODEL -DCMAKE_MAKE_PROGRAM=/opt/imgtec/catapult-sdk/Helpers/build/bin/ninja --no-warn-unused-cli -S/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello -B/Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/hello/build -G Ninja --debugger --debugger-pipe /tmp/cmake-debugger-pipe-fb462646-2592-41bd-8bb9-8a4bc1caedf7
[cmake] Not searching for unused variables given on the command line.
[cmake] Running with debugger on.
[cmake] Waiting for debugger client to connect...
[debugger] Connecting debugger on named pipe: "/tmp/cmake-debugger-pipe-fb462646-2592-41bd-8bb9-8a4bc1caedf7"
[cmake] Debugger client connected.
[cmake] -- @@ PLATFORM=RTXM2200MODEL
[cmake] -- @@ CMAKE_TOOLCHAIN_FILE=
[cmake] CMake Error at /Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/riscv-sw-common/Common.cmake:51 (get_filename_component):
[cmake]   get_filename_component called with incorrect number of arguments
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:10 (include)
[cmake] 
[cmake] 

SDK version 2024.2.1

To Reproduce Steps to reproduce the behavior:

  1. Follow the Catapult SDK (2024.2.1) Documentation to install the Catapult SDK and VSCode extensions
  2. Follow the Environment Variables for Using Catapult SDK to set the PATH
  3. Open /Users/<user_name>/catapult-sdk_examples/2024.2.1/examples/apps/hello in VSCode
  4. Select platform RTXM2200MODEL
  5. CMake failed in the Configure step with the error aforementioned

Expected behavior Expected a successful build.

Screenshots CMake Debug: Screenshot 2024-08-26 at 11 30 11

Host OS (please complete the following information):

Edit: Also failed on Ubuntu 22.04

RISC-V development platform: RTXM2200MODEL

Additional context I added some debug message in the following patch

diff --git a/Common_backup.cmake b/Common.cmake
index 4284bd4..7db1e5a 100644
--- a/Common_backup.cmake
+++ b/Common.cmake
@@ -38,6 +38,8 @@ if((CLANG_TARGET MATCHES "linux") OR (CMAKE_C_COMPILER MATCHES "linux") OR (CMAK
   set(LDGEN OFF)
 endif()

+message(STATUS "@@ PLATFORM=${PLATFORM}")^M
+^M
 # Set default platform
 if(NOT PLATFORM)
     message(FATAL_ERROR "Please define PLATFORM")
@@ -45,6 +47,7 @@ endif()

 # Get path to the build directory and use it to assemble the path to the
 # platform directory
+message(STATUS "@@ CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")^M
 get_filename_component(BUILD_DIR ${CMAKE_TOOLCHAIN_FILE} DIRECTORY)
 set(PLATFORM_DIR "${BUILD_DIR}/platform")
 set(UART_DRIVER_DIR ${CMAKE_CURRENT_LIST_DIR}/drivers/uart)

The root cause appears to be CMAKE_TOOLCHAIN_FILE not set to anything.

[cmake] -- @@ PLATFORM=RTXM2200MODEL
[cmake] -- @@ CMAKE_TOOLCHAIN_FILE=
[cmake] -- Configuring incomplete, errors occurred!
[cmake] CMake Error at /Users/kunjian/catapult-sdk_examples/2024.2.1/examples/apps/riscv-sw-common/Common.cmake:51 (get_filename_component):
[cmake]   get_filename_component called with incorrect number of arguments
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:10 (include)
WiseCrohn commented 1 week ago

Hi @kunjsong01 , in the CMake tab of VSCode, Configure section, please ensure that a kit is selected: either Catapult SDK gcc-elf or Catapult SDK clang. Please let me know if this solves the problem.

WiseCrohn commented 1 week ago

Note there has been a bug in the CMake tools extension recently (https://github.com/microsoft/vscode-cmake-tools/issues/3901) which caused it to fail to ask the user to select a kit, resulting in the kit being listed as __unspec__. This has now been fixed in CMake tools versions > 1.19. This may be causing users to hit this problem.

kunjsong01 commented 1 week ago

Hi @WiseCrohn

Thanks very much for the answers.

The issue is precisely as you have described in the above comment.

My CMake Tools version is v1.19.51 and there was no user prompt to select a kit after opening the hello example in VSCode, leaving the kit __unspec__ in CMake configure:

CMake_unspec

Following your proposed solution, the issue has been resolved using the steps below:

  1. Click the 'Edit' button then select Catapult SDK gcc-elf
  2. Ctrl+Shift+p, run CMake action CMake: Delete Cache and Reconfigure
  3. then run action CMake: Build

The hello example was successfully built and executed:

[build] Build finished with exit code 0
[main] Building folder: /home/ks/catapult-sdk_examples/2024.2.1/examples/apps/hello/build 
[build] Starting build
[proc] Executing command: /opt/imgtec/catapult-sdk_2024.2.1/build/bin/cmake --build /home/ks/catapult-sdk_examples/2024.2.1/examples/apps/hello/build --config Debug --target all --
[build] [1/2  50% :: 0.031] Building C object CMakeFiles/hello.elf.dir/hello.c.obj
[build] [2/2 100% :: 0.307] Linking C executable hello.elf
[driver] Build completed: 00:00:00.322
[build] Build finished with exit code 0

Screenshot from 2024-09-06 12-37-24

kunjsong01 commented 1 week ago

Updated the environment to VSCode v1.93 with CMake Tools 1.91.51 and got the user prompts in order - compiler selection followed by the platform selection before CMake configuration stage.