CMake: Move library options to the top CMakeLists.txt

Move library options to the top CMakeLists.txt.
That way:
- we will be able to set the TF-PSA-Crypto
library options according to the Mbed TLS ones.
- we can define the crypto library target names
in the top CMakeLists.txt and not in the library
one that is dedicated to the TLS and x509
libraries now.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f05e1e3..21c9925 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,6 +95,19 @@
     option(ENABLE_TESTING "Build Mbed TLS tests." ON)
 endif()
 
+option(USE_STATIC_MBEDTLS_LIBRARY "Build Mbed TLS static library." ON)
+option(USE_SHARED_MBEDTLS_LIBRARY "Build Mbed TLS shared library." OFF)
+option(LINK_WITH_PTHREAD "Explicitly link Mbed TLS library to pthread." OFF)
+option(LINK_WITH_TRUSTED_STORAGE "Explicitly link Mbed TLS library to trusted_storage." OFF)
+
+set(mbedcrypto_target "${MBEDTLS_TARGET_PREFIX}mbedcrypto")
+if (USE_STATIC_MBEDTLS_LIBRARY)
+    set(mbedcrypto_static_target ${mbedcrypto_target})
+endif()
+if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
+    string(APPEND mbedcrypto_static_target "_static")
+endif()
+
 # Warning string - created as a list for compatibility with CMake 2.8
 set(CTR_DRBG_128_BIT_KEY_WARN_L1 "****  WARNING!  MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined!\n")
 set(CTR_DRBG_128_BIT_KEY_WARN_L2 "****  Using 128-bit keys for CTR_DRBG limits the security of generated\n")
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 0f75822..24c4de6 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -1,8 +1,3 @@
-option(USE_STATIC_MBEDTLS_LIBRARY "Build Mbed TLS static library." ON)
-option(USE_SHARED_MBEDTLS_LIBRARY "Build Mbed TLS shared library." OFF)
-option(LINK_WITH_PTHREAD "Explicitly link Mbed TLS library to pthread." OFF)
-option(LINK_WITH_TRUSTED_STORAGE "Explicitly link Mbed TLS library to trusted_storage." OFF)
-
 # Set the project root directory if it's not already defined, as may happen if
 # the library folder is included directly by a parent project, without
 # including the top level CMakeLists.txt.
@@ -251,16 +246,13 @@
 
 set(mbedtls_target    "${MBEDTLS_TARGET_PREFIX}mbedtls")
 set(mbedx509_target   "${MBEDTLS_TARGET_PREFIX}mbedx509")
-set(mbedcrypto_target "${MBEDTLS_TARGET_PREFIX}mbedcrypto")
 
 set(mbedtls_target    ${mbedtls_target}    PARENT_SCOPE)
 set(mbedx509_target   ${mbedx509_target}   PARENT_SCOPE)
-set(mbedcrypto_target ${mbedcrypto_target} PARENT_SCOPE)
 
 if (USE_STATIC_MBEDTLS_LIBRARY)
-    set(mbedtls_static_target    ${mbedtls_target})
-    set(mbedx509_static_target   ${mbedx509_target})
-    set(mbedcrypto_static_target ${mbedcrypto_target})
+    set(mbedtls_static_target  ${mbedtls_target})
+    set(mbedx509_static_target ${mbedx509_target})
 endif()
 
 set(target_libraries ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target})
@@ -268,7 +260,6 @@
 if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
     string(APPEND mbedtls_static_target    "_static")
     string(APPEND mbedx509_static_target   "_static")
-    string(APPEND mbedcrypto_static_target "_static")
 
     list(APPEND target_libraries
         ${mbedcrypto_static_target}