You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
cmake_minimum_required(VERSION 3.10)
|
|
project(kyncat C)
|
|
|
|
# Set C standard
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
# Set output directory for the compiled binary
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
|
set(CMAKE_BINARY_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
|
|
|
# SOEM Repository Info
|
|
set(SOEM_REPO "https://github.com/OpenEtherCATsociety/SOEM.git")
|
|
set(SOEM_PATH "${CMAKE_SOURCE_DIR}/SOEM")
|
|
|
|
# Check if SOEM exists, if not, clone it
|
|
if(NOT EXISTS ${SOEM_PATH}/CMakeLists.txt)
|
|
message(STATUS "SOEM not found! Cloning from ${SOEM_REPO}...")
|
|
execute_process(
|
|
COMMAND git clone --depth 1 ${SOEM_REPO} ${SOEM_PATH}
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
RESULT_VARIABLE GIT_CLONE_RESULT
|
|
)
|
|
if(NOT GIT_CLONE_RESULT EQUAL 0)
|
|
message(FATAL_ERROR "Failed to clone SOEM repository!")
|
|
endif()
|
|
endif()
|
|
|
|
# Include SOEM as a subdirectory (it has its own CMakeLists.txt)
|
|
add_subdirectory(${SOEM_PATH})
|
|
|
|
# Include directories for SOEM
|
|
include_directories(
|
|
${SOEM_PATH}/soem
|
|
${SOEM_PATH}/osal
|
|
${SOEM_PATH}/osal/linux
|
|
${SOEM_PATH}/oshw/linux
|
|
)
|
|
|
|
# Define the source files for kyncat
|
|
set(SOURCES
|
|
main.c
|
|
slaveconfig.c
|
|
)
|
|
|
|
set(HEADERS
|
|
slaveconfig.h
|
|
)
|
|
|
|
# Create the executable and link against the SOEM static library
|
|
add_executable(kyncat ${SOURCES} ${HEADERS})
|
|
|
|
# Link SOEM library and required system libraries
|
|
target_link_libraries(kyncat soem pthread rt)
|
|
|