Add support for VS CMake/vcpkg compilation (#1174)
* Add support for VS CMake/vcpkg compilation * Fix system_windows.cpp compilation * Add optimization and hidden console to MSVC release builds1008-fix
parent
073191d1ea
commit
abb7d54ef5
|
@ -38,3 +38,7 @@ CMakeLists.txt.user.*
|
||||||
|
|
||||||
# Ignore Visual Studio Code files
|
# Ignore Visual Studio Code files
|
||||||
/.vscode
|
/.vscode
|
||||||
|
|
||||||
|
# Ignore Visual Studio files
|
||||||
|
/CMakeSettings.json
|
||||||
|
/.vs
|
||||||
|
|
|
@ -124,6 +124,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
# Include cmake directory with some additional scripts
|
# Include cmake directory with some additional scripts
|
||||||
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
# MSVC needs different flags if linking statically
|
||||||
|
option(MSVC_STATIC "Link statically when using MSVC" OFF)
|
||||||
|
|
||||||
# Compiler detection
|
# Compiler detection
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
||||||
|
@ -160,14 +163,19 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
message(STATUS "Detected MSVC compiler")
|
message(STATUS "Detected MSVC compiler")
|
||||||
|
|
||||||
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
|
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
|
||||||
set(RELEASE_CXX_FLAGS "/MD")
|
if(MSVC_STATIC)
|
||||||
set(DEBUG_CXX_FLAGS "/MDd /ZI")
|
set(RELEASE_CXX_FLAGS "/MT /Ox")
|
||||||
|
set(DEBUG_CXX_FLAGS "/MTd /ZI")
|
||||||
|
else(MSVC_STATIC)
|
||||||
|
set(RELEASE_CXX_FLAGS "/MD /Ox")
|
||||||
|
set(DEBUG_CXX_FLAGS "/MDd /ZI")
|
||||||
|
endif()
|
||||||
set(TEST_CXX_FLAGS "")
|
set(TEST_CXX_FLAGS "")
|
||||||
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
|
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
|
||||||
|
|
||||||
# Needed for Debug information (it's set to "No" by default for some reason)
|
# Needed for Debug information (it's set to "No" by default for some reason)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG")
|
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.")
|
message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.")
|
||||||
endif()
|
endif()
|
||||||
|
@ -315,6 +323,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
|
||||||
set(CBOT_STATIC 1) # only this works for some reason
|
set(CBOT_STATIC 1) # only this works for some reason
|
||||||
set(WINGETOPT 1) # use wingetopt library
|
set(WINGETOPT 1) # use wingetopt library
|
||||||
|
|
||||||
|
# Hide console in release builds
|
||||||
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(CMAKE_WIN32_EXECUTABLE 1)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
|
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
|
||||||
|
|
||||||
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile)
|
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1)
|
||||||
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
|
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
|
||||||
|
|
||||||
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
|
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
|
||||||
|
|
|
@ -7,7 +7,7 @@ IF (WIN32)
|
||||||
FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
|
FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
|
||||||
DOC "The directory where physfs.h resides")
|
DOC "The directory where physfs.h resides")
|
||||||
FIND_LIBRARY( PHYSFS_LIBRARY
|
FIND_LIBRARY( PHYSFS_LIBRARY
|
||||||
NAMES physfs
|
NAMES physfs physfs-static
|
||||||
PATHS /mingw/lib
|
PATHS /mingw/lib
|
||||||
DOC "The PhysFS library")
|
DOC "The PhysFS library")
|
||||||
ELSE (WIN32)
|
ELSE (WIN32)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "CBot/CBotInstr/CBotFunction.h"
|
#include "CBot/CBotInstr/CBotFunction.h"
|
||||||
#include "CBot/CBotInstr/CBotInstrCall.h"
|
#include "CBot/CBotInstr/CBotInstrCall.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
|
@ -151,7 +151,12 @@ set(LOCAL_INCLUDES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(SYSTEM_INCLUDES
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(${LOCAL_INCLUDES})
|
include_directories(${LOCAL_INCLUDES})
|
||||||
|
include_directories(SYSTEM ${SYSTEM_INCLUDES})
|
||||||
|
|
||||||
|
|
||||||
if(CBOT_STATIC)
|
if(CBOT_STATIC)
|
||||||
|
|
|
@ -44,8 +44,51 @@ if(MXE) # MXE requires special treatment
|
||||||
elseif(PLATFORM_WINDOWS)
|
elseif(PLATFORM_WINDOWS)
|
||||||
# because it isn't included in standard linking libraries
|
# because it isn't included in standard linking libraries
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
find_library(LIBINTL_LIBRARY NAMES intl.lib)
|
find_library(LIBINTL_LIBRARY NAMES intl.lib libintl)
|
||||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
|
|
||||||
|
if(${MSVC_STATIC})
|
||||||
|
if (${OPENAL_SOUND})
|
||||||
|
find_library(FLAC_LIBRARY NAMES flac.lib)
|
||||||
|
find_library(VORBIS_LIBRARY NAMES vorbis.lib)
|
||||||
|
find_library(VORBISENC_LIBRARY NAMES vorbisenc.lib)
|
||||||
|
find_library(OGG_LIBRARY NAMES ogg.lib)
|
||||||
|
set(OPENAL_MSVC_LIBS
|
||||||
|
${FLAC_LIBRARY}
|
||||||
|
${VORBIS_LIBRARY}
|
||||||
|
${VORBISENC_LIBRARY}
|
||||||
|
${OGG_LIBRARY}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(BZ2_LIBRARY NAMES bz2.lib)
|
||||||
|
find_library(JPEG_LIBRARY NAMES jpeg.lib)
|
||||||
|
find_library(TIFF_LIBRARY NAMES tiff.lib)
|
||||||
|
find_library(WEBP_LIBRARY NAMES webp.lib)
|
||||||
|
find_library(LZMA_LIBRARY NAMES lzma.lib)
|
||||||
|
find_library(FREETYPE_LIBRARY NAMES freetype.lib)
|
||||||
|
set(MSVC_LIBS
|
||||||
|
${LIBINTL_LIBRARY}
|
||||||
|
${OPENAL_MSVC_LIBS}
|
||||||
|
${JPEG_LIBRARY}
|
||||||
|
${TIFF_LIBRARY}
|
||||||
|
${BZ2_LIBRARY}
|
||||||
|
${WEBP_LIBRARY}
|
||||||
|
${LZMA_LIBRARY}
|
||||||
|
${FREETYPE_LIBRARY}
|
||||||
|
winmm.lib
|
||||||
|
dxguid.lib
|
||||||
|
imm32.lib
|
||||||
|
ole32.lib
|
||||||
|
oleaut32.lib
|
||||||
|
version.lib
|
||||||
|
wsock32.lib
|
||||||
|
ws2_32.lib
|
||||||
|
)
|
||||||
|
else(${MSVC_STATIC})
|
||||||
|
set(MSVC_LIBS ${LIBINTL_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PLATFORM_LIBS ${MSVC_LIBS})
|
||||||
else()
|
else()
|
||||||
set(PLATFORM_LIBS "-lintl")
|
set(PLATFORM_LIBS "-lintl")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -111,7 +111,7 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
|
||||||
std::string CSystemUtilsWindows::GetSaveDir()
|
std::string CSystemUtilsWindows::GetSaveDir()
|
||||||
{
|
{
|
||||||
#if PORTABLE_SAVES || DEV_BUILD
|
#if PORTABLE_SAVES || DEV_BUILD
|
||||||
return "./saves";
|
return CSystemUtils::GetSaveDir();
|
||||||
#else
|
#else
|
||||||
std::string savegameDir;
|
std::string savegameDir;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ std::string CSystemUtilsWindows::GetSaveDir()
|
||||||
if (envUSERPROFILE == nullptr)
|
if (envUSERPROFILE == nullptr)
|
||||||
{
|
{
|
||||||
GetLogger()->Warn("Unable to find directory for saves - using current directory");
|
GetLogger()->Warn("Unable to find directory for saves - using current directory");
|
||||||
savegameDir = CSystemUtils::GetSaveDir(false);
|
savegameDir = "./saves";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue