[zeromq-dev] cmake: building zmq with sodium

Frank Hartmann soundart at gmx.net
Sun Mar 23 13:33:20 CET 2014


Hi,

I played with "modern cmake" approach which uses some of the
features(especially "target usage requirements") introduced in 
cmake >= 2.8.12.

I like it a lot, it is really elegant and targets for better builds. Of
course I will probably have introduced some problems myself and whole
parts are still magic to mee.

If you would like to try it out clone https://github.com/soundart/libsodium

which provides a single new file

https://github.com/soundart/libsodium/blob/master/CMakeLists.txt 

which provides the targets and adds a FindSodium module to your cmake
build. The cmake script currently is quite basic and misses lots of
features compared to the autoconf one, so be warned.

In libzmq CMakeLists.txt you need to call find_package and use the
results:

find_package(Sodium)
target_link_libraries(libzmq ${SODIUM_LIBRARY})

see

https://github.com/soundart/libzmq/blob/master/CMakeLists.txt

In your Application "xx" which uses libzmq you would have the following
files and clones:

./CMakeLists.txt # script below
./libzmq         # git clone
./libsodium      # git clone

#----------------------------------------------------------------------
project(test_sodium_with_zmq)

cmake_minimum_required(VERSION 2.8.12)

enable_testing()
add_subdirectory(libsodium)

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/Modules)
find_package(Sodium)

if(SODIUM_FOUND)
  add_definitions(-DHAVE_LIBSODIUM)
else()
  message(FATAL_ERROR "no sodium?")
endif()

add_subdirectory(libzmq)


include_directories(libzmq/include ${CMAKE_BINARY_DIR}/libzmq)
add_executable(xx libzmq/tests/test_security_curve.cpp)
target_link_libraries(xx libzmq)
#----------------------------------------------------------------------



I would like to have the setup of CMAKE_MODULE_PATH done by the libsodium
cmake script, but did not get that to work.

It would be nice if you could try that flow on other systems (other than
Debian/Wheezy/Amd64) and give patches and feedback!  

kind regards
  Frank



More information about the zeromq-dev mailing list