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

Do not hardcode Compiler flags #3106

Closed
Fleischner opened this issue Mar 21, 2018 · 2 comments
Closed

Do not hardcode Compiler flags #3106

Fleischner opened this issue Mar 21, 2018 · 2 comments
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@Fleischner
Copy link

I tried to add an third build configuration (FastDebug) to vcpkg. As I recognized this is not easily possible.

So I decided to change the compiler flags of the default debug configuration instead.
However these are hardcoded into the the file vcpkg_configure_cmake.cmake
The user can only add additional flags by setting VCPKG_CXX_FLAGS Varibles

I suggest to put the configuration into the tripets files. Eg in variables as VCPKG_CXX_DEFAULT_FLAGS

The targeted code fragment where the flags are hardcoded:

common:

set(VCPKG_CXX_FLAGS " /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP ${VCPKG_CXX_FLAGS}")

set(VCPKG_C_FLAGS " /DWIN32 /D_WINDOWS /W3 /utf-8 /MP ${VCPKG_C_FLAGS}")

"-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}"

"-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}"

"-DCMAKE_SHARED_LINKER_FLAGS_DEBUG="

"-DCMAKE_EXE_LINKER_FLAGS_DEBUG="

shared:

"-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}"

"-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}"

"-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}"

"-DCMAKE_C_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}"

static:

"-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}"

"-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}"

"-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}"

"-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}"

@ras0219-msft ras0219-msft added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Mar 24, 2018
@ras0219-msft
Copy link
Contributor

Thanks for the suggestion!

On the master branch, these have been moved out into scripts\toolchains\windows.cmake, which can be entirely replaced by specifying (in your triplet file) VCPKG_CHAINLOAD_TOOLCHAIN_FILE.

However, this will currently suppress running vcvarsall.bat which means the build will not be able to locate cl.exe without you also specifying CMAKE_CXX_COMPILER (etcetera) in your toolchain file as well as the flags.

@Fleischner
Copy link
Author

Closing as feature is finished. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
Development

No branches or pull requests

2 participants