-
Notifications
You must be signed in to change notification settings - Fork 67
Added Cmake support #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| include(CheckIncludeFile) | ||
| include(CheckFunctionExists) | ||
| include(TestBigEndian) | ||
| include(CheckCSourceCompiles) | ||
| include(CheckStructHasMember) | ||
|
|
||
| check_include_file(assert.h HAVE_ASSERT_H) | ||
| check_include_file(arpa/inet.h HAVE_ARPA_INET_H) | ||
| check_include_file(fcntl.h HAVE_FCNTL_H) | ||
| check_include_file(inttypes.h HAVE_INTTYPES_H) | ||
| check_include_file(memory.h HAVE_MEMORY_H) | ||
| check_include_file(netdb.h HAVE_NETDB_H) | ||
| check_include_file(netinet/in.h HAVE_NETINET_IN_H) | ||
| check_include_file(stddef.h HAVE_STDDEF_H) | ||
| check_include_file(stdint.h HAVE_STDINT_H) | ||
| check_include_file(stdlib.h HAVE_STDLIB_H) | ||
| check_include_file(string.h HAVE_STRING_H) | ||
| check_include_file(strings.h HAVE_STRINGS_H) | ||
| check_include_file(time.h HAVE_TIME_H) | ||
| check_include_file(sys/param.h HAVE_SYS_PARAM_H) | ||
| check_include_file(sys/socket.h HAVE_SYS_SOCKET_H) | ||
| check_include_file(sys/stat.h HAVE_SYS_STAT_H) | ||
| check_include_file(sys/types.h HAVE_SYS_TYPES_H) | ||
| check_include_file(sys/time.h HAVE_SYS_TIME_H) | ||
| check_include_file(unistd.h HAVE_UNISTD_H) | ||
| check_include_file(float.h HAVE_FLOAT_H) | ||
| check_include_file(dlfcn.h HAVE_DLFCN_H) | ||
|
|
||
| check_function_exists (memset HAVE_MEMSET) | ||
| check_function_exists (select HAVE_SELECT) | ||
| check_function_exists (socket HAVE_SOCKET) | ||
| check_function_exists (strdup HAVE_STRDUP) | ||
| check_function_exists (strerror HAVE_STRERROR) | ||
| check_function_exists (strnlen HAVE_STRNLEN) | ||
| check_function_exists (fls HAVE_FLS) | ||
| check_function_exists (vprintf HAVE_VPRINTF) | ||
|
|
||
| if( ${HAVE_STRING_H} AND ${HAVE_STRINGS_H} AND | ||
| ${HAVE_FLOAT_H} AND ${HAVE_STDLIB_H} AND | ||
| ${HAVE_STDDEF_H} AND ${HAVE_STDINT_H} AND | ||
| ${HAVE_INTTYPES_H} AND ${HAVE_DLFCN_H} ) | ||
| set( STDC_HEADERS 1) | ||
| endif() | ||
|
|
||
| check_struct_has_member (struct sockaddr_in6.sin6_len netinet/in.h HAVE_SOCKADDR_IN6_SIN6_LEN) | ||
| TEST_BIG_ENDIAN(IS_BIG_ENDIAN) | ||
| if(IS_BIG_ENDIAN) | ||
| set(WORDS_BIGENDIAN 1) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| cmake_minimum_required(VERSION 3.5) | ||
|
|
||
| include (AutoConf.cmake) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Link using shared libs" OFF) | ||
| option(make_tests "Make test programs" OFF) | ||
|
|
||
| if(NOT PLATFORM) | ||
| set(PLATFORM "posix" CACHE STRING "Choose platform." FORCE) | ||
| set_property(CACHE PLATFORM PROPERTY STRINGS "contiki" "espidf" "posix" "riot") | ||
| endif() | ||
|
|
||
| set(PACKAGE_NAME "tinydtls") | ||
| set(PACKAGE_VERSION "0.8.6" ) | ||
|
|
||
| option(DTLS_ECC "disable support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" ON ) | ||
| option(DTLS_PSK "disable support for TLS_PSK_WITH_AES_128_CCM_8" ON) | ||
|
|
||
| configure_file(dtls_config.h.cmake.in dtls_config.h ) | ||
|
|
||
| file(GLOB SOURCE "*.c" "ecc/ecc.c" "aes/*.c" "sha2/sha2.c" "platform/dtls_prng_${PLATFORM}.c") | ||
|
|
||
| add_library(tinydtls ${SOURCE}) | ||
| target_compile_options(tinydtls PRIVATE -Wall -pedantic -std=c99 -DSHA2_USE_INTTYPES_H -fPIC -pedantic -Wall -Wextra -Wformat-security -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wunused -DDTLSv12 -DWITH_SHA256 -DDTLS_CHECK_CONTENTTYPE) | ||
| target_compile_options(tinydtls PUBLIC -DDTLSv12 -DWITH_SHA256) | ||
| target_include_directories(tinydtls PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
||
| if( ${make_tests} ) | ||
| add_subdirectory(tests) | ||
| endif() | ||
|
|
||
|
|
||
| if(${BUILD_SHARED_LIBS}) | ||
| install(TARGETS tinydtls DESTINATION /usr/local/lib ) | ||
| endif() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great that you provide this cmake script! questions: why only installing when shared lib? missing also header files installation. : include(GNUInstallDirs)
install(
TARGETS tinydtls
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
install(
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT dev
FILES_MATCHING
PATTERN "*.h")
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /* dtls_config.h.cmake.in. Generated from cmake */ | ||
|
|
||
| /* Define if building universal (internal helper macro) */ | ||
| #cmakedefine AC_APPLE_UNIVERSAL_BUILD | ||
|
|
||
| /* Define to 1 if building with ECC support. */ | ||
| #cmakedefine DTLS_ECC 1 | ||
|
|
||
| /* Define to 1 if building with PSK support */ | ||
| #cmakedefine DTLS_PSK 1 | ||
|
|
||
| /* Define to 1 if you have the <arpa/inet.h> header file. */ | ||
| #cmakedefine HAVE_ARPA_INET_H 1 | ||
|
|
||
| /* Define to 1 if you have the <assert.h> header file. */ | ||
| #cmakedefine HAVE_ASSERT_H 1 | ||
|
|
||
| /* Define to 1 if you have the <fcntl.h> header file. */ | ||
| #cmakedefine HAVE_FCNTL_H 1 | ||
|
|
||
| /* Define to 1 if you have the `fls' function. */ | ||
| #cmakedefine HAVE_FLS 1 | ||
|
|
||
| /* Define to 1 if you have the <inttypes.h> header file. */ | ||
| #cmakedefine HAVE_INTTYPES_H 1 | ||
|
|
||
| /* Define to 1 if you have the <memory.h> header file. */ | ||
| #cmakedefine HAVE_MEMORY_H 1 | ||
|
|
||
| /* Define to 1 if you have the `memset' function. */ | ||
| #cmakedefine HAVE_MEMSET 1 | ||
|
|
||
| /* Define to 1 if you have the <netdb.h> header file. */ | ||
| #cmakedefine HAVE_NETDB_H 1 | ||
|
|
||
| /* Define to 1 if you have the <netinet/in.h> header file. */ | ||
| #cmakedefine HAVE_NETINET_IN_H 1 | ||
|
|
||
| /* Define to 1 if you have the `select' function. */ | ||
| #cmakedefine HAVE_SELECT 1 | ||
|
|
||
| /* Define to 1 if struct sockaddr_in6 has a member sin6_len. */ | ||
| #cmakedefine HAVE_SOCKADDR_IN6_SIN6_LEN 1 | ||
|
|
||
| /* Define to 1 if you have the `socket' function. */ | ||
| #cmakedefine HAVE_SOCKET 1 | ||
|
|
||
| /* Define to 1 if you have the <stddef.h> header file. */ | ||
| #cmakedefine HAVE_STDDEF_H 1 | ||
|
|
||
| /* Define to 1 if you have the <stdint.h> header file. */ | ||
| #cmakedefine HAVE_STDINT_H 1 | ||
|
|
||
| /* Define to 1 if you have the <stdlib.h> header file. */ | ||
| #cmakedefine HAVE_STDLIB_H 1 | ||
|
|
||
| /* Define to 1 if you have the `strdup' function. */ | ||
| #cmakedefine HAVE_STRDUP 1 | ||
|
|
||
| /* Define to 1 if you have the `strerror' function. */ | ||
| #cmakedefine HAVE_STRERROR 1 | ||
|
|
||
| /* Define to 1 if you have the <strings.h> header file. */ | ||
| #cmakedefine HAVE_STRINGS_H 1 | ||
|
|
||
| /* Define to 1 if you have the <string.h> header file. */ | ||
| #cmakedefine HAVE_STRING_H 1 | ||
|
|
||
| /* Define to 1 if you have the `strnlen' function. */ | ||
| #cmakedefine HAVE_STRNLEN 1 | ||
|
|
||
| /* Define to 1 if you have the <sys/param.h> header file. */ | ||
| #cmakedefine HAVE_SYS_PARAM_H 1 | ||
|
|
||
| /* Define to 1 if you have the <sys/socket.h> header file. */ | ||
| #cmakedefine HAVE_SYS_SOCKET_H 1 | ||
|
|
||
| /* Define to 1 if you have the <sys/stat.h> header file. */ | ||
| #cmakedefine HAVE_SYS_STAT_H 1 | ||
|
|
||
| /* Define to 1 if you have the <sys/time.h> header file. */ | ||
| #cmakedefine HAVE_SYS_TIME_H 1 | ||
|
|
||
| /* Define to 1 if you have the <sys/types.h> header file. */ | ||
| #cmakedefine HAVE_SYS_TYPES_H 1 | ||
|
|
||
| /* Define to 1 if you have the <time.h> header file. */ | ||
| #cmakedefine HAVE_TIME_H 1 | ||
|
|
||
| /* Define to 1 if you have the <unistd.h> header file. */ | ||
| #cmakedefine HAVE_UNISTD_H 1 | ||
|
|
||
| /* Define to 1 if you have the `vprintf' function. */ | ||
| #cmakedefine HAVE_VPRINTF 1 | ||
|
|
||
| /* Define to the address where bug reports for this package should be sent. */ | ||
| #define PACKAGE_BUGREPORT "" | ||
|
|
||
| /* Define to the full name of this package. */ | ||
| #define PACKAGE_NAME "${PACKAGE_NAME}" | ||
|
|
||
| /* Define to the full name and version of this package. */ | ||
| #define PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" | ||
|
|
||
| /* Define to the one symbol short name of this package. */ | ||
| #define PACKAGE_TARNAME "${PACKAGE_NAME}" | ||
|
|
||
| /* Define to the home page for this package. */ | ||
| #define PACKAGE_URL "" | ||
|
|
||
| /* Define to the version of this package. */ | ||
| #define PACKAGE_VERSION "${PACKAGE_VERSION}" | ||
|
|
||
| /* Define to 1 if you have the ANSI C header files. */ | ||
| #cmakedefine STDC_HEADERS 1 | ||
|
|
||
| /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most | ||
| significant byte first (like Motorola and SPARC, unlike Intel). */ | ||
| #cmakedefine WORDS_BIGENDIAN 1 | ||
|
|
||
| /* TODO | ||
| Define to `__inline__' or `__inline' if that's what the C compiler | ||
| calls it, or to nothing if 'inline' is not supported under any name. | ||
| #ifndef __cplusplus | ||
| #undef inline | ||
| #endif | ||
|
|
||
| Define to `unsigned int' if <sys/types.h> does not define. | ||
| #undef size_t */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| cmake_minimum_required(VERSION 3.5) | ||
|
|
||
| add_executable(dtls-server dtls-server.c) | ||
| target_link_libraries(dtls-server LINK_PUBLIC tinydtls) | ||
| target_compile_options(dtls-server PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256) | ||
|
|
||
| add_executable(ccm-test ccm-test.c) | ||
| target_link_libraries(ccm-test LINK_PUBLIC tinydtls) | ||
| target_compile_options(ccm-test PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256) | ||
|
|
||
| add_executable(prf-test prf-test.c) | ||
| target_link_libraries(prf-test LINK_PUBLIC tinydtls) | ||
| target_compile_options(prf-test PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256) | ||
|
|
||
| add_executable(dtls-client dtls-client.c) | ||
| target_link_libraries(dtls-client LINK_PUBLIC tinydtls) | ||
| target_compile_options(dtls-client PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256) | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditions seems to require "" around for the case, that a header is missing. e.g. "${HAVE_DLFCN_H}".