From 573e08a643bac0af91df90582638f1f765dab429 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 15 Jan 2017 14:48:09 -0800 Subject: 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. --- src/CMakeLists.txt | 22 +++++++++++++--------- src/platform/posix/posix_alloc.c | 5 +++++ src/platform/posix/posix_clock.c | 5 +++++ src/platform/posix/posix_debug.c | 5 +++++ src/platform/posix/posix_ipc.c | 5 +++++ src/platform/posix/posix_net.c | 5 +++++ src/platform/posix/posix_rand.c | 5 +++++ src/platform/posix/posix_thread.c | 5 +++++ src/platform/windows/win_clock.c | 5 +++++ src/platform/windows/win_debug.c | 5 +++++ src/platform/windows/win_ipc.c | 5 +++++ src/platform/windows/win_net.c | 5 +++++ src/platform/windows/win_rand.c | 5 +++++ src/platform/windows/win_thread.c | 5 +++++ 14 files changed, 78 insertions(+), 9 deletions(-) (limited to 'src') 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 +# Copyright 2017 Garrett D'Amore # # 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 -- cgit v1.2.3-70-g09d2