代码拉取完成,页面将自动刷新
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 1.4.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()
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)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
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)
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)
add_library(soem STATIC
${SOEM_SOURCES}
${OSAL_SOURCES}
${OSHW_SOURCES}
${OSHW_EXTRA_SOURCES})
target_link_libraries(soem ${OS_LIBS})
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}>
$<INSTALL_INTERFACE:include/soem>
)
message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}")
install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR})
install(EXPORT soemConfig DESTINATION share/soem/cmake)
install(FILES
${SOEM_HEADERS}
${OSAL_HEADERS}
${OSHW_HEADERS}
DESTINATION ${SOEM_INCLUDE_INSTALL_DIR})
if(BUILD_TESTS)
add_subdirectory(test/simple_ng)
add_subdirectory(test/linux/slaveinfo)
add_subdirectory(test/linux/eepromtool)
add_subdirectory(test/linux/simple_test)
endif()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。