Skip to content

Commit

Permalink
CMakeLists.txt: use abs pathes instead of relatives, move cyphal and …
Browse files Browse the repository at this point in the history
…dronecan related CMake logic to their own files
  • Loading branch information
PonomarevDA committed Jan 5, 2024
1 parent dde7239 commit 72721de
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 48 deletions.
44 changes: 10 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,31 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(PLATFORM bxcan)
set(stm32cubeMxProjectPath ${CMAKE_CURRENT_LIST_DIR}/Libs/stm32-cube-project)
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})

# libparams
set(LIBPARAMS_PATH ${ROOT_DIR}/Libs/libparams)
set(LIBPARAMS_PLATFORM stm32f103)
include(${ROOT_DIR}/Libs/libparams/CMakeLists.txt)

if(USE_DRONECAN)
set(LIBPARAMS_PATH ${CMAKE_CURRENT_LIST_DIR}/Libs/libparams)
set(LIBPARAMS_PLATFORM stm32f103)
include(Libs/libsqcan/CMakeLists.txt)
include(Libs/libparams/CMakeLists.txt)
set(libsSourceCode
${libparamsSrc}
${dronecanSources}
)
set(libsHeaders
${libparamsHeaders}
${dronecanHeaders}
)
include(Src/dronecan_application/CMakeLists.txt)
include(${ROOT_DIR}/Src/dronecan_application/CMakeLists.txt)
else()
set(libparamsPath ${CMAKE_CURRENT_LIST_DIR}/Libs/libparams)
add_definitions(-DBXCAN_MAX_IFACE_INDEX=0)
include(Libs/Cyphal/CMakeLists.txt)
set(libsSourceCode ${CYPHAL_SRC})
set(libsHeaders
Libs/Cyphal/Cyphal
Libs/Cyphal/Libs/libcanard/libcanard
${libparamsPath}/libparams
Libs/Cyphal/Libs/o1heap/o1heap
build/nunavut_out
)
set(cyphalRegisters ${CMAKE_CURRENT_LIST_DIR}/Libs/Cyphal/Cyphal/params.yaml)
include(Src/cyphal_application/CMakeLists.txt)
list(APPEND applicationSourceCode
build/src/params.cpp
build/src/string_params.cpp
)
include(${ROOT_DIR}/Src/cyphal_application/CMakeLists.txt)
endif()


set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_CXX_STANDARD 20)

set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project)
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Src/*.c*)

set(gitRelatedHeaders
build/src
${ROOT_DIR}/build/src
)

set(stm32CubeMxGeneratedFiles
Expand Down
36 changes: 28 additions & 8 deletions Src/cyphal_application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH SRC_DIR)
cmake_path(GET SRC_DIR PARENT_PATH ROOT_DIR)

set(PLATFORM bxcan)
set(libparamsPath ${ROOT_DIR}/Libs/libparams)
add_definitions(-DBXCAN_MAX_IFACE_INDEX=0)
include(${ROOT_DIR}/Libs/Cyphal/CMakeLists.txt)
set(libsSourceCode ${CYPHAL_SRC})
set(libsHeaders
${ROOT_DIR}/Libs/Cyphal/Cyphal
${ROOT_DIR}/Libs/Cyphal/Libs/libcanard/libcanard
${libparamsPath}/libparams
${ROOT_DIR}/Libs/Cyphal/Libs/o1heap/o1heap
${ROOT_DIR}/build/nunavut_out
)

set(applicationSourceCode
Src/periphery/pwm/pwm.cpp
Src/periphery/led/led.cpp
${ROOT_DIR}/Src/periphery/pwm/pwm.cpp
${ROOT_DIR}/Src/periphery/led/led.cpp

${ROOT_DIR}/Src/cyphal_application/setpoint/setpoint.cpp
${ROOT_DIR}/Src/cyphal_application/feedback/feedback.cpp
${ROOT_DIR}/Src/cyphal_application/application.cpp

Src/cyphal_application/setpoint/setpoint.cpp
Src/cyphal_application/feedback/feedback.cpp
Src/cyphal_application/application.cpp
${ROOT_DIR}/build/src/params.cpp
${ROOT_DIR}/build/src/string_params.cpp
)
set(applicationHeaders
Src
Src/cyphal_application
Libs/Cyphal
${ROOT_DIR}/Src
${ROOT_DIR}/Src/cyphal_application
${ROOT_DIR}/Libs/Cyphal
)

set(cyphalRegisters ${ROOT_DIR}/Libs/Cyphal/Cyphal/params.yaml)
list(APPEND cyphalRegisters
${CMAKE_CURRENT_LIST_DIR}/params.yaml
${CMAKE_CURRENT_LIST_DIR}/setpoint/params.yaml
Expand Down
26 changes: 20 additions & 6 deletions Src/dronecan_application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH SRC_DIR)
cmake_path(GET SRC_DIR PARENT_PATH ROOT_DIR)

set(PLATFORM bxcan)
include(${ROOT_DIR}/Libs/libsqcan/CMakeLists.txt)
set(libsSourceCode
${libparamsSrc}
${dronecanSources}
)
set(libsHeaders
${libparamsHeaders}
${dronecanHeaders}
)

set(applicationSourceCode
Src/periphery/pwm/pwm.cpp
Src/periphery/led/led.cpp
${ROOT_DIR}/Src/periphery/pwm/pwm.cpp
${ROOT_DIR}/Src/periphery/led/led.cpp

Src/dronecan_application/application.cpp
Src/dronecan_application/params.cpp
${ROOT_DIR}/Src/dronecan_application/application.cpp
${ROOT_DIR}/Src/dronecan_application/params.cpp
)
set(applicationHeaders
Src
Src/dronecan_application
${ROOT_DIR}/Src
${ROOT_DIR}/Src/dronecan_application
)

0 comments on commit 72721de

Please sign in to comment.