Skip to content

Conversation

torbjoernk
Copy link

As proposed by @deanberris on Google Groups, this patch adds an additional CMake option BUILD_SHARED_LIBS to build cpp-netlib as shared libraries.

As a side effect, two further CMake options are introduced to selectively enable or disable build of the unit tests and examples: BUILD_TESTS and BUILD_EXAMPLES.

Some minor modifications to the preprocessor part of the unit tests were necessary to achieve successful build and execution of the unit tests with cpp-netlib as shared libraries.

I tested these modifications with CMake 2.8.9 and 2.8.10 with GCC 4.7 on Linux 64bit. Unfortunately I cannot test on other platforms as OSX or Windows.

Add options to CMake to enable build of cpp-netlib as shared libraries.
New options are:
  BUILD_SHARED_LIBS (default OFF)
  BUILD_TESTS (default ON)
  BUILD_EXAMPLES (default ON)

As the current (CMakeLists-)setup of the tests and examples does not
work with a shared cpp-netlib build, those get not build then.

Specify with `cmake -D<OPTION>=<ON|OFF>`
keeping those lines will break previously introduced options
The unit tests will compile and run now as well for cpp-netlib compiled
as shared libraries.
'cppnetlib-utils-thread_pool' had to be added to the list of linked
libraries for 'cppnetlib-http-server'. For the static case this was not
a problem but in the shared case symbols were missing.

Listing external shared or static libraries in 'add_dependencies' is not
required. This CMake command is for adding dependencies between
different targets defined by 'add_executable', 'add_library' or
'add_custom_target'.
else()
set(Boost_COMPONENTS system regex date_time thread chrono filesystem program_options )
endif()
find_package( Boost 1.45.0 REQUIRED ${Boost_COMPONENTS} )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always meant to upgrade this to 1.51 -- would you mind changing this to 1.51 now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing easier than that. I've only tested with Boost 1.51.0 though.

@ghost ghost assigned deanberris Nov 4, 2012
@deanberris
Copy link
Member

This one looks very good to me. Let me know if you can make the upgrade to 1.51 too. 👍

@deanberris
Copy link
Member

Awesome stuff, thanks Torbjörn! I'm merging this in now.

deanberris added a commit that referenced this pull request Nov 4, 2012
Enable build of cpp-netlib as shared libraries
@deanberris deanberris merged commit b9c3a01 into cpp-netlib:master Nov 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants