]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Improve MSVC cmake and update vcpkg instruction (#10407)
authork.h.lai <dlshcbmuipmam@hotmail.com>
Tue, 29 Sep 2020 17:39:53 +0000 (01:39 +0800)
committerGitHub <noreply@github.com>
Tue, 29 Sep 2020 17:39:53 +0000 (19:39 +0200)
Remove unnecessary compiler flag for clang-cl
Update vcpkg instruction in README.md

README.md
src/CMakeLists.txt

index 6a3c11f40cc5336b7df79704a76bb7db879ce9bc..a06c3e2577268072c198ccf809421ce1a4e6ca26 100644 (file)
--- a/README.md
+++ b/README.md
@@ -314,13 +314,14 @@ It is highly recommended to use vcpkg as package manager.
 
 After you successfully built vcpkg you can easily install the required libraries:
 ```powershell
-vcpkg install irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit --triplet x64-windows
+vcpkg install irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp --triplet x64-windows
 ```
 
 - `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store.
 - `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound.
 - `freetype` is optional, it allows true-type font rendering.
 - `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter.
+- `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled
 
 There are other optional libraries, but they are not tested if they can build and link correctly.
 
@@ -353,7 +354,7 @@ This is outdated and not recommended. Follow the instructions on https://dev.min
 Run the following script in PowerShell:
 
 ```powershell
-cmake . -G"Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GETTEXT=0 -DENABLE_CURSES=0
+cmake . -G"Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GETTEXT=OFF -DENABLE_CURSES=OFF -DENABLE_SYSTEM_JSONCPP=ON
 cmake --build . --config Release
 ```
 Make sure that the right compiler is selected and the path to the vcpkg toolchain is correct.
index 7e1d0bd39bedf35b12584fa9a26ee27537baca56..b5d4fae0e60fa69ec4e58ab99c6608b8565dd76c 100644 (file)
@@ -701,21 +701,14 @@ include(CheckCSourceCompiles)
 
 if(MSVC)
        # Visual Studio
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN /MP")
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN")
        # EHa enables SEH exceptions (used for catching segfaults)
-       set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
+       set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0")
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
                set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE")
        endif()
-       
-       if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-               set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
-       else()
-               set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
-       endif()
-
-       set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
 
+       set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
 
        set(CMAKE_CXX_FLAGS_SEMIDEBUG "/MDd /Zi /Ob0 /O1 /RTC1")
 
@@ -726,6 +719,19 @@ if(MSVC)
        # Flags for C files (sqlite)
        # /MD = dynamically link to MSVCRxxx.dll
        set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MD")
+
+       # Flags that cannot be shared between cl and clang-cl
+       # https://clang.llvm.org/docs/UsersManual.html#clang-cl
+       if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
+
+               # Disable pragma-pack warning
+               set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-pragma-pack")
+       else()
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+               set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /TP /FD /GL")
+               set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
+       endif()
 else()
        # GCC or compatible compilers such as Clang
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")