6

I'm trying to build only the release version of packages because creating debug versions takes too long / too much space. Vcpkg docs state that:

Adding set(VCPKG_BUILD_TYPE release) in a triplet: will cause most ports to only build release

In terminal when I run set(VCPKG_BUILD_TYPE release) I get

syntax error near unexpected token 'VCPKG_BUILD_TYPE'

How do I fix this?

TooTone
  • 7,129
  • 5
  • 34
  • 60
Carl
  • 705
  • 8
  • 22

1 Answers1

11

You probably need to set it in your triplet file. Make a copy and rename one of those default triplet files, say "x64-windows.cmake" to "x64-windows-rel.cmake". Then add a line so that:

 
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_BUILD_TYPE release)

I think this will work on some libraries but not all, as it requires the libraries' own build files (CMakeLists.txt) to deal with it.

kjpus
  • 509
  • 4
  • 8
  • Could it also be set on the command prompt before running vcpkg.exe? `set VCPKG_BUILD_TYPE=release`? – Stéphane Sep 14 '20 at 09:21
  • 1
    I don't think so. A quick search in vcpkg seems to suggest it doesn't check VCPKG_BUILD_TYPE in environment variable. – kjpus Sep 16 '20 at 02:57
  • 1
    Looks like VCPKG_BUILD_TYPE is not well supported. E.g., OpenCV's build fails if you set it since parts of the build scripts expect both release and debug are being built. – Stéphane Sep 17 '20 at 19:58
  • What if I want to let system detect triplet itself, and set only VCPKG_BUILD_TYPE? – kyb Oct 27 '21 at 13:41