Skip to content

CMake build doesn't disable the Windows autolink feature #525

@jtytgat

Description

@jtytgat

When using the CMake build for the process component of Boost on Windows, the autolink feature is still active (using process v2 API), resulting in a link error:

LINK : fatal error LNK1104: cannot open file 'boost_process-vc143-mt-gd-x64-1_89.lib'

Using boost 1.89 release but I believe the problem is still present currently, i.e. autolink is active for CMake builds.

When comparing the CMakeLists.txt of Boost process with e.g. filesystem or url we don't have a BOOST_<COMPONENT>_NO_LIB define in Boost process:

url:
--8<--
function(boost_url_setup_properties target)
target_compile_features(${target} PUBLIC cxx_constexpr)
target_compile_definitions(${target} PUBLIC BOOST_URL_NO_LIB=1)
--8<--

filesystem:
--8<--
target_compile_definitions(boost_filesystem
PUBLIC
# NOTE:
# We deactivate autolinking, because cmake based builds don't need it
# and we don't implement name mangling for the library file anyway.
# Ususally the parent CMakeLists.txt file should already have globally defined BOOST_ALL_NO_LIB
BOOST_FILESYSTEM_NO_LIB
$&lt;$&lt;STREQUAL:$<TARGET_PROPERTY:boost_filesystem,TYPE>,SHARED_LIBRARY>:BOOST_FILESYSTEM_DYN_LINK=1>
$&lt;$&lt;STREQUAL:$<TARGET_PROPERTY:boost_filesystem,TYPE>,STATIC_LIBRARY>:BOOST_FILESYSTEM_STATIC_LINK=1>
PRIVATE
BOOST_FILESYSTEM_SOURCE
)
--8<--

Changing in process' CMakeLists.txt from...

--8<--
target_compile_definitions(boost_process
PRIVATE BOOST_PROCESS_SOURCE=1
)
--8<--
to...
--8<--
target_compile_definitions(boost_process
PUBLIC BOOST_PROCESS_NO_LIB
PRIVATE BOOST_PROCESS_SOURCE=1
)
--8<--

...solves the problem as it disables the autolink features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions