boost icon indicating copy to clipboard operation
boost copied to clipboard

Missing build type definitions

Open dutow opened this issue 6 years ago • 2 comments

The boost thread library build depends on the existence of the BOOST_THREAD_BUILD_LIB (static) or BOOST_THREAD_BUILD_DLL (dynamic) definitions.

In the normal build, it is defined in its Jamfile.

Without one of these defined, it marks functions defined in cpp files with dllimport on Windows.

The following addition to its CMakeLists solves the problem:

if (BUILD_SHARED_LIBS)
    target_compile_definitions(boost_thread PRIVATE BOOST_THREAD_BUILD_DLL)
else()
    target_compile_definitions(boost_thread PRIVATE BOOST_THREAD_BUILD_LIB)
endif()

dutow avatar Oct 03 '17 06:10 dutow

This isn't the only missing definitions - for example, I just noticed that while most libraries define BOOST_{NAME}_SOURCE in all of their cpp files, context defines BOOST_CONTEXT_SOURCE in its Jamfile, and without it, it won't add the dllexport specifiers.

So it also should be added to the CMakeLists in context:

target_compile_definitions(boost_context PRIVATE BOOST_CONTEXT_SOURCE)

I missed this (and probably others too) before because I've only built a static version so far, and unlike thread, the other libraries default to declarations without import/export symbols.

(uh, and sorry for opening all these as issues, but with a 1-commit repository with this recent commit date and older issues, I'm assuming you are just force pushing / rewriting a single commit)

dutow avatar Oct 03 '17 07:10 dutow

uh, and sorry for opening all these as issues, but with a 1-commit repository with this recent commit date and older issues, I'm assuming you are just force pushing / rewriting a single commit

I do push a single new commit since it is generated from a script, but you can still do PRs and I will merge the changes into the scripts as well.

pfultz2 avatar Oct 03 '17 14:10 pfultz2