Since in my Windows 7 64-bit box with Windows 10 SDK 10.0.17763.0 launching Visual Studio 2017 Community Edition takes forever,
and knowing that later versions of Visual Studio have both CMake and ninja on their back,
today I happily compiled libvgm suite in a fast way with these four moves
1.
Code: Select all
C:\Users\user\libvgm>mkdir buildVs2017
C:\Users\user\libvgm>cd buildVs2017
C:\Users\user\libvgm\buildVs2017>
Just create a build folder.
2.
Code: Select all
C:\Users\user\libvgm\buildVS2017>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 10.0.17763.0
initializes environment variables for Visual Studio and PATH is among them.
Now utilities like cmake and ninja can be called with their names instead of call them with full paths like
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
and
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
NOTE - on Windows 10 it is possible to shorten this step 2. using Windows search, searching for `x64 Native Tools Command Prompt for VS 20XY` being `20XY` installed Microsoft Visual Studio number, and calling found App.
3.
Code: Select all
C:\Users\user\libvgm\buildVS2017>cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
Invoke cmake targetting ninja.
4.
Code: Select all
C:\Users\user\libvgm\buildVS2017>ninja
It's easy. Isn't it?
I suspect on Apple Mac things should be the same. For one thing now there's Visual Studio for Mac.
Or, if Xcode is preferred over Visual Studio for Mac, just
download CMake Mac installer and
retrieve Ninja from package manager. Then retrieve libvgm and
2-Mac.
Code: Select all
User-MBP:libvgm/buildMac User$cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..
3-Mac.
Code: Select all
User-MBP:libvgm/buildMac User$ninja
Giangiacomo
P.S.
for other reasons I have compiled zlib and iconv from sources and so, speaking the truth I also edited CMakeList.txt, this part
set(ZLIB_ROOT C:/Users/user/workspace/zlib-1.2.11 CACHE PATH "ZLib directory")
set(Iconv_INCLUDE_DIR C:/Users/user/workspace/libiconv-win-build/include CACHE PATH "directory with iconv headers")
set(Iconv_LIBRARY C:/Users/user/workspace/libiconv-win-build/build-VS2017-MT/x64/Release/libiconv.lib CACHE FILEPATH "iconv library")
P.P.S.
on Windows o.s. it seems more integrated and compact compiling with Visual Studio +
vcpkg package manager + ninja. Since libvgm depends on zlib and libiconv, vcpkg must be used to import these libraries with
Code: Select all
PS C:\Users\gzaff\Devs\libvgm> .\vcpkg install zlib:x64-windows libiconv:x64-windows
then modify CMakeLists.txt
Code: Select all
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 493ff85..7e24ec1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,11 +21,12 @@ if(MSVC)
set(CMAKE_DEBUG_POSTFIX "_${MSVC_POSTFIX}${CMAKE_DEBUG_POSTFIX}")
set(CMAKE_MINSIZEREL_POSTFIX "_${MSVC_POSTFIX}${CMAKE_MINSIZEREL_POSTFIX}")
set(CMAKE_RELWITHDEBINFO_POSTFIX "_${MSVC_POSTFIX}${CMAKE_RELWITHDEBINFO_POSTFIX}")
-
- set(ZLIB_ROOT "${PROJECT_SOURCE_DIR}/libs" CACHE PATH "ZLib directory")
- set(Iconv_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/libs/iconv/include" CACHE PATH "directory with iconv headers")
- set(Iconv_LIBRARY "${PROJECT_SOURCE_DIR}/libs/iconv/lib/libiconv.lib" CACHE FILEPATH "iconv library")
-
+
+ find_package(ZLIB REQUIRED)
+
+ add_library(unofficial::iconv::libcharset INTERFACE IMPORTED)
+ add_library(unofficial::iconv::libiconv INTERFACE IMPORTED)
+
if(NOT MSVC_VERSION LESS 1400)
add_definitions("/D _CRT_SECURE_NO_WARNINGS")
endif()
2.
Code: Select all
C:\Users\user\libvgm\buildVS2017>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 10.0.17763.0
3.
Code: Select all
C:\Users\user\libvgm\buildVS2017>cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=C:/Users/user/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ..
4.
Code: Select all
C:\Users\user\libvgm\buildVS2017>ninja