Add cmake variable to adjust the value of NN_MAX_SOCKETS define
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80276c0..a165387 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,6 +101,7 @@
 option (NN_TESTS "Build and run nanomsg tests" ON)
 option (NN_TOOLS "Build nanomsg tools" ON)
 option (NN_ENABLE_NANOCAT "Enable building nanocat utility." ${NN_TOOLS})
+set (NN_MAX_SOCKETS 512 CACHE STRING "max number of nanomsg sockets that can be created")
 #  Platform checks.
@@ -237,6 +238,8 @@
     add_definitions (-DNN_HAVE_GCC_ATOMIC_BUILTINS)
 endif ()
 add_subdirectory (src)
 #  Build the tools
diff --git a/src/core/global.c b/src/core/global.c
index 12b1506..8fc13c2 100644
--- a/src/core/global.c
+++ b/src/core/global.c
@@ -59,8 +59,10 @@
 #include <unistd.h>
-/*  Max number of concurrent SP sockets. */
+/*  Max number of concurrent SP sockets. Configureable at build time */
 #define NN_MAX_SOCKETS 512
 /*  To save some space, list of unused socket slots uses uint16_t integers to
     refer to individual sockets. If there's a need to more that 0x10000 sockets,