Enable and fix warnings (#123)
* cleanup CMakeLists.txt * build with more warnings, warnings as errors * fix expression has no effect warning * fix unused parameter warnings * fix loss of precision warning * remove obsolete files
This commit is contained in:
parent
0ece3165a0
commit
da7d55e893
|
@ -3,67 +3,65 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
|
||||||
project(SOEM C)
|
project(SOEM C)
|
||||||
|
|
||||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
# Default to installing in SOEM source directory
|
# Default to installing in SOEM source directory
|
||||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SOEM_INCLUDE_INSTALL_DIR include/soem)
|
set(SOEM_INCLUDE_INSTALL_DIR include/soem)
|
||||||
|
|
||||||
message("CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(OS "win32")
|
set(OS "win32")
|
||||||
include_directories(oshw/win32/wpcap/Include)
|
include_directories(oshw/win32/wpcap/Include)
|
||||||
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib)
|
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib)
|
||||||
|
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)
|
elseif(UNIX)
|
||||||
set(OS "linux")
|
set(OS "linux")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
|
||||||
|
set(OS_LIBS pthread rt)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
|
||||||
set(OS "rtk")
|
set(OS "rtk")
|
||||||
message("ARCH is ${ARCH}")
|
message("ARCH is ${ARCH}")
|
||||||
message("BSP is ${BSP}")
|
message("BSP is ${BSP}")
|
||||||
include_directories(oshw/${OS}/${ARCH})
|
include_directories(oshw/${OS}/${ARCH})
|
||||||
add_definitions("-Wno-unused-but-set-variable")
|
file(GLOB OSHW_EXTRA_SOURCES oshw/${OS}/${ARCH}/*.c)
|
||||||
add_definitions("-Wno-unused-function")
|
set(OSHW_SOURCES "${OS_HW_SOURCES} ${OSHW_ARCHSOURCES}")
|
||||||
add_definitions("-Wno-format")
|
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")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message("OS is ${OS}")
|
message("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)
|
||||||
|
|
||||||
include_directories(soem)
|
include_directories(soem)
|
||||||
include_directories(osal)
|
include_directories(osal)
|
||||||
include_directories(osal/${OS})
|
include_directories(osal/${OS})
|
||||||
include_directories(oshw/${OS})
|
include_directories(oshw/${OS})
|
||||||
|
|
||||||
if (MSVC)
|
add_library(soem STATIC
|
||||||
set(CMAKE_C_FLAGS_RELEASE "/D _CRT_SECURE_NO_WARNINGS /EHsc")
|
${SOEM_SOURCES}
|
||||||
set(CMAKE_C_FLAGS_DEBUG "/D _CRT_SECURE_NO_WARNINGS /EHsc /ZI /Od")
|
${OSAL_SOURCES}
|
||||||
endif()
|
${OSHW_SOURCES}
|
||||||
|
${OSHW_EXTRA_SOURCES})
|
||||||
file(GLOB SOEM_SOURCES soem/*.c)
|
target_link_libraries(soem ${OS_LIBS})
|
||||||
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 lib)
|
install(TARGETS soem DESTINATION lib)
|
||||||
install(FILES ${SOEM_HEADERS} ${OSAL_HEADERS} ${OSHW_HEADERS} DESTINATION ${SOEM_INCLUDE_INSTALL_DIR})
|
install(FILES
|
||||||
|
${SOEM_HEADERS}
|
||||||
|
${OSAL_HEADERS}
|
||||||
|
${OSHW_HEADERS}
|
||||||
|
DESTINATION ${SOEM_INCLUDE_INSTALL_DIR})
|
||||||
|
|
||||||
add_subdirectory(test/linux/slaveinfo)
|
add_subdirectory(test/linux/slaveinfo)
|
||||||
add_subdirectory(test/linux/eepromtool)
|
add_subdirectory(test/linux/eepromtool)
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
LIBNAME = osal
|
|
||||||
include $(PRJ_ROOT)/make/lib.mk
|
|
|
@ -25,12 +25,13 @@ int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int return_value;
|
int return_value;
|
||||||
|
(void)tz; /* Not used */
|
||||||
|
|
||||||
/* Use clock_gettime to prevent possible live-lock.
|
/* Use clock_gettime to prevent possible live-lock.
|
||||||
* Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust.
|
* Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust.
|
||||||
* If this function preempts timeadjust and it uses vpage it live-locks.
|
* If this function preempts timeadjust and it uses vpage it live-locks.
|
||||||
* Also when using XENOMAI, only clock_gettime is RT safe */
|
* Also when using XENOMAI, only clock_gettime is RT safe */
|
||||||
return_value = clock_gettime(CLOCK_MONOTONIC, &ts), 0;
|
return_value = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
tv->tv_sec = ts.tv_sec;
|
tv->tv_sec = ts.tv_sec;
|
||||||
tv->tv_usec = ts.tv_nsec / 1000;
|
tv->tv_usec = ts.tv_nsec / 1000;
|
||||||
return return_value;
|
return return_value;
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
LIBNAME = osal
|
|
||||||
include $(PRJ_ROOT)/make/lib.mk
|
|
|
@ -1,21 +0,0 @@
|
||||||
#******************************************************************************
|
|
||||||
# * *** ***
|
|
||||||
# *** *** ***
|
|
||||||
# *** **** ********** *** ***** *** **** *****
|
|
||||||
# ********* ********** *** ********* ************ *********
|
|
||||||
# **** *** *** *** *** **** ***
|
|
||||||
# *** *** ****** *** *********** *** **** *****
|
|
||||||
# *** *** ****** *** ************* *** **** *****
|
|
||||||
# *** **** **** *** *** *** **** ***
|
|
||||||
# *** ******* ***** ************** ************* *********
|
|
||||||
# *** ***** *** ******* ** ** ****** *****
|
|
||||||
# t h e r e a l t i m e t a r g e t e x p e r t s
|
|
||||||
#
|
|
||||||
# http://www.rt-labs.com
|
|
||||||
# Copyright (C) 2009. rt-labs AB, Sweden. All rights reserved.
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# $Id: Makefile 262 2012-08-14 06:14:07Z rtlaka $
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
LIBNAME = osal
|
|
||||||
include $(PRJ_ROOT)/make/lib.mk
|
|
|
@ -1,2 +0,0 @@
|
||||||
LIBNAME = oshw
|
|
||||||
include $(PRJ_ROOT)/make/lib.mk
|
|
|
@ -2,11 +2,4 @@
|
||||||
set(SOURCES eepromtool.c)
|
set(SOURCES eepromtool.c)
|
||||||
add_executable(eepromtool ${SOURCES})
|
add_executable(eepromtool ${SOURCES})
|
||||||
target_link_libraries(eepromtool soem)
|
target_link_libraries(eepromtool soem)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(eepromtool wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
|
|
||||||
elseif(UNIX)
|
|
||||||
target_link_libraries(eepromtool pthread rt)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS eepromtool DESTINATION bin)
|
install(TARGETS eepromtool DESTINATION bin)
|
||||||
|
|
|
@ -225,25 +225,25 @@ int eeprom_read(int slave, int start, int length)
|
||||||
for (i = start ; i < (start + length) ; i+=ainc)
|
for (i = start ; i < (start + length) ; i+=ainc)
|
||||||
{
|
{
|
||||||
b8 = ec_readeepromAP(aiadr, i >> 1 , EC_TIMEOUTEEP);
|
b8 = ec_readeepromAP(aiadr, i >> 1 , EC_TIMEOUTEEP);
|
||||||
ebuf[i] = b8;
|
ebuf[i] = b8 & 0xFF;
|
||||||
ebuf[i+1] = b8 >> 8;
|
ebuf[i+1] = (b8 >> 8) & 0xFF;
|
||||||
ebuf[i+2] = b8 >> 16;
|
ebuf[i+2] = (b8 >> 16) & 0xFF;
|
||||||
ebuf[i+3] = b8 >> 24;
|
ebuf[i+3] = (b8 >> 24) & 0xFF;
|
||||||
ebuf[i+4] = b8 >> 32;
|
ebuf[i+4] = (b8 >> 32) & 0xFF;
|
||||||
ebuf[i+5] = b8 >> 40;
|
ebuf[i+5] = (b8 >> 40) & 0xFF;
|
||||||
ebuf[i+6] = b8 >> 48;
|
ebuf[i+6] = (b8 >> 48) & 0xFF;
|
||||||
ebuf[i+7] = b8 >> 56;
|
ebuf[i+7] = (b8 >> 56) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = start ; i < (start + length) ; i+=ainc)
|
for (i = start ; i < (start + length) ; i+=ainc)
|
||||||
{
|
{
|
||||||
b4 = ec_readeepromAP(aiadr, i >> 1 , EC_TIMEOUTEEP);
|
b4 = ec_readeepromAP(aiadr, i >> 1 , EC_TIMEOUTEEP) & 0xFFFFFFFF;
|
||||||
ebuf[i] = b4;
|
ebuf[i] = b4 & 0xFF;
|
||||||
ebuf[i+1] = b4 >> 8;
|
ebuf[i+1] = (b4 >> 8) & 0xFF;
|
||||||
ebuf[i+2] = b4 >> 16;
|
ebuf[i+2] = (b4 >> 16) & 0xFF;
|
||||||
ebuf[i+3] = b4 >> 24;
|
ebuf[i+3] = (b4 >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,4 @@
|
||||||
set(SOURCES simple_test.c)
|
set(SOURCES simple_test.c)
|
||||||
add_executable(simple_test ${SOURCES})
|
add_executable(simple_test ${SOURCES})
|
||||||
target_link_libraries(simple_test soem)
|
target_link_libraries(simple_test soem)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(simple_test wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
|
|
||||||
elseif(UNIX)
|
|
||||||
target_link_libraries(simple_test pthread rt)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS simple_test DESTINATION bin)
|
install(TARGETS simple_test DESTINATION bin)
|
||||||
|
|
|
@ -146,6 +146,7 @@ void simpletest(char *ifname)
|
||||||
OSAL_THREAD_FUNC ecatcheck( void *ptr )
|
OSAL_THREAD_FUNC ecatcheck( void *ptr )
|
||||||
{
|
{
|
||||||
int slave;
|
int slave;
|
||||||
|
(void)ptr; /* Not used */
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,4 @@
|
||||||
set(SOURCES slaveinfo.c)
|
set(SOURCES slaveinfo.c)
|
||||||
add_executable(slaveinfo ${SOURCES})
|
add_executable(slaveinfo ${SOURCES})
|
||||||
target_link_libraries(slaveinfo soem)
|
target_link_libraries(slaveinfo soem)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(slaveinfo wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
|
|
||||||
elseif(UNIX)
|
|
||||||
target_link_libraries(slaveinfo pthread rt)
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
|
|
||||||
target_link_libraries(slaveinfo "-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")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS slaveinfo DESTINATION bin)
|
install(TARGETS slaveinfo DESTINATION bin)
|
||||||
|
|
Loading…
Reference in New Issue