Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the right way to enable/disable Boost features in main CMake script? #106

Open
Bakul-Gaur opened this issue Dec 14, 2021 · 0 comments
Open

Comments

@Bakul-Gaur
Copy link

Hi Orphis/boost-cmake experts,

I am trying to port an old build-system to CMake (I am not too experienced with CMake).
I just tried boost-cmake and hats-off to its developers.. great package!

My project depends on Boost::locale and I am having some trouble with static linking against ICU libs. I know there are dozens of forums talking about it and suggesting changing link-order, etc. but nothing has worked for me so far. FYI, I end-up with something like this:

/usr/bin/c++    -static CMakeFiles/test_boost.dir/main.cpp.o  -o test_boost  boost-cmake/libboost_locale.a boost-cmake/libboost_thread.a boost-cmake/libboost_chrono.a /usr/lib/x86_64-linux-gnu/librt.a -lpthread /usr/local/lib/libicudata.a /usr/local/lib/libicui18n.a /usr/local/lib/libicuuc.a -ldl
/usr/bin/ld: /usr/local/lib/libicuuc.a(putil.ao): in function `uprv_dl_open_70':
putil.cpp:(.text.uprv_dl_open_70+0x16): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/lib/libicuuc.a(udata.ao): in function `doLoadFromCommonData(signed char, char const*, char const*, char const*, char const*, char const*, char const*, char const*, signed char (*)(void*, char const*, char const*, UDataInfo const*), void*, UErrorCode*, UErrorCode*) [clone .constprop.0]':
udata.cpp:(.text._ZL20doLoadFromCommonDataaPKcS0_S0_S0_S0_S0_S0_PFaPvS0_S0_PK9UDataInfoES1_P10UErrorCodeS8_.constprop.0+0x3ca): undefined reference to `icudt70_dat'
/usr/bin/ld: udata.cpp:(.text._ZL20doLoadFromCommonDataaPKcS0_S0_S0_S0_S0_S0_PFaPvS0_S0_PK9UDataInfoES1_P10UErrorCodeS8_.constprop.0+0x4af): undefined reference to `icudt70_dat'

ICU lib has given me other troubles too, so I decided to disable it (and use the iconv lib instead) by doing:

set(BOOST_LOCALE_ENABLE_ICU_BACKEND OFF)
add_subdirectory(boost-cmake)
...

I know this is not the recommended way to override options in sub-projects. And of course it fails at configure:

-- Boost locale unsupported on platform: need either iconv or ICU.
-- Configuring done
CMake Error at CMakeLists.txt:11 (add_executable):
  Target "test_boost" links to target "Boost::locale" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

I thought the option BOOST_LOCALE_ENABLE_ICONV_BACKEND in boost-cmake\libs\locale.cmake will take effect. But it doesn't. I have no idea of how to configure it right.

My questions is: what is the foreseen way to configure Boost with Orphis/boost-cmake? Can you please provide an example?

Here is my CMake script for a hello-world C++ program using Boost::locale:

cmake_minimum_required(VERSION 3.16)

project(test_boost)

# boost-cmake setup
# -----------------
find_library(RT_LIBRARY NAMES librt.a)
set(BOOST_LOCALE_ENABLE_ICU_BACKEND OFF)
add_subdirectory(boost-cmake)

# My hello-world binary
# ---------------------
add_executable(test_boost main.cpp)
target_link_libraries(test_boost
	PRIVATE
		Boost::boost
		Boost::locale
)
target_link_options(test_boost PRIVATE -static)

Other details about my setup:

  • I am using WSL2 Ubuntu 20.04.3 LTS
  • Orphis/boost-cmake branch master
  • gcc 9.3.0
  • cmake 3.16.3
  • Boost 1.71.0 (default in Orphis/boost-cmake)

Thanks in advance!

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

No branches or pull requests

1 participant