From b06819bb5d190e4ebca1676e1f52c9700a2d70ac Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Tue, 18 Jan 2011 16:18:38 +0000
Subject: [PATCH] - Adapted CMake files for the PKCS#11 support
---
CMakeLists.txt | 2 ++
library/CMakeLists.txt | 1 +
programs/ssl/CMakeLists.txt | 14 +++++++++++---
programs/test/CMakeLists.txt | 16 ++++++++++++----
programs/x509/CMakeLists.txt | 10 +++++++++-
tests/CMakeLists.txt | 10 +++++++++-
6 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed01daed2..1c6a583ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
set(CMAKE_SHARED_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
endif(CMAKE_BUILD_TYPE STREQUAL "Coverage")
+option(USE_PKCS11_HELPER_LIBRARY "Build PolarSSL with the pkcs11-helper library." OFF)
+
include_directories(include/)
add_subdirectory(library)
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 62a3eb584..9cce0f31b 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -20,6 +20,7 @@ set(src
md5.c
net.c
padlock.c
+ pkcs11.c
rsa.c
sha1.c
sha2.c
diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt
index 14b1d3eb3..f5c26d239 100644
--- a/programs/ssl/CMakeLists.txt
+++ b/programs/ssl/CMakeLists.txt
@@ -1,11 +1,19 @@
+set(libs
+ polarssl
+)
+
+if(USE_PKCS11_HELPER_LIBRARY)
+ set(libs ${libs} pkcs11-helper)
+endif(USE_PKCS11_HELPER_LIBRARY)
+
add_executable(ssl_client1 ssl_client1.c)
-target_link_libraries(ssl_client1 polarssl)
+target_link_libraries(ssl_client1 ${libs})
add_executable(ssl_client2 ssl_client2.c)
-target_link_libraries(ssl_client2 polarssl)
+target_link_libraries(ssl_client2 ${libs})
add_executable(ssl_server ssl_server.c)
-target_link_libraries(ssl_server polarssl)
+target_link_libraries(ssl_server ${libs})
INSTALL(TARGETS ssl_client1 ssl_client2 ssl_server
DESTINATION "bin"
diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt
index 9cd43baaf..87f08c7bf 100644
--- a/programs/test/CMakeLists.txt
+++ b/programs/test/CMakeLists.txt
@@ -1,14 +1,22 @@
+set(libs
+ polarssl
+)
+
+if(USE_PKCS11_HELPER_LIBRARY)
+ set(libs ${libs} pkcs11-helper)
+endif(USE_PKCS11_HELPER_LIBRARY)
+
add_executable(selftest selftest.c)
-target_link_libraries(selftest polarssl)
+target_link_libraries(selftest ${libs})
add_executable(benchmark benchmark.c)
-target_link_libraries(benchmark polarssl)
+target_link_libraries(benchmark ${libs})
add_executable(ssl_test ssl_test.c)
-target_link_libraries(ssl_test polarssl)
+target_link_libraries(ssl_test ${libs})
add_executable(ssl_cert_test ssl_cert_test.c)
-target_link_libraries(ssl_cert_test polarssl)
+target_link_libraries(ssl_cert_test ${libs})
INSTALL(TARGETS selftest benchmark ssl_test ssl_cert_test
DESTINATION "bin"
diff --git a/programs/x509/CMakeLists.txt b/programs/x509/CMakeLists.txt
index 29e5854ae..872feb4ce 100644
--- a/programs/x509/CMakeLists.txt
+++ b/programs/x509/CMakeLists.txt
@@ -1,5 +1,13 @@
+set(libs
+ polarssl
+)
+
+if(USE_PKCS11_HELPER_LIBRARY)
+ set(libs ${libs} pkcs11-helper)
+endif(USE_PKCS11_HELPER_LIBRARY)
+
add_executable(cert_app cert_app.c)
-target_link_libraries(cert_app polarssl)
+target_link_libraries(cert_app ${libs})
INSTALL(TARGETS cert_app
DESTINATION "bin"
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1bfce1847..1bea3618d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,3 +1,11 @@
+set(libs
+ polarssl
+)
+
+if(USE_PKCS11_HELPER_LIBRARY)
+ set(libs ${libs} pkcs11-helper)
+endif(USE_PKCS11_HELPER_LIBRARY)
+
function(add_test_suite suite_name)
add_custom_command(
OUTPUT test_suite_${suite_name}.c
@@ -7,7 +15,7 @@ function(add_test_suite suite_name)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test_suite_${suite_name} test_suite_${suite_name}.c)
- target_link_libraries(test_suite_${suite_name} polarssl)
+ target_link_libraries(test_suite_${suite_name} ${libs})
add_test(${suite_name}-suite test_suite_${suite_name})
endfunction(add_test_suite)