Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using HINTS for STM Toolchain Path #266

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

robamu
Copy link
Contributor

@robamu robamu commented Aug 10, 2021

This causes toolchains found via the STM32_TOOLCHAIN_PATH variable
to take precedence over a toolchain in the system path.
Also updated README accordingly

Fixes #251 . Closes #265

This causes toolchains found via the STM32_TOOLCHAIN_PATH variable
to take precedence over a toolchain in the system path
Copy link
Collaborator

@Hish15 Hish15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

What is the confidence on the TOOLCHAIN_BIN_PATH correctness?

If I quote cmake's find packages doc :

Search paths specified by the HINTS option. These should be paths computed by system introspection, such as a hint provided by the location of another item already found. Hard-coded guesses should be specified with the PATHS option.

@atsju
Copy link
Collaborator

atsju commented Aug 15, 2021

Hi,

What is the confidence on the TOOLCHAIN_BIN_PATH correctness?

If I quote cmake's find packages doc :

Search paths specified by the HINTS option. These should be paths computed by system introspection, such as a hint provided by the location of another item already found. Hard-coded guesses should be specified with the PATHS option.

Hi,
I think you want documentation of find_program and not find_package. I agree spirit is exactly same. You can judge the confidence here :

if(NOT STM32_TOOLCHAIN_PATH)
if(DEFINED ENV{STM32_TOOLCHAIN_PATH})
message(STATUS "Detected toolchain path STM32_TOOLCHAIN_PATH in environmental variables: ")
message(STATUS "$ENV{STM32_TOOLCHAIN_PATH}")
set(STM32_TOOLCHAIN_PATH $ENV{STM32_TOOLCHAIN_PATH})
endif()
if(NOT CMAKE_C_COMPILER)
set(STM32_TOOLCHAIN_PATH "/usr")
message(STATUS "No STM32_TOOLCHAIN_PATH specified, using default: " ${STM32_TOOLCHAIN_PATH})
else()
# keep only directory of compiler
get_filename_component(STM32_TOOLCHAIN_PATH ${CMAKE_C_COMPILER} DIRECTORY)
# remove the last /bin directory
get_filename_component(STM32_TOOLCHAIN_PATH ${STM32_TOOLCHAIN_PATH} DIRECTORY)
endif()
file(TO_CMAKE_PATH "${STM32_TOOLCHAIN_PATH}" STM32_TOOLCHAIN_PATH)
endif()
if(NOT STM32_TARGET_TRIPLET)
set(STM32_TARGET_TRIPLET "arm-none-eabi")
message(STATUS "No STM32_TARGET_TRIPLET specified, using default: " ${STM32_TARGET_TRIPLET})
endif()
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_SYSROOT "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}")
set(TOOLCHAIN_BIN_PATH "${STM32_TOOLCHAIN_PATH}/bin")
set(TOOLCHAIN_INC_PATH "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}/include")
set(TOOLCHAIN_LIB_PATH "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}/lib")

Maybe PATH is better than HINTS in the spirit but I doesn't work. See related issue.

@Hish15
Copy link
Collaborator

Hish15 commented Aug 16, 2021

Well, we want things to work so lets go for the HINT thing then. cmake's documentation is quite poor on the difference between PATH and HINTS anyway.

@Hish15 Hish15 merged commit e3a60ac into ObKo:master Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could no set path of compiler
3 participants