cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH 4/8] cmake: build libhostname for test suite

From: Peter Wu <peter_at_lekensteyn.nl>
Date: Thu, 6 Nov 2014 01:32:44 +0100

Used by some test cases via LD_PRELOAD in order to fake the host name.

Signed-off-by: Peter Wu <peter_at_lekensteyn.nl>

---
 tests/libtest/CMakeLists.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index 73aaaa1..ef73e55 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -35,6 +35,15 @@ foreach(TEST_NAME ${noinst_PROGRAMS})
   setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
 endforeach()
 
+# Allows for hostname override to make tests machine independent.
+# TODO this cmake build assumes a shared build, detect static linking here!
+if(NOT WIN32)
+  add_library(hostname MODULE sethostname.c sethostname.h)
+  # Output to .libs for compatibility with autotools, the test data expects a
+  # library at (tests)/libtest/.libs/libhostname.so
+  set_target_properties(hostname PROPERTIES
+      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.libs)
+endif()
 
 # # files used only in some libcurl test programs
 # SET(TESTUTIL testutil.c testutil.h)
-- 
2.1.2
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-11-06