Skip to content

Commit

Permalink
Change to cmake build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Heden committed Jul 9, 2015
1 parent 57c648a commit 77da52b
Show file tree
Hide file tree
Showing 58 changed files with 207 additions and 1,275 deletions.
65 changes: 65 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
project(SOEM C)

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)

message("CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")

if(WIN32)
set(OS "win32")
include_directories(oshw/win32/wpcap/Include)
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib)
elseif(UNIX)
set(OS "linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
set(OS "rtk")
message("ARCH is ${ARCH}")
message("BSP is ${BSP}")
include_directories(oshw/${OS}/${ARCH})
add_definitions("-Wno-unused-but-set-variable")
add_definitions("-Wno-unused-function")
add_definitions("-Wno-format")
endif()

message("OS is ${OS}")

include_directories(soem)
include_directories(osal)
include_directories(osal/${OS})
include_directories(oshw/${OS})

if (MSVC)
set(CMAKE_C_FLAGS_RELEASE "/D _CRT_SECURE_NO_WARNINGS /EHsc")
set(CMAKE_C_FLAGS_DEBUG "/D _CRT_SECURE_NO_WARNINGS /EHsc /ZI /Od")
endif()

file(GLOB SOEM_SOURCES soem/*.c)
file(GLOB OSAL_SOURCES osal/${OS}/*.c)
file(GLOB OSHW_SOURCES oshw/${OS}/*.c)

if(WIN32)
set(SOEM_SOURCES ${SOEM_SOURCES})
endif()

file(GLOB SOEM_HEADERS soem/*.h)
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h)
file(GLOB OSHW_HEADERS oshw/${OS}/*.h)

if(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
file(GLOB OSHW_ARCHSOURCES oshw/${OS}/${ARCH}/*.c)
endif()

add_library(soem STATIC ${SOEM_SOURCES} ${OSAL_SOURCES} ${OSHW_SOURCES} ${OSHW_ARCHSOURCES})
if(WIN32)
target_link_libraries(soem wpcap.lib Packet.lib Ws2_32.lib Winmm.lib ${HDF5_LIBRARIES})
elseif(UNIX)
target_link_libraries(soem pthread rt)
endif()

install(TARGETS soem DESTINATION bin)
install(FILES ${SOEM_HEADERS} ${OSAL_HEADERS} ${OSHW_HEADERS} DESTINATION include)

add_subdirectory(test/linux/slaveinfo)
add_subdirectory(test/linux/eepromtool)
add_subdirectory(test/linux/simple_test)
20 changes: 0 additions & 20 deletions Makefile

This file was deleted.

27 changes: 0 additions & 27 deletions README

This file was deleted.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BUILDING
========

Prerequisites for all platforms
-------------------------------

* CMake 2.8.0 or later


Windows (Visual Studio)
-----------------------

* Start a Visual Studio command prompt then:
$ mkdir build
$ cd build
$ cmake .. -G "NMake Makefiles"
$ nmake

Linux
-----

$ mkdir build
$ cmake ..
$ make
10 changes: 0 additions & 10 deletions clean_libsoem_lib.bat

This file was deleted.

54 changes: 0 additions & 54 deletions clean_test_win32.bat

This file was deleted.

13 changes: 13 additions & 0 deletions cmake/Modules/Platform/rt-kernel-C.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

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()
3 changes: 3 additions & 0 deletions cmake/Modules/Platform/rt-kernel-gcc-bfin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

set(MACHINE "-mcpu=bf537")
set(LDFLAGS "-T${RT_KERNEL_PATH}/bsp/${BSP}/${BSP}.ld")
7 changes: 7 additions & 0 deletions cmake/Modules/Platform/rt-kernel-gcc-kinetis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

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")
19 changes: 19 additions & 0 deletions cmake/Modules/Platform/rt-kernel-gcc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

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 changes: 20 additions & 0 deletions cmake/Modules/Platform/rt-kernel.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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}
)
9 changes: 9 additions & 0 deletions cmake/Toolchains/rt-kernel-bfin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

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 changes: 9 additions & 0 deletions cmake/Toolchains/rt-kernel-kinetis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

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")
58 changes: 0 additions & 58 deletions make/app.mk

This file was deleted.

2 changes: 0 additions & 2 deletions make/cl_eepromtool.rsp

This file was deleted.

12 changes: 0 additions & 12 deletions make/cl_libsoem.rsp

This file was deleted.

2 changes: 0 additions & 2 deletions make/cl_simple_test.rsp

This file was deleted.

2 changes: 0 additions & 2 deletions make/cl_slaveinfo.rsp

This file was deleted.

Loading

0 comments on commit 77da52b

Please sign in to comment.