summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorFelix Weinrank <weinrank@fh-muenster.de>2016-09-21 21:37:47 (GMT)
committerFelix Weinrank <weinrank@fh-muenster.de>2016-09-21 21:37:47 (GMT)
commitc74bb9bebf86c8e697e65317b7724855a0fc2a45 (patch)
tree23eb7c2287af79074df90ac6400737e6509edad6 /programs
parent7b5302ee6a1d8e00d058ccc25b34457c3f1059d8 (diff)
downloadusrsctp-c74bb9bebf86c8e697e65317b7724855a0fc2a45.tar.gz
usrsctp-c74bb9bebf86c8e697e65317b7724855a0fc2a45.tar.xz
cmake refactoring and diet
Diffstat (limited to 'programs')
-rw-r--r--programs/CMakeLists.txt104
1 files changed, 43 insertions, 61 deletions
diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt
index e211260..ed2dd00 100644
--- a/programs/CMakeLists.txt
+++ b/programs/CMakeLists.txt
@@ -45,27 +45,9 @@ include(CheckTypeSize)
#################################################
-# CHECK FOR TYPES AND FUNCTIONS
-#################################################
-
-# xxx warum machen wir die checks?
-check_type_size("size_t" HAVE_SIZE_T)
-check_type_size("ssize_t" HAVE_SSIZE_T)
-
-check_function_exists("socket" HAVE_SOCKET)
-check_function_exists("inet_addr" HAVE_INET_ADDR)
-
-
-#################################################
# CHECK INCLUDES
#################################################
-check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
-check_include_file(sys/types.h HAVE_SYS_TYPES_H)
-check_include_file(sys/queue.h HAVE_SYS_QUEUE_H)
-check_include_file(linux/if_addr.h HAVE_LINUX_IF_ADDR_H)
-check_include_file(linux/rtnetlink.h HAVE_LINUX_RTNETLINK_H)
-check_include_file(netinet/ip_icmp.h HAVE_NETINET_IP_ICMP_H)
check_include_file(usrsctp.h HAVE_USRSCTP_H)
@@ -74,24 +56,24 @@ check_include_file(usrsctp.h HAVE_USRSCTP_H)
#################################################
check_struct_has_member("struct sockaddr" "sa_len" "sys/types.h;sys/socket.h" HAVE_SA_LEN)
-if(HAVE_SA_LEN)
+if (HAVE_SA_LEN)
add_definitions(-DHAVE_SA_LEN)
-endif()
+endif ()
check_struct_has_member("struct sockaddr_in" "sin_len" "sys/types.h;netinet/in.h" HAVE_SIN_LEN)
-if(HAVE_SIN_LEN)
+if (HAVE_SIN_LEN)
add_definitions(-DHAVE_SIN_LEN)
-endif()
+endif ()
check_struct_has_member("struct sockaddr_in6" "sin6_len" "sys/types.h;netinet/in.h" HAVE_SIN6_LEN)
-if(HAVE_SIN6_LEN)
+if (HAVE_SIN6_LEN)
add_definitions(-DHAVE_SIN6_LEN)
-endif()
+endif ()
check_struct_has_member("struct sockaddr_conn" "sconn_len" "usrsctp.h" HAVE_SCONN_LEN)
-if(HAVE_SCONN_LEN)
+if (HAVE_SCONN_LEN)
add_definitions(-DHAVE_SCONN_LEN)
-endif()
+endif ()
#################################################
@@ -101,26 +83,26 @@ endif()
option(SCTP_DEBUG "Provide debug information" 1)
if (SCTP_DEBUG)
add_definitions(-DSCTP_DEBUG)
-endif()
+endif ()
option(INET "Support IPv4 " 1)
if (INET)
add_definitions(-DINET)
-endif()
+endif ()
option(INET6 "Support IPv6 " 1)
if (INET6)
add_definitions(-DINET6)
-endif()
+endif ()
-option(LINK_STATIC "Link static" 0)
+option(link_static"Link static" 0)
# xxx enable W32 support for shared lib ...
-if (LINK_STATIC OR WIN32)
- set(LINK_STATIC "usrsctp-static")
+if (link_staticOR WIN32)
+ set(link_static"usrsctp-static")
else()
- set(LINK_STATIC "usrsctp")
-endif()
+ set(link_static"usrsctp")
+endif ()
option(WERROR "Warning as error" ON)
@@ -131,25 +113,25 @@ option(WERROR "Warning as error" ON)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
-endif()
+endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-D__APPLE_USE_RFC_2292)
-endif()
+endif ()
#################################################
# MISC
#################################################
-FIND_PACKAGE(Threads)
+find_package(Threads)
#################################################
# PROGRAMS
#################################################
-SET (check_PROGRAMS
+set(check_PROGRAMS
client.c
datachan_serv.c
daytime_server.c
@@ -166,39 +148,39 @@ SET (check_PROGRAMS
)
# SETTINGS FOR UNIX COMPILER
-IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
+if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c99")
if (WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
- endif()
-ENDIF ()
+ endif ()
+endif ()
# SETTINGS FOR VISUAL STUDIO COMPILER
-IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
- IF (CMAKE_C_FLAGS MATCHES "/W[0-4]")
- STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- ELSE ()
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
- ENDIF ()
-
- IF (WERROR)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
- ENDIF()
-ENDIF ()
-
-FOREACH (source_file ${check_PROGRAMS})
- GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
- ADD_EXECUTABLE (
+if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
+ if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
+ string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ else ()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
+ endif ()
+
+ if (WERROR)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
+ endif ()
+endif ()
+
+foreach (source_file ${check_PROGRAMS})
+ get_filename_component(source_file_we ${source_file} NAME_WE)
+ add_executable(
${source_file_we}
${source_file}
)
- TARGET_LINK_LIBRARIES (${source_file_we}
- ${LINK_STATIC}
- ${CMAKE_THREAD_LIBS_INIT}
+ target_link_library (${source_file_we}
+ ${link_static}
+ ${cmake_thread_libs_init}
)
- ADD_TEST (${source_file_we} ${source_file_we})
-ENDFOREACH ()
+ add_test(${source_file_we} ${source_file_we})
+endforeach ()