Refactor common PThreads CMake code
Move the flags and find of Threads to root CMakeLists.txt, rather than duplicate these everywhere. Make explicit linking of library with PThreads use the same mechanism. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
ed3ba3cc8e
commit
7fd162ec26
15 changed files with 6 additions and 52 deletions
|
@ -114,6 +114,11 @@ if(MBEDTLS_PYTHON_EXECUTABLE)
|
|||
|
||||
endif()
|
||||
|
||||
# We now potentially need to link all executables against PThreads, if available
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
# If this is the root project add longer list of available CMAKE_BUILD_TYPE values
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
|
||||
|
|
|
@ -231,7 +231,7 @@ if(HAIKU)
|
|||
endif(HAIKU)
|
||||
|
||||
if(LINK_WITH_PTHREAD)
|
||||
set(libs ${libs} pthread)
|
||||
set(libs ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if(LINK_WITH_TRUSTED_STORAGE)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables
|
||||
crypt_and_hash
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables
|
||||
cipher_aead_demo
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
${mbedtls_target}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables
|
||||
generic_sum
|
||||
hello
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables_mbedtls
|
||||
dh_client
|
||||
dh_server
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables
|
||||
aead_demo
|
||||
crypto_examples
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(executables
|
||||
gen_entropy
|
||||
gen_random_ctr_drbg
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
set(THREADS_USE_PTHREADS_WIN32 true)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
${mbedtls_target}
|
||||
)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.5.1)
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
# Test the target renaming support by adding a prefix to the targets built
|
||||
set(MBEDTLS_TARGET_PREFIX subproject_test_)
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
${mbedcrypto_target}
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
${mbedx509_target}
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
|
||||
set(libs
|
||||
${mbedtls_target}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
|
|
Loading…
Reference in a new issue