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

A problem with VC++ and vcpkg due to setting C++ standard as public compile option for Folly::folly target #2295

Open
eao197 opened this issue Sep 19, 2024 · 0 comments

Comments

@eao197
Copy link

eao197 commented Sep 19, 2024

There is a line in FollyCompilerMSVC.cmake that adds /std: compiler option for Folly::folly target:

/std:${MSVC_LANGUAGE_VERSION} # Build in the requested version of C++

This line causes a problem with I'm trying to use Folly with VC++ via vcpkg. There is the output from the compiler:

FAILED: CMakeFiles/folly_case.dir/main.cpp.obj
C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\cl.exe 
  /nologo /TP -DBOOST_ATOMIC_NO_LIB -DBOOST_ATOMIC_STATIC_LINK -DBOOST_CHRONO_NO_LIB
  -DBOOST_CHRONO_STATIC_LINK -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE -DBOOST_CONTAINER_NO_LIB
  -DBOOST_CONTAINER_STATIC_LINK -DBOOST_CONTEXT_EXPORT="" -DBOOST_CONTEXT_NO_LIB=""
  -DBOOST_CONTEXT_STATIC_LINK="" -DBOOST_DATE_TIME_NO_LIB -DBOOST_DATE_TIME_STATIC_LINK
  -DBOOST_FILESYSTEM_NO_LIB -DBOOST_FILESYSTEM_STATIC_LINK=1 -DBOOST_PROGRAM_OPTIONS_NO_LIB
  -DBOOST_PROGRAM_OPTIONS_STATIC_LINK -DBOOST_THREAD_NO_LIB -DBOOST_THREAD_STATIC_LINK
  -DBOOST_THREAD_USE_LIB -DGFLAGS_IS_A_DLL=0 -DGLOG_NO_ABBREVIATED_SEVERITIES -DGLOG_USE_GFLAGS
  -DGLOG_USE_GLOG_EXPORT -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_NONSTDC_NO_WARNINGS
  -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_SCL_SECURE_NO_WARNINGS
  -D_STL_EXTRA_DISABLED_WARNINGS="4774 4987"
  -external:IC:\home\eao197\sandboxes\folly_vcpkg_msvc_cpp20\cmake_build_release\vcpkg_installed\x64-windows-static\include
  -external:W0 /DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG
  -std:c++20
  -MT /EHs /GF /Zc:referenceBinding /Zc:rvalueCast /Zc:implicitNoexcept /Zc:strictStrings /Zc:threadSafeInit /Zc:throwingNew
  /permissive-
  /std:c++17
  /wd4191 /wd4291 /wd4309 /wd4310 /wd4366 /wd4587 /wd4592 /wd4628 /wd4723 /wd4724 /wd4868 /wd4996
  /wd4068 /wd4091 /wd4146 /wd4800 /wd4018 /wd4365 /wd4388 /wd4389 /wd4100 /wd4459 /wd4505 /wd4701
  /wd4702 /wd4061 /wd4127 /wd4200 /wd4201 /wd4296 /wd4316 /wd4324 /wd4355 /wd4371 /wd4435 /wd4514
  /wd4548 /wd4571 /wd4574 /wd4582 /wd4583 /wd4619 /wd4623 /wd4625 /wd4626 /wd4643 /wd4647 /wd4668
  /wd4706 /wd4710 /wd4711 /wd4714 /wd4820 /wd5026 /wd5027 /wd5031 /wd5045 /we4099 /we4129 /we4566
  /utf-8 /Zc:__cplusplus /showIncludes /FoCMakeFiles\folly_case.dir\main.cpp.obj /FdCMakeFiles\folly_case.dir\ /FS
  -c C:\home\eao197\sandboxes\folly_vcpkg_msvc_cpp20\main.cpp
cl : Command line warning D9025 : overriding '/std:c++20' with '/std:c++17'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\concepts(12): warning STL4038: The contents of <concepts> are available only with C++20 or later.
C:\home\eao197\sandboxes\folly_vcpkg_msvc_cpp20\main.cpp(5): error C2039: 'movable': is not a member of 'std'

The /std:c++17 inherited from Folly::folly overrides /std:c++20 from my project and prevents compilation in C++20 mode.

There is a demo project that show this case: https://github.com/eao197/folly_vcpkg_msvc_cpp20

It seems that there is no need to add /std:${MSVC_LANGUAGE_VERSION} as a PUBLIC compile option for the target Folly::folly, it has to be PRIVATE option in terms of CMake's target_compile_options.

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