1
- # Copyright (c) 2020 ARM Limited. All rights reserved.
1
+ # Copyright (c) 2024 ARM Limited. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
3
4
4
# ----------------------------------------------
5
5
# CMake finder for STMicro's STM32 upload and debugging tools
6
6
#
7
7
# This module accepts the following components (blame ST for the capitalization, not me):
8
- # STM32CubeProg
9
- # STLINK_gdbserver
8
+ # - STM32CubeProg
9
+ # - STLINK_gdbserver
10
10
#
11
11
# This module defines:
12
12
# STLINKTools_FOUND - Whether the requested components were found.
15
15
# STM32CubeProg_COMMAND - Command to run the STM32 command line programmer.
16
16
# STLINK_gdbserver_COMMAND - Command to run the ST-Link GDB server.
17
17
18
- # first try to locate STM32Cube IDE in its default location
18
+ # first try to locate STM32CubeXXX tools in their default location
19
19
set (STM32CUBE_IDE_LINUX_HINTS "" )
20
20
set (STM32CUBE_IDE_WINDOWS_HINTS "" )
21
+ set (STM32CUBE_CLT_LINUX_HINTS "" )
22
+ set (STM32CUBE_CLT_WINDOWS_HINTS "" )
21
23
if (EXISTS "/opt/st" )
22
24
# Linux directory has version number
23
- file (GLOB STM32CUBE_IDE_LINUX_HINTS LIST_DIRECTORIES TRUE "/opt/st/*" )
25
+ file (GLOB STM32CUBE_IDE_LINUX_HINTS LIST_DIRECTORIES TRUE "/opt/st/stm32cubeide*" )
26
+ file (GLOB STM32CUBE_CLT_LINUX_HINTS LIST_DIRECTORIES TRUE "/opt/st/stm32cubeclt*" )
24
27
endif ()
25
28
if (EXISTS "C:/ST/" )
26
- # On Windows, STM32CubeIDE by default is installed into a subdirectory of
27
- # C:\ST\STM32CubeIDE_ <version>\STM32CubeIDE , but may also be installed into
28
- # C:\ST\STM32CubeIDE directly
29
+ # On Windows, STM32CubeXXX tools by default are installed into a subdirectory of
30
+ # C:\ST\STM32CubeXXX_ <version>\STM32CubeXXX , but may also be installed into
31
+ # C:\ST\STM32CubeXXX directly
29
32
30
33
# Identify all the subdirectories and sub-subdirectories of C:\ST
31
- file (GLOB STM32CUBE_IDE_WINDOWS_HINTS LIST_DIRECTORIES TRUE "C:/ST/*/*" "C:/ST/*" )
34
+ file (GLOB STM32CUBE_IDE_WINDOWS_HINTS LIST_DIRECTORIES TRUE "C:/ST/STM32CubeIDE*/*" "C:/ST/STM32CubeIDE*" )
35
+ file (GLOB STM32CUBE_CLT_WINDOWS_HINTS LIST_DIRECTORIES TRUE "C:/ST/STM32CubeCLT*/*" "C:/ST/STM32CubeCLT*" )
32
36
endif ()
33
37
find_path (STM32CUBE_IDE_PATH
34
38
NAMES stm32cubeide.ini
35
- DOC "Path to STM32Cube IDE . Used to find the ST-Link Tools"
39
+ DOC "Path to STM32CubeIDE . Used to find the ST-Link Tools"
36
40
PATHS
37
41
${STM32CUBE_IDE_WINDOWS_HINTS} # Windows
38
42
${STM32CUBE_IDE_LINUX_HINTS} # Linux
39
43
/Applications/STM32CubeIDE.app/Contents/Eclipse # OS X
40
44
)
45
+ find_path (STM32CUBE_CLT_PATH
46
+ NAMES
47
+ STM32CubeCLT_metadata.bat # Windows
48
+ STM32CubeCLT_metadata.sh # Linux
49
+ DOC "Path to STM32CubeCLT. Used to find the ST-Link Tools"
50
+ PATHS
51
+ ${STM32CUBE_CLT_WINDOWS_HINTS} # Windows
52
+ ${STM32CUBE_CLT_LINUX_HINTS} # Linux
53
+ #/Applications/STM32CubeIDE.app/Contents/Eclipse # OS X
54
+ )
41
55
42
56
set (STLINKTools_HINTS "" )
43
- if (EXISTS "${STM32CUBE_IDE_PATH} " )
57
+ if (EXISTS "${STM32CUBE_CLT_PATH} " )
58
+ message (STATUS "Located STM32CubeCLT: ${STM32CUBE_CLT_PATH} " )
59
+
60
+ # find install dirs inside IDE, which also have version numbers
61
+ file (GLOB GDB_SERVER_INSTALL_DIRS LIST_DIRECTORIES TRUE "${STM32CUBE_CLT_PATH} /STLink-gdb-server/bin" )
62
+ list (GET GDB_SERVER_INSTALL_DIRS 0 GDB_SERVER_INSTALL_DIR ) # If glob returns multiple just pick one
63
+ if (EXISTS "${GDB_SERVER_INSTALL_DIR} " )
64
+ list (APPEND STLINKTools_HINTS ${GDB_SERVER_INSTALL_DIR} )
65
+ endif ()
66
+
67
+ file (GLOB CUBEPROG_INSTALL_DIRS LIST_DIRECTORIES TRUE "${STM32CUBE_CLT_PATH} /STM32CubeProgrammer/bin" )
68
+ list (GET CUBEPROG_INSTALL_DIRS 0 CUBEPROG_INSTALL_DIR ) # If glob returns multiple just pick one
69
+ if (EXISTS "${CUBEPROG_INSTALL_DIR} " )
70
+ list (APPEND STLINKTools_HINTS ${CUBEPROG_INSTALL_DIR} )
71
+ endif ()
72
+ elseif (EXISTS "${STM32CUBE_IDE_PATH} " )
44
73
message (STATUS "Located STM32CubeIDE: ${STM32CUBE_IDE_PATH} " )
45
74
46
75
# find install dirs inside IDE, which also have version numbers
@@ -55,8 +84,8 @@ if(EXISTS "${STM32CUBE_IDE_PATH}")
55
84
if (EXISTS "${CUBEPROG_INSTALL_DIR} " )
56
85
list (APPEND STLINKTools_HINTS ${CUBEPROG_INSTALL_DIR} )
57
86
endif ()
58
- elseif ()
59
- set (FAIL_MESSAGE_ARG FAIL_MESSAGE "Warning: Failed to find STM32CubeIDE , will still look for ST-LINK tools on your PATH. Recommend setting STM32CUBE_IDE_PATH to the location of STM32CubeIDE." )
87
+ else ()
88
+ set (FAIL_MESSAGE_ARG FAIL_MESSAGE "Warning: Failed to find STM32CubeCLT or IDE , will still look for ST-LINK tools on your PATH. Recommend setting STM32CUBE_IDE_PATH to the location of STM32CubeIDE or STM32CUBE_CLT_PATH to the location of STM32CubeCLT ." )
60
89
endif ()
61
90
set (STLINKTools_REQUIRED_VARS "" )
62
91
@@ -107,5 +136,3 @@ if(EXISTS "${STLINK_gdbserver_PATH}")
107
136
endif ()
108
137
109
138
find_package_handle_standard_args (STLINKTools REQUIRED_VARS ${STLINKTools_REQUIRED_VARS} )
110
-
111
-
0 commit comments