build: support RelWithDebInfo for vcpkg
Make some tweaks to the cmake files to support CMAKE_BUILD_TYPE=RelWithDebInfo, release with debug information for MSVC vcpkg builds. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
40711fa5c9
commit
23aa083cd4
|
@ -88,6 +88,11 @@ elseif(NOT CMAKE_BUILD_TYPE MATCHES "^(Release|Debug|RelWithDebInfo|MinSizeRel)$
|
||||||
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}', must be one of: 'Release', 'Debug', 'RelWithDebInfo' or 'MinSizeRel'")
|
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}', must be one of: 'Release', 'Debug', 'RelWithDebInfo' or 'MinSizeRel'")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Link debug libs for RelWithDebInfo
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug")
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
|
@ -168,6 +173,14 @@ endif()
|
||||||
|
|
||||||
find_package(SFML 2.4 COMPONENTS network system)
|
find_package(SFML 2.4 COMPONENTS network system)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
||||||
|
if(SFML_STATIC_LIBRARIES AND SFML_NETWORK_LIBRARY_STATIC_DEBUG AND SFML_SYSTEM_LIBRARY_STATIC_DEBUG)
|
||||||
|
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_STATIC_DEBUG} ${SFML_SYSTEM_LIBRARY_STATIC_DEBUG})
|
||||||
|
elseif(SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG AND SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG)
|
||||||
|
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG} ${SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SFML_FOUND)
|
if(SFML_FOUND)
|
||||||
set(ENABLE_LINK_DEFAULT ON)
|
set(ENABLE_LINK_DEFAULT ON)
|
||||||
endif()
|
endif()
|
||||||
|
@ -652,9 +665,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_ASAN)
|
if(ENABLE_ASAN)
|
||||||
string(TOLOWER ${CMAKE_BUILD_TYPE} build)
|
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
if(NOT build STREQUAL "debug")
|
message(FATAL_ERROR "asan requires a debug build, set -DCMAKE_BUILD_TYPE=Debug")
|
||||||
message(FATAL_ERROR "asan requires debug build, set -DCMAKE_BUILD_TYPE=Debug")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(TOLOWER ${ENABLE_ASAN} SANITIZER)
|
string(TOLOWER ${ENABLE_ASAN} SANITIZER)
|
||||||
|
@ -809,9 +821,11 @@ elseif(MSVC)
|
||||||
set(runtime "/MD")
|
set(runtime "/MD")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
|
||||||
set(runtime "${runtime}d")
|
set(runtime "${runtime}d")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
add_compiler_flags(${runtime} /ZI /W4 /Ob0 /Od /RTC1 /DDEBUG /EHsc)
|
add_compiler_flags(${runtime} /ZI /W4 /Ob0 /Od /RTC1 /DDEBUG /EHsc)
|
||||||
else()
|
else()
|
||||||
# Enable severe warnings for release builds, but suppress macro
|
# Enable severe warnings for release builds, but suppress macro
|
||||||
|
@ -819,11 +833,7 @@ elseif(MSVC)
|
||||||
add_compiler_flags(/W1 /wd4005 /DNDEBUG /EHsc)
|
add_compiler_flags(/W1 /wd4005 /DNDEBUG /EHsc)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||||
if(X86_32)
|
add_compiler_flags(${runtime} /O2 /Ob3)
|
||||||
add_compiler_flags(${runtime} /O2 /Ob3)
|
|
||||||
else()
|
|
||||||
add_compiler_flags(${runtime} /O2 /Ob3)
|
|
||||||
endif()
|
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
||||||
add_compiler_flags(${runtime} /Zi /Ob1)
|
add_compiler_flags(${runtime} /Zi /Ob1)
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
|
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
|
||||||
|
|
|
@ -169,7 +169,7 @@ ENDIF(NOT APPLE)
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
SET(MINGW32_LIBRARY -lmingw32 CACHE STRING "MinGW library")
|
SET(MINGW32_LIBRARY -lmingw32 CACHE STRING "MinGW library")
|
||||||
|
|
||||||
IF(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
|
||||||
SET(MINGW32_LIBRARY ${MINGW32_LIBRARY} -mwindows)
|
SET(MINGW32_LIBRARY ${MINGW32_LIBRARY} -mwindows)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
|
@ -349,4 +349,14 @@ endfunction()
|
||||||
|
|
||||||
vcpkg_set_toolchain()
|
vcpkg_set_toolchain()
|
||||||
|
|
||||||
|
# Make vcpkg use debug libs for RelWithDebInfo
|
||||||
|
set(orig_build_type ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
||||||
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_TYPE ${orig_build_type})
|
||||||
|
unset(orig_build_type)
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ if(NOT TRANSLATIONS_ONLY)
|
||||||
|
|
||||||
unset(pdb_file)
|
unset(pdb_file)
|
||||||
|
|
||||||
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL Debug)
|
if(MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
|
||||||
set(pdb_file visualboyadvance-m.pdb)
|
set(pdb_file visualboyadvance-m.pdb)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue