Skip to content

Commit eeac56e

Browse files
committed
Merge remote-tracking branch 'origin/noinstall' into noinstall
2 parents 57b440d + 1df619d commit eeac56e

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

CMakeLists.txt

+7-23
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,6 @@ function(teensy_set_dynamic_properties)
4141
if (NOT DEFINED teensy_set_dynamic_properties_has_executed)
4242
set(teensy_set_dynamic_properties_has_executed 1 CACHE INTERNAL "teensy_set_dynamic_properties_has_executed")
4343
message(STATUS "teensy_set_dynamic_properties()")
44-
45-
message(CHECK_START "identify root dependency path")
46-
if (NOT DEFINED DEPSPATH)
47-
message(FATAL_ERROR "DEPSPATH is UNDEFINED")
48-
else()
49-
message(STATUS "DEPSPATH: ${DEPSPATH}")
50-
endif()
51-
message(CHECK_PASS "identified")
52-
53-
54-
55-
if (NOT DEFINED COREPATH)
56-
set(COREPATH "${DEPSPATH}/cores/teensy4/")
57-
set(COREPATH ${COREPATH} CACHE INTERNAL "COREPATH")
58-
message(STATUS "COREPATH: ${COREPATH}")
59-
else()
60-
message(STATUS "COREPATH: ${COREPATH}")
61-
endif()
6244

6345
if (NOT DEFINED CPU_CORE_SPEED)
6446
message(FATAL_ERROR "CPU_CORE_SPEED is UNDEFINED")
@@ -108,7 +90,7 @@ function(teensy_set_dynamic_properties)
10890
elseif(TEENSY_VERSION EQUAL 41)
10991
message(STATUS "building for teensy 4.1")
11092
set(CPU_DEFINE __IMXRT1062__)
111-
set(LINKER_FILE ${COREPATH}imxrt1062_t41.ld)
93+
set(LINKER_FILE ${teensy_cores_SOURCE_DIR}/teensy4/imxrt1062_t41.ld)
11294
set(build_board TEENSY41)
11395
set(build_flags_ld " -Wl,--gc-sections,--relax ")
11496
set(build_core teensy4)
@@ -262,7 +244,9 @@ function(teensy_add_library TARGET)
262244
endforeach(SOURCE_S ${SOURCES_S})
263245

264246
add_library(${ELFTARGET} STATIC ${ARGN} ${TEENSY_SOURCES} ${TEENSY_LIB_CPP_SOURCES} ${TEENSY_LIB_C_SOURCES} ${TEENSY_LIB_S_SOURCES})
265-
set_target_properties(${ELFTARGET} PROPERTIES INCLUDE_DIRECTORIES ${COREPATH})
247+
if (COREPATH)
248+
set_target_properties(${ELFTARGET} PROPERTIES INCLUDE_DIRECTORIES ${COREPATH})
249+
endif ()
266250
set_target_properties(${ELFTARGET} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
267251

268252
add_custom_command(OUTPUT ${TARGET}.hex
@@ -366,14 +350,14 @@ macro(import_arduino_library_git LIB_NAME LIB_URL LIB_BRANCH LIB_PATH)
366350
GIT_TAG ${LIB_BRANCH}
367351
)
368352
FetchContent_MakeAvailable(${LIB_NAME})
369-
set(LIB_ROOT "${${LIB_NAME}_SOURCE_DIR}/${LIB_PATH}")
353+
string(TOLOWER ${LIB_NAME} LIB_NAME_LOWER)
354+
set(LIB_ROOT "${${LIB_NAME_LOWER}_SOURCE_DIR}/${LIB_PATH}")
370355

371-
message(STATUS "import_arduino_library_git(${LIB_NAME} ${LIB_URL} ${LIB_BRANCH} ${LIB_ROOT} ${ARGN})")
372356
# Check if we can find the library.
373357
if(NOT EXISTS "${LIB_ROOT}")
374358
message(STATUS "Could not find the directory for library '${LIB_ROOT}' -- ignoring (its possible that the library is not used for the target you are calling) !!!!!")
375359
else()
376360
import_arduino_library(${LIB_NAME} ${LIB_ROOT} ${ARGN})
377361
endif(NOT EXISTS "${LIB_ROOT}")
378362

379-
endmacro(import_arduino_library_git)
363+
endmacro(import_arduino_library_git)

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,37 @@
1212
* targetting Teensy 4.x, tested on Teensy 4.1 (should be easy to extend for 3.x)
1313
* compiles library code to .a archive files to avoid unnecessary recompiling
1414

15+
* add a toolchain cmake file `cmake\toolchains\teensy41.cmake`
16+
<details>
17+
18+
```cmake
19+
set(TEENSY_VERSION 41 CACHE STRING "Set to the Teensy version corresponding to your board (30 or 31 allowed)" FORCE)
20+
set(CPU_CORE_SPEED 600000000 CACHE STRING "Set to 24000000, 48000000, 72000000 or 96000000 to set CPU core speed" FORCE) # Derived variables
21+
set(CMAKE_EXE_LINKER_FLAGS "--specs=nano.specs" CACHE INTERNAL "")
22+
#teensy compiler options
23+
set(COMPILERPATH "/Applications/ARM/bin/")
24+
25+
add_definitions(-DTEENSY_VERSION=${TEENSY_VERSION})
26+
include(FetchContent)
27+
28+
FetchContent_Declare(teensy_cores
29+
GIT_REPOSITORY https://github.com/PaulStoffregen/cores
30+
GIT_TAG master
31+
)
32+
FetchContent_MakeAvailable(teensy_cores)
33+
34+
FetchContent_Declare(teensy_cmake_macros
35+
GIT_REPOSITORY https://github.com/newdigate/teensy-cmake-macros
36+
GIT_TAG noinstall
37+
)
38+
FetchContent_MakeAvailable(teensy_cmake_macros)
39+
include(${teensy_cmake_macros_SOURCE_DIR}/CMakeLists.txt)
40+
set(BUILD_FOR_TEENSY ON)
41+
```
42+
</details>
43+
44+
`cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE:FILEPATH="../cmake/toolchains/teensy41.cmake`
45+
1546
## TL/DR
1647
<details>
1748
<summary>install build dependencies (click to expand) </summary>

0 commit comments

Comments
 (0)