Commit 929d4b06747a1ec33417da6875fd813d2424b825
Committed by
Moritz Wirger
1 parent
c404e66f
Update git submodules in CMakeLists.
Showing
1 changed file
with
21 additions
and
0 deletions
CMakeLists.txt
| @@ -33,6 +33,19 @@ if(CLANG_TIDY_EXE) | @@ -33,6 +33,19 @@ if(CLANG_TIDY_EXE) | ||
| 33 | endif() | 33 | endif() |
| 34 | endif() | 34 | endif() |
| 35 | 35 | ||
| 36 | +# update submodules | ||
| 37 | +find_package(Git QUIET) | ||
| 38 | +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") | ||
| 39 | + option(GIT_SUBMODULE "Check submodules during build" ON) | ||
| 40 | + if(GIT_SUBMODULE) | ||
| 41 | + message(STATUS "Submodule update") | ||
| 42 | + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
| 43 | + RESULT_VARIABLE GIT_SUBMOD_RESULT) | ||
| 44 | + if(NOT GIT_SUBMOD_RESULT EQUAL "0") | ||
| 45 | + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") | ||
| 46 | + endif() | ||
| 47 | + endif() | ||
| 48 | +endif() | ||
| 36 | 49 | ||
| 37 | # Set default build type if none was specified | 50 | # Set default build type if none was specified |
| 38 | set(default_build_type "Release") | 51 | set(default_build_type "Release") |
| @@ -69,8 +82,16 @@ if (1 AND APPLE) | @@ -69,8 +82,16 @@ if (1 AND APPLE) | ||
| 69 | set(CMAKE_MACOSX_RPATH 1) | 82 | set(CMAKE_MACOSX_RPATH 1) |
| 70 | endif() | 83 | endif() |
| 71 | 84 | ||
| 85 | +set(USE_STATIC_MBEDTLS_LIBRARY ON) | ||
| 86 | +set(USE_SHARED_MBEDTLS_LIBRARY OFF) | ||
| 72 | add_subdirectory("lib/mbedtls" EXCLUDE_FROM_ALL) | 87 | add_subdirectory("lib/mbedtls" EXCLUDE_FROM_ALL) |
| 73 | 88 | ||
| 89 | +# Compile the mbedtls library as a static with position independent code, | ||
| 90 | +# because we need it for both a shared and static library | ||
| 91 | +set_property(TARGET mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| 92 | +set_property(TARGET mbedcrypto PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| 93 | +set_property(TARGET mbedx509 PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| 94 | + | ||
| 74 | add_subdirectory(src) | 95 | add_subdirectory(src) |
| 75 | 96 | ||
| 76 | # if the user decided to use tests add the subdirectory | 97 | # if the user decided to use tests add the subdirectory |