summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-15 14:48:09 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-15 14:48:09 -0800
commit573e08a643bac0af91df90582638f1f765dab429 (patch)
treead745bb81608147304b1bb92aeb682353feedcbd /src
parent694ad48a9c3b4c3d3a91d323a1601c2c4ebacba9 (diff)
downloadnng-573e08a643bac0af91df90582638f1f765dab429.tar.gz
nng-573e08a643bac0af91df90582638f1f765dab429.tar.bz2
nng-573e08a643bac0af91df90582638f1f765dab429.zip
Compile static *and* shared libraries.
Test code needs to use the static libraries so that they can get access to the entire set of symbols, including private ones that are not exported.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt22
-rw-r--r--src/platform/posix/posix_alloc.c5
-rw-r--r--src/platform/posix/posix_clock.c5
-rw-r--r--src/platform/posix/posix_debug.c5
-rw-r--r--src/platform/posix/posix_ipc.c5
-rw-r--r--src/platform/posix/posix_net.c5
-rw-r--r--src/platform/posix/posix_rand.c5
-rw-r--r--src/platform/posix/posix_thread.c5
-rw-r--r--src/platform/windows/win_clock.c5
-rw-r--r--src/platform/windows/win_debug.c5
-rw-r--r--src/platform/windows/win_ipc.c5
-rw-r--r--src/platform/windows/win_net.c5
-rw-r--r--src/platform/windows/win_rand.c5
-rw-r--r--src/platform/windows/win_thread.c5
14 files changed, 78 insertions, 9 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 48294b35..c8168d76 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,7 +2,7 @@
# Copyright (c) 2012-2013 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
-# Copyright 2016 Garrett D'Amore <garrett@damore.org>
+# Copyright 2017 Garrett D'Amore <garrett@damore.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
@@ -121,19 +121,23 @@ foreach (f ${NNG_SOURCES})
source_group ("${SRC_GROUP}" FILES ${f})
endforeach ()
-if (NNG_STATIC_LIB)
- add_library (${PROJECT_NAME} STATIC ${NNG_SOURCES})
-else ()
- add_library (${PROJECT_NAME} SHARED ${NNG_SOURCES})
- add_definitions (-DNNG_SHARED_LIB)
- #set_target_properties (${PROJECT_NAME} PROPERTIES SOVERSION "${NNG_ABI_VERSION}")
-endif ()
+# Static libary
+add_library (${PROJECT_NAME}_static STATIC ${NNG_SOURCES})
+
+# Shared library
+add_library (${PROJECT_NAME} SHARED ${NNG_SOURCES})
+target_compile_definitions(${PROJECT_NAME} PRIVATE -DNNG_SHARED_LIB)
+#set_target_properties (${PROJECT_NAME} PROPERTIES SOVERSION "${NNG_ABI_VERSION}")
# Set library outputs same as top-level project binary outputs
set_target_properties (${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_target_properties (${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_target_properties (${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set_target_properties (${PROJECT_NAME}_static PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set_target_properties (${PROJECT_NAME}_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set_target_properties (${PROJECT_NAME}_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+
target_link_libraries (${PROJECT_NAME} ${NNG_REQUIRED_LIBRARIES})
if( THREADS_HAVE_PTHREAD_ARG)
add_definitions (-pthread)
@@ -152,7 +156,7 @@ endif()
#install (
# FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-install (TARGETS ${PROJECT_NAME}
+install (TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
diff --git a/src/platform/posix/posix_alloc.c b/src/platform/posix/posix_alloc.c
index cce348f3..aef5bbfc 100644
--- a/src/platform/posix/posix_alloc.c
+++ b/src/platform/posix/posix_alloc.c
@@ -29,4 +29,9 @@ nni_free(void *ptr, size_t size)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_alloc_not_used = 0;
+
#endif
diff --git a/src/platform/posix/posix_clock.c b/src/platform/posix/posix_clock.c
index 6b452cbf..c87fb890 100644
--- a/src/platform/posix/posix_clock.c
+++ b/src/platform/posix/posix_clock.c
@@ -125,4 +125,9 @@ nni_plat_usleep(nni_duration usec)
#endif // NNG_USE_GETTIMEOFDAY
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_clock_not_used = 0;
+
#endif // PLATFORM_POSIX_CLOCK
diff --git a/src/platform/posix/posix_debug.c b/src/platform/posix/posix_debug.c
index 6199df1d..aa7afaea 100644
--- a/src/platform/posix/posix_debug.c
+++ b/src/platform/posix/posix_debug.c
@@ -106,4 +106,9 @@ nni_plat_errno(int errnum)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_debug_not_used = 0;
+
#endif // PLATFORM_POSIX_DEBUG
diff --git a/src/platform/posix/posix_ipc.c b/src/platform/posix/posix_ipc.c
index 6044280e..584dc4a9 100644
--- a/src/platform/posix/posix_ipc.c
+++ b/src/platform/posix/posix_ipc.c
@@ -340,4 +340,9 @@ nni_plat_ipc_accept(nni_plat_ipcsock *s, nni_plat_ipcsock *server)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_ipc_not_used = 0;
+
#endif // PLATFORM_POSIX_IPC
diff --git a/src/platform/posix/posix_net.c b/src/platform/posix/posix_net.c
index f9720b66..b89e7c49 100644
--- a/src/platform/posix/posix_net.c
+++ b/src/platform/posix/posix_net.c
@@ -391,4 +391,9 @@ nni_plat_tcp_accept(nni_plat_tcpsock *s, nni_plat_tcpsock *server)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_net_not_used = 0;
+
#endif // PLATFORM_POSIX_NET
diff --git a/src/platform/posix/posix_rand.c b/src/platform/posix/posix_rand.c
index 2576a444..76b2ee46 100644
--- a/src/platform/posix/posix_rand.c
+++ b/src/platform/posix/posix_rand.c
@@ -83,4 +83,9 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_rand_not_used = 0;
+
#endif // PLATFORM_POSIX_RANDOM
diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c
index 7b4dbbdc..91fbdff7 100644
--- a/src/platform/posix/posix_thread.c
+++ b/src/platform/posix/posix_thread.c
@@ -313,4 +313,9 @@ nni_plat_fini(void)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_posix_thread_not_used = 0;
+
#endif
diff --git a/src/platform/windows/win_clock.c b/src/platform/windows/win_clock.c
index bdb2f550..9a2546ae 100644
--- a/src/platform/windows/win_clock.c
+++ b/src/platform/windows/win_clock.c
@@ -26,4 +26,9 @@ nni_plat_usleep(nni_duration usec)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_clock_not_used = 0;
+
#endif // PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_debug.c b/src/platform/windows/win_debug.c
index 00fd6493..cf8ad9eb 100644
--- a/src/platform/windows/win_debug.c
+++ b/src/platform/windows/win_debug.c
@@ -78,4 +78,9 @@ nni_plat_errno(int errnum)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_debug_not_used = 0;
+
#endif // PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_ipc.c b/src/platform/windows/win_ipc.c
index feef6942..42590ee9 100644
--- a/src/platform/windows/win_ipc.c
+++ b/src/platform/windows/win_ipc.c
@@ -345,4 +345,9 @@ nni_plat_ipc_connect(nni_plat_ipcsock *s, const char *path)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_ipc_not_used = 0;
+
#endif // PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_net.c b/src/platform/windows/win_net.c
index 65f986bd..48be1781 100644
--- a/src/platform/windows/win_net.c
+++ b/src/platform/windows/win_net.c
@@ -557,4 +557,9 @@ nni_plat_tcp_accept(nni_plat_tcpsock *s, nni_plat_tcpsock *server)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_net_not_used = 0;
+
#endif // PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_rand.c b/src/platform/windows/win_rand.c
index 8bca5927..a1e381d8 100644
--- a/src/platform/windows/win_rand.c
+++ b/src/platform/windows/win_rand.c
@@ -30,4 +30,9 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_rand_not_used = 0;
+
#endif // PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c
index 4d47f18e..2dcb62fe 100644
--- a/src/platform/windows/win_thread.c
+++ b/src/platform/windows/win_thread.c
@@ -196,4 +196,9 @@ nni_plat_fini(void)
}
+#else
+
+// Suppress empty symbols warnings in ranlib.
+int nni_win_thread_not_used = 0;
+
#endif