VCPKG on Mac OSX

Hello,

I have a Macbook Air 2018 with macOS Mojave installed.

For the development, I uses Windows 10 during my work time. There are many useful Unix/Linux libraries that can be used with vcpkg like GTK+ or CAIRO on Windows 10. It saves my time during my tests.

I'd like to have a similar environment on my Macbook Air. But I could not build vcpkg. Maybe an experimental library called c++fs is not available or it cannot be built for C++17. Additional info, macOS uses Clang to build C/C++ programs instead of GNU GCC. I was researching on Google, many developers failed to build vcpkg and got similar build errors.

So I decided to join the BETA program and install the beta version of macOS: Catalina. Besides of that, I installed the Command Line Tools for Xcode 11 Beta 6. It is available in Apple Developer site.

Finally, my environment is ready! So, go to the Terminal, clone the vcpkg source code and run the script:


$ git clone https://github.com/microsoft/vcpkg.git
$ cd vcpkg


Then edit the following line:

$ vi toolsrc/CMakeLists.txt

Comment the line:

if(GCC OR (CLANG AND USES_LIBSTDCXX))
    link_libraries(stdc++fs)
elseif(CLANG AND NOT MSVC)
#    link_libraries(c++fs)
endif()

And replace the compile options(c++lz -> c++17) :

elseif(GCC OR CLANG)
#    add_compile_options(-std=c++1z)
add_compile_options(-std=c++17)

if(VCPKG_DEVELOPMENT_WARNINGS)
    add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Werror)


Save and run the script below:

./bootstrap-vcpkg.sh --allowAppleClang


In my case, my build succeeded. So, I hope yours can succeed too.


Sorry about my writing. I am in a rush now, I cannot do a more elaborated tutorial.



Thanks for reading!

Comments