Modernize CMakeLists

Change-Id: Ie3877370918315d1452d2ea0a0013f12bffcbcc2
This commit is contained in:
Hans-Erik Floryd
2025-07-09 17:20:46 +02:00
parent 62a4c44336
commit 3eeb1d9b57
32 changed files with 773 additions and 185 deletions
+68 -105
View File
@@ -2,130 +2,93 @@
# license. See the file LICENSE.md distributed with this software for
# full license information.
cmake_minimum_required(VERSION 3.9)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
project(SOEM
DESCRIPTION "Simple Open EtherCAT Master"
VERSION 2.0.0
LANGUAGES C)
cmake_minimum_required(VERSION 3.28)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(SOEM VERSION 2.0.0 LANGUAGES C)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Default to installing in SOEM source directory
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install)
endif()
if(PROJECT_IS_TOP_LEVEL)
# Make option visible in ccmake, cmake-gui
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(SOEM_BUILD_UTILS "Build utitilities" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
# Default to release build with debug info
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
set(SOEM_INCLUDE_INSTALL_DIR include/soem)
set(SOEM_LIB_INSTALL_DIR lib)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BUILD_TESTS TRUE)
else()
message(STATUS "SOEM: not building tests when built as dependency")
set(BUILD_TESTS FALSE)
endif()
if(WIN32)
set(OS "win32")
include_directories(oshw/win32/wpcap/Include)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib)
# Default to installing in build directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()
if(MSVC)
message(STATUS "Win32 MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
else()
message(STATUS "Win32 non-MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
endif()
set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
elseif(UNIX AND NOT APPLE)
set(OS "linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
set(OS_LIBS pthread rt)
elseif(APPLE)
# This must come *before* linux or MacOSX will identify as Unix.
set(OS "macosx")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
set(OS_LIBS pthread pcap)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
set(OS "rtk")
message(STATUS "ARCH is ${ARCH}")
message(STATUS "BSP is ${BSP}")
include_directories(oshw/${OS}/${ARCH})
file(GLOB OSHW_EXTRA_SOURCES oshw/${OS}/${ARCH}/*.c)
set(OSHW_SOURCES "${OS_HW_SOURCES} ${OSHW_ARCHSOURCES}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
set(OS_LIBS "-Wl,--start-group -l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lc -lm -Wl,--end-group")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rtems")
message(STATUS "Building for RTEMS")
set(OS "rtems")
set(SOEM_LIB_INSTALL_DIR ${LIB_DIR})
set(BUILD_TESTS FALSE)
message(STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
endif()
message(STATUS "OS is ${OS}")
file(GLOB SOEM_SOURCES soem/*.c)
file(GLOB OSAL_SOURCES osal/${OS}/*.c)
file(GLOB OSHW_SOURCES oshw/${OS}/*.c)
file(GLOB SOEM_HEADERS soem/*.h)
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h)
file(GLOB OSHW_HEADERS oshw/${OS}/*.h)
# Always use standard .o suffix
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
add_library(soem
${SOEM_SOURCES}
${OSAL_SOURCES}
${OSHW_SOURCES}
${OSHW_EXTRA_SOURCES})
if (BUILD_SHARED_LIBS)
set_target_properties(soem PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
endif(BUILD_SHARED_LIBS)
target_link_libraries(soem ${OS_LIBS})
soem/ethercatbase.c
soem/ethercatcoe.c
soem/ethercatconfig.c
soem/ethercatdc.c
soem/ethercateoe.c
soem/ethercatfoe.c
soem/ethercatmain.c
soem/ethercatprint.c
soem/ethercatsoe.c
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/soem>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal/${OS}>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/oshw/${OS}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/soem>
$<INSTALL_INTERFACE:include/soem>
)
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/osal>
$<INSTALL_INTERFACE:include/soem>
)
message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}")
# Platform configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake)
install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR})
install(
TARGETS soem
EXPORT soemConfig
DESTINATION lib
)
install(EXPORT soemConfig DESTINATION share/soem/cmake)
install(
EXPORT soemConfig
DESTINATION cmake
)
install(FILES
${SOEM_HEADERS}
${OSAL_HEADERS}
${OSHW_HEADERS}
DESTINATION ${SOEM_INCLUDE_INSTALL_DIR})
soem/ethercatbase.h
soem/ethercatcoe.h
soem/ethercatconfig.h
soem/ethercatconfiglist.h
soem/ethercatdc.h
soem/ethercateoe.h
soem/ethercatfoe.h
soem/ethercat.h
soem/ethercatmain.h
soem/ethercatprint.h
soem/ethercatsoe.h
soem/ethercattype.h
osal/osal.h
DESTINATION include/soem
)
if(BUILD_TESTS)
if(SOEM_BUILD_UTILS)
add_subdirectory(test/simple_ng)
add_subdirectory(test/linux/slaveinfo)
add_subdirectory(test/linux/eepromtool)
add_subdirectory(test/linux/simple_test)
add_subdirectory(test/linux/coetest)
# add_subdirectory(test/linux/coetest)
endif()
+31
View File
@@ -0,0 +1,31 @@
# Licensed under the GNU General Public License version 2 with exceptions. See
# LICENSE file in the project root for full license information
target_sources(soem PRIVATE
osal/linux/osal.c
osal/linux/osal_defs.h
oshw/linux/oshw.c
oshw/linux/oshw.h
oshw/linux/nicdrv.c
oshw/linux/nicdrv.h
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/osal/linux>
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/oshw/linux>
$<INSTALL_INTERFACE:include/soem>
)
target_compile_options(soem PRIVATE
-Wall
-Wextra
-Werror
)
target_link_libraries(soem PUBLIC pthread rt)
install(FILES
osal/linux/osal_defs.h
oshw/linux/nicdrv.h
DESTINATION include/soem
)
-13
View File
@@ -1,13 +0,0 @@
message("rt-kernel-C.cmake")
# Determine toolchain
include(CMakeForceCompiler)
if(${ARCH} MATCHES "kinetis")
cmake_force_c_compiler(arm-eabi-gcc GNU)
cmake_force_cxx_compiler(arm-eabi-g++ GNU)
elseif(${ARCH} MATCHES "bfin")
cmake_force_c_compiler(bfin-elf-gcc GNU)
cmake_force_cxx_compiler(bfin-elf-g++ GNU)
endif()
@@ -1,3 +0,0 @@
set(MACHINE "-mcpu=bf537")
set(LDFLAGS "-T${RT_KERNEL_PATH}/bsp/${BSP}/${BSP}.ld")
@@ -1,7 +0,0 @@
message("rt-kernel-gcc-kinetis.cmake")
#SET_PROPERTY(GLOBAL PROPERTY ARCH kinetis)
#SET_PROPERTY(GLOBAL PROPERTY BSP twrk60)
set(MACHINE "-mfpu=vfp -mcpu=cortex-m3 -mthumb")
@@ -1,19 +0,0 @@
message("rt-kernel-gcc.cmake")
set(CMAKE_C_OUTPUT_EXTENSION .o)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(CFLAGS "${CFLAGS} -Wall -Wextra -Wno-unused-parameter -Werror")
set(CFLAGS "${CFLAGS} -fomit-frame-pointer -fno-strict-aliasing -fshort-wchar")
#set(CFLAGS" ${CFLAGS} -B$(GCC_PATH)/libexec/gcc")
set(CXXFLAGS "${CXXFLAGS} -fno-rtti -fno-exceptions")
set(LDFLAGS "${LDFLAGS} -nostartfiles")
set(CMAKE_C_FLAGS "${CFLAGS} ${MACHINE}" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS "${MACHINE} ${LDFLAGS}" CACHE STRING "")
-20
View File
@@ -1,20 +0,0 @@
if(__RTK_CMAKE_INCLUDED)
return()
endif()
set(__RTK_CMAKE_INCLUDED TRUE)
message("rt-kernel.cmake")
include_directories(
${RT_KERNEL_PATH}/include
${RT_KERNEL_PATH}/include/kern
${RT_KERNEL_PATH}/kern
${RT_KERNEL_PATH}/include/drivers
${RT_KERNEL_PATH}/include/arch/${ARCH}
${RT_KERNEL_PATH}/bsp/${BSP}/include
${RT_KERNEL_PATH}/lwip/src/include
${RT_KERNEL_PATH}/lwip/src/include/ipv4
)
link_directories(
${RT_KERNEL_PATH}/lib/${ARCH}
)
+102
View File
@@ -0,0 +1,102 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# www.rt-labs.com
# Copyright 2017 rt-labs AB, Sweden.
#
# This software is licensed under the terms of the BSD 3-clause
# license. See the file LICENSE distributed with this software for
# full license information.
#*******************************************************************/
include_guard()
cmake_minimum_required (VERSION 3.16)
# Avoid warning when re-running cmake
set(DUMMY ${CMAKE_TOOLCHAIN_FILE})
# No support for shared libs
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(UNIX 1)
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
# Do not build executables during configuration stage. Required
# libraries may not be built yet.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# Prefer standard extensions
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1)
# Add machine-specific flags
add_compile_options(${MACHINE})
add_link_options(${MACHINE})
if (NOT ${VARIANT} STREQUAL "")
add_definitions(-D${VARIANT})
endif()
# Common flags
add_compile_options(
-fdata-sections
-ffunction-sections
-fomit-frame-pointer
-fno-strict-aliasing
-fshort-wchar
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
# Linker script
set(TYPE "" CACHE STRING "BSP link type")
if (NOT ${TYPE} STREQUAL "")
set(_TYPE "_${TYPE}")
endif()
define_property(TARGET
PROPERTY BSP_LINK_SCRIPT INHERITED
BRIEF_DOCS "Define the linker script to use when linking executable"
FULL_DOCS "Define the linker script to use when linking executable"
)
set_directory_properties(
PROPERTIES BSP_LINK_SCRIPT ${BSP_DIR}/${BSP}${_TYPE}.ld
)
# Linker flags
add_link_options(
-nostartfiles
-T$<TARGET_PROPERTY:BSP_LINK_SCRIPT>
-Wl,--gc-sections
)
# Standard libraries
link_libraries(
c
m
$<$<LINK_LANGUAGE:CXX>:-lstdc++>
)
# Group libraries when linking
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--start-group <LINK_LIBRARIES> -Wl,--end-group -Wl,-Map=<TARGET>.map,--cref")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--start-group <LINK_LIBRARIES> -Wl,--end-group -Wl,-Map=<TARGET>.map,--cref")
# Macro to add TTOS schedule
macro(target_tt_schedule target infile)
find_package(Python3 REQUIRED)
string(REPLACE .tt .c outfile ${infile})
add_custom_command(
OUTPUT ${outfile}
COMMAND ${Python3_EXECUTABLE} ${TT_PARSE} ${CMAKE_CURRENT_LIST_DIR}/${infile} > ${outfile}
DEPENDS ${infile}
)
target_sources(${target} PRIVATE ${outfile})
endmacro()
-9
View File
@@ -1,9 +0,0 @@
message("rt-kernel-kinetis.cmake")
set(CMAKE_SYSTEM_NAME rt-kernel)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR bfin)
set(ARCH bfin CACHE STRING "Architecture")
set(BSP stamp537 CACHE STRING "Board")
-9
View File
@@ -1,9 +0,0 @@
message("rt-kernel-kinetis.cmake")
set(CMAKE_SYSTEM_NAME rt-kernel)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR kinetis)
set(ARCH kinetis CACHE STRING "Architecture")
set(BSP twrk60 CACHE STRING "Board")
+42
View File
@@ -0,0 +1,42 @@
# Licensed under the GNU General Public License version 2 with exceptions. See
# LICENSE file in the project root for full license information
target_sources(soem PRIVATE
osal/win32/osal.c
osal/win32/osal_defs.h
oshw/win32/oshw.c
oshw/win32/oshw.h
oshw/win32/nicdrv.c
oshw/win32/nicdrv.h
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/osal/win32>
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/oshw/win32>
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/oshw/win32/wpcap/Include>
$<INSTALL_INTERFACE:include/soem>
)
target_compile_options(soem PRIVATE
/D _CRT_SECURE_NO_WARNINGS
/WX
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WPCAP_LIB_PATH ${SOEM_SOURCE_DIR}/oshw/win32/wpcap/Lib/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WPCAP_LIB_PATH ${SOEM_SOURCE_DIR}/oshw/win32/wpcap/Lib)
endif()
target_link_libraries(soem PUBLIC
${WPCAP_LIB_PATH}/wpcap.lib
${WPCAP_LIB_PATH}/Packet.lib
Ws2_32.lib
Winmm.lib
)
install(FILES
osal/win32/osal_defs.h
oshw/win32/nicdrv.h
DESTINATION include/soem
)
+43
View File
@@ -0,0 +1,43 @@
# Licensed under the GNU General Public License version 2 with exceptions. See
# LICENSE file in the project root for full license information
find_package(rtkernel)
find_package(${BSP})
target_sources(soem PRIVATE
osal/rtk/osal.c
osal/rtk/osal_defs.h
oshw/rtk/oshw.c
oshw/rtk/oshw.h
oshw/rtk/nicdrv.c
oshw/rtk/nicdrv.h
oshw/rtk/lw_mac/lw_emac.c
oshw/rtk/fec/fec_ecat.c
oshw/rtk/fec/fec_ecat.h
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/osal/rtk>
$<INSTALL_INTERFACE:include/soem>
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${SOEM_SOURCE_DIR}/oshw/rtk>
$<INSTALL_INTERFACE:include/soem>
)
target_compile_options(soem PRIVATE
-Wall
-Wextra
-Werror
-Wno-unused-parameter
-Wno-format
)
install(FILES
osal/rtk/osal_defs.h
oshw/rtk/nicdrv.h
DESTINATION include/soem
)
target_link_libraries(soem PUBLIC kern ${BSP})
+33
View File
@@ -0,0 +1,33 @@
# Licensed under the GNU General Public License version 2 with exceptions. See
# LICENSE file in the project root for full license information
set(BUILD_TESTS FALSE)
target_sources(soem PRIVATE
osal/rtems/osal.c
osal/rtems/osal_defs.h
oshw/rtems/oshw.c
oshw/rtems/oshw.h
oshw/rtems/nicdrv.c
oshw/rtems/nicdrv.h
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/osal/rtems>
$<INSTALL_INTERFACE:include/soem>
)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/oshw/rtems>
$<INSTALL_INTERFACE:include/soem>
)
add_definitions(-Wall -Wextra -Werror)
target_link_libraries(soem PUBLIC rtemscpu bsd ${HOST_LIBS})
install(FILES
osal/rtems/osal_defs.h
oshw/rtems/nicdrv.h
DESTINATION include/soem
)
+17
View File
@@ -0,0 +1,17 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2014 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mthumb-interwork
-mlittle-endian
-mthumb
)
+16
View File
@@ -0,0 +1,16 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2010 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mlittle-endian
-mcpu=arm926ej-s
)
+15
View File
@@ -0,0 +1,15 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=bf537
)
+17
View File
@@ -0,0 +1,17 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2017 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-a8
-mfpu=neon
-mfloat-abi=hard
)
+16
View File
@@ -0,0 +1,16 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mfpu=neon
-mcpu=cortex-a8
)
+17
View File
@@ -0,0 +1,17 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2014 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-a9
-mfpu=vfpv3-d16
-mfloat-abi=hard
)
+16
View File
@@ -0,0 +1,16 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2014 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mfpu=neon
-mcpu=cortex-a9
)
+17
View File
@@ -0,0 +1,17 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mfpu=vfp
-mcpu=cortex-m3
-mthumb
)
+15
View File
@@ -0,0 +1,15 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-m33+nodsp
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2024 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-m33
-mthumb
-mfloat-abi=hard
-mfpu=fpv5-sp-d16
)
+17
View File
@@ -0,0 +1,17 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mfpu=vfp
-mcpu=cortex-m4
-mthumb
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-m4
-mthumb
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-m7
-mthumb
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-m7
-mthumb
-mfloat-abi=hard
-mfpu=fpv5-d16
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2018 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=cortex-r5
-mthumb
-mfloat-abi=hard
-mfpu=vfpv3-d16
)
+18
View File
@@ -0,0 +1,18 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mcpu=8540
-mregnames
-mmultiple
-mabi=spe
)
+19
View File
@@ -0,0 +1,19 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# http://www.rt-labs.com
# Copyright 2011 rt-labs AB, Sweden.
# See LICENSE file in the project root for full license information.
#*******************************************************************/
list(APPEND MACHINE
-mbig
-mregnames
-mcpu=powerpc
-mcall-sysv
-meabi
)
+148
View File
@@ -0,0 +1,148 @@
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# www.rt-labs.com
# Copyright 2017 rt-labs AB, Sweden.
#
# This software is licensed under the terms of the BSD 3-clause
# license. See the file LICENSE distributed with this software for
# full license information.
#*******************************************************************/
#[=======================================================================[.rst:
rt-kernel toolchain
-------------------
The following variables must be set when cmake configuration is
invoked::
BSP - Name of Board Support Package
The following variables are optional::
COMPILERS - Compiler search path, defaults to /opt/rt-tools/compilers
RTK - Location of rt-kernel tree, defaults to root of toolchain file
BSP_DIR - Location of BSP directory, defaults to ${RTK}/bsp/${BSP}
TT_PARSE - Location of tt_parse, defaults to ${RTK}/script/tt_parse.py
The variables can set from environment variables or from CMake
configuration. Your CMAKE_MODULE_PATH must also be configured so that
Platform/rt-kernel.cmake can be found.
Example to build for the xmc48relax board::
BSP=xmc48relax cmake \
-B build.xmc48relax \
-S /path/to/rt-kernel \
-DCMAKE_TOOLCHAIN_FILE=/path/to/rt-kernel.cmake \
-G "Unix Makefiles"
The variables can also be set from the root CMakeLists.txt. Example to
build using an out-of-tree BSP::
cmake_minimum_required(VERSION 3.16)
set(ENV{BSP} mybsp)
set(ENV{BSP_DIR} "${CMAKE_CURRENT_LIST_DIR}/mybsp")
set(ENV{RTK} "${CMAKE_CURRENT_LIST_DIR}/rt-kernel")
list(APPEND CMAKE_MODULE_PATH "$ENV{RTK}/cmake")
project (MYPROJECT VERSION 2.0.1)
#]=======================================================================]
include_guard()
cmake_minimum_required (VERSION 3.16)
# The name of the target operating system
set(CMAKE_SYSTEM_NAME rt-kernel)
# Default toolchain search path
if (NOT DEFINED ENV{COMPILERS})
set(ENV{COMPILERS} "/opt/rt-tools/compilers")
endif()
set(COMPILERS $ENV{COMPILERS} CACHE PATH
"Location of compiler toolchain")
# Default rt-kernel location
if(NOT DEFINED ENV{RTK})
# Set default to grand-parent of current dir
get_filename_component(RTK_ROOT
${CMAKE_CURRENT_LIST_DIR}/../..
ABSOLUTE
)
set(ENV{RTK} ${RTK_ROOT})
endif()
set(RTK $ENV{RTK} CACHE PATH
"Location of rt-kernel tree")
# Name of BSP
set(BSP $ENV{BSP} CACHE STRING
"The name of the BSP to build for")
# Default BSP dir
if(NOT DEFINED ENV{BSP_DIR})
set(ENV{BSP_DIR} ${RTK}/bsp/${BSP})
endif()
set(BSP_DIR $ENV{BSP_DIR} CACHE PATH
"Location of BSP")
# Default tt_parse search path
if (NOT DEFINED ENV{TT_PARSE})
set(ENV{TT_PARSE} "${RTK}/script/tt_parse.py")
endif()
set(TT_PARSE $ENV{TT_PARSE} CACHE FILEPATH
"Location of tt_parse")
message(STATUS "BSP: ${BSP}")
message(STATUS "BSP_DIR: ${BSP_DIR}")
message(STATUS "RTK: ${RTK}")
# Variables required for cmake try_compile phase
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
"BSP"
"BSP_DIR"
)
# Check that BSP is set
if (NOT BSP)
message(FATAL_ERROR "BSP has not been set")
endif()
# Check that bsp.mk exists
set(BSP_MK_FILE ${BSP_DIR}/${BSP}.mk)
if (NOT EXISTS ${BSP_MK_FILE})
message(FATAL_ERROR "Failed to open ${BSP_MK_FILE}")
endif()
# Slurp bsp.mk contents
file(READ ${BSP_MK_FILE} BSP_MK)
# Get CPU
string(REGEX MATCH "CPU=([A-Za-z0-9_\-]*)" _ ${BSP_MK})
set(CPU ${CMAKE_MATCH_1})
# Get ARCH
string(REGEX MATCH "ARCH=([A-Za-z0-9_\-]*)" _ ${BSP_MK})
set(ARCH ${CMAKE_MATCH_1})
# Get VARIANT
string(REGEX MATCH "VARIANT=([A-Za-z0-9_\-]*)" _ ${BSP_MK})
set(VARIANT ${CMAKE_MATCH_1})
# Get CROSS_GCC
string(REGEX MATCH "CROSS_GCC=([A-Za-z0-9_\-]*)" _ ${BSP_MK})
set(CROSS_GCC ${CMAKE_MATCH_1})
# Set cross-compiler toolchain
set(CMAKE_C_COMPILER ${COMPILERS}/${CROSS_GCC}/bin/${CROSS_GCC}-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
if(CMAKE_HOST_WIN32)
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER}.exe)
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}.exe)
endif(CMAKE_HOST_WIN32)
# Set cross-compiler machine-specific flags
include(${CMAKE_CURRENT_LIST_DIR}/${CPU}.cmake)
+16
View File
@@ -0,0 +1,16 @@
# Look for an executable called sphinx-build
find_program(
SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable"
)
include(FindPackageHandleStandardArgs)
# Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(
Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE
)