- if( PACK_EXTERNALS )
- # This makes some stand-alone unit testing possible for bindings and transport layer testing;
- # it is not meant for production packages.
- #
- unset( SKIP_EXTERNALS CACHE ) # must remove so as not to trap user into a never ending failure
- unset( PACK_EXTERNALS CACHE )
- message( FATAL_ERROR "ERROR: PACK_EXTERNALS can be set only if SKIP_EXTERNALS is unset (=0, or not supplied on command line)" )
+ if( NOT SKIP_EXTERNALS )
+ set( need_ext 1 ) # we force dependences on these for right build order
+ execute_process( COMMAND git submodule update --init -- ext/nng
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+ if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext/nng/CMakeLists.txt )
+ message( FATAL_ERROR "cannot find nng in our git source as a submodule: Giving up" ) # this will abort which seems wrong, but tdam.
+ endif()
+
+ include( ExternalProject )
+ ExternalProject_Add(
+ ext_nng
+ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nng"
+ CMAKE_ARGS "-DBUILD_SHARED_LIBS=1"
+ CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}"
+ BUILD_COMMAND "make"
+ UPDATE_COMMAND ""
+ TEST_COMMAND ""
+ STEP_TARGETS build
+ )
+
+ # it seems impossible to install everything that lands in {bin}/lib, so we need to
+ # hard code (shudder) some things. Even worse, we have to make exceptions for
+ # builds on apple (osx) since their naming convention wandered off the path.
+ set( nng_major 1 )
+ set( nng_minor 1.0 )
+ set( so ${CMAKE_SHARED_LIBRARY_SUFFIX} ) # cmake variables are impossibly long :(
+ if( NOT APPLE ) # probably breaks in windows, but idc
+ set( nng_so_suffix ${so} )
+ set( nng_so_suffix_m ${so}.${nng_major} )
+ set( nng_so_suffix_mm ${so}.${nng_major}.${nng_minor} )
+ else()
+ # of course apple puts versions before the suffix :(
+ set( nng_so_suffix ${so} ) # so has a lead dot, so NOT needed
+ set( nng_so_suffix_m ".${nng_major}${so}" ) # these need leading dots
+ set( nng_so_suffix_mm ".${nng_major}.${nng_minor}${so}" )
+ endif()
+
+ message( "+++ building with nng: ${nng_major}.${nng_minor}" )
+ else()
+ if( PACK_EXTERNALS )
+ # This makes some stand-alone unit testing possible for bindings and transport layer testing;
+ # it is not meant for production packages.
+ #
+ unset( SKIP_EXTERNALS CACHE ) # must remove so as not to trap user into a never ending failure
+ unset( PACK_EXTERNALS CACHE )
+ message( FATAL_ERROR "ERROR: PACK_EXTERNALS can be set only if SKIP_EXTERNALS is unset (=0, or not supplied on command line)" )
+ endif()
+ set( need_ext 0 )