1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

cmake+conan: do not use debug runtime in debug mode

This improves debug experience on windows using Visual Studio
This commit is contained in:
Anonymous Maarten 2018-12-19 19:32:05 +01:00
parent 5e582fd393
commit 151de65f69
5 changed files with 36 additions and 18 deletions

View File

@ -23,7 +23,7 @@ if(USE_CONAN)
message(STATUS "Using conan 'cmake' generator") message(STATUS "Using conan 'cmake' generator")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
endif() endif()
conan_basic_setup(TARGETS) conan_basic_setup(TARGETS NO_OUTPUT_DIRS)
rwdep_wrap_conan_targets() rwdep_wrap_conan_targets()
else() else()

View File

@ -4,7 +4,6 @@ add_library(openrw::interface ALIAS rw_interface)
add_library(rw_checks INTERFACE) add_library(rw_checks INTERFACE)
add_library(openrw::checks ALIAS rw_checks) add_library(openrw::checks ALIAS rw_checks)
target_link_libraries(rw_interface INTERFACE rw_checks) target_link_libraries(rw_interface INTERFACE rw_checks)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(rw_interface target_compile_options(rw_interface
INTERFACE INTERFACE
@ -16,6 +15,20 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang
"$<IF:$<COMPILE_LANGUAGE:CXX>,-Wold-style-cast,>" "$<IF:$<COMPILE_LANGUAGE:CXX>,-Wold-style-cast,>"
) )
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(MSVC_NO_DEBUG_RUNTIME)
foreach(LANG C CXX)
foreach(CONFIGURATION_TYPE ${CMAKE_CONFIGURATION_TYPES} "")
string(TOUPPER "${CONFIGURATION_TYPE}" CONFIGURATION_TYPE)
set(FLAGS_VAR "CMAKE_${LANG}_FLAGS")
if(CONFIGURATION_TYPE)
set(FLAGS_VAR "${FLAGS_VAR}_${CONFIGURATION_TYPE}")
endif()
string(REPLACE "/MDd" "/MD" "${FLAGS_VAR}" "${${FLAGS_VAR}}")
string(REPLACE "/MTd" "/MT" "${FLAGS_VAR}" "${${FLAGS_VAR}}")
set("${FLAGS_VAR}" "${${FLAGS_VAR}}" CACHE STRING "${LANG} flags for ${CONFIGURATION_TYPE} configuration type")
endforeach()
endforeach()
endif()
target_compile_definitions(rw_checks target_compile_definitions(rw_checks
INTERFACE INTERFACE
"_SCL_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_WARNINGS"

View File

@ -19,6 +19,9 @@ set(CMAKE_CONFIGURATION_TYPES "Release;Debug;RelWithDebInfo;MinSizeRel" CACHE IN
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}") set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}")
endif() endif()
if(MSVC)
option(MSVC_NO_DEBUG_RUNTIME "Don't use the debug runtime")
endif()
option(CHECK_IWYU "Enable IncludeWhatYouUse (Analyze #includes in C and C++ source files)") option(CHECK_IWYU "Enable IncludeWhatYouUse (Analyze #includes in C and C++ source files)")
option(CHECK_CLANGTIDY "Enable clang-tidy (A clang-based C++ linter tool)") option(CHECK_CLANGTIDY "Enable clang-tidy (A clang-based C++ linter tool)")

View File

@ -1,5 +1,4 @@
from conans import ConanFile, CMake from conans import ConanFile, CMake
from conans.errors import ConanException
class OpenrwConan(ConanFile): class OpenrwConan(ConanFile):
@ -13,19 +12,22 @@ class OpenrwConan(ConanFile):
'test_data': [True, False], 'test_data': [True, False],
'viewer': [True, False], 'viewer': [True, False],
'tools': [True, False], 'tools': [True, False],
'profiling': [True, False],
} }
default_options = ( default_options = {
'test_data=False', 'test_data': False,
'viewer=True', 'viewer': True,
'tools=True', 'tools': True,
'bullet3:shared=False', 'profiling': True,
'sdl2:sdl2main=False', 'bullet3:shared': False,
) 'sdl2:sdl2main': False,
}
generators = 'cmake', generators = 'cmake',
exports_sources = 'CMakeLists.txt', 'cmake_configure.cmake', 'cmake_options.cmake', 'COPYING', \ exports_sources = 'CMakeLists.txt', 'cmake_configure.cmake', 'cmake_options.cmake', 'CMakeCPack.cmake', 'COPYING', \
'cmake/modules/*', 'benchmarks', 'rwlib/*', 'rwengine/*', 'rwgame/*', 'rwviewer/*', 'tests/*' 'cmake/modules/*', 'benchmarks', 'rwcore/*', 'rwengine/*', 'rwgame/*', 'rwviewer/*', \
'rwtools/*', 'tests/*', 'external/*'
_rw_dependencies = { _rw_dependencies = {
'game': ( 'game': (
@ -67,6 +69,7 @@ class OpenrwConan(ConanFile):
'BUILD_VIEWER': self.options.viewer, 'BUILD_VIEWER': self.options.viewer,
'BUILD_TOOLS': self.options.tools, 'BUILD_TOOLS': self.options.tools,
'TESTS_NODATA': not self.options.test_data, 'TESTS_NODATA': not self.options.test_data,
'ENABLE_PROFILING': self.options.profiling,
'USE_CONAN': True, 'USE_CONAN': True,
'BOOST_STATIC': not self.options['boost'].shared, 'BOOST_STATIC': not self.options['boost'].shared,
} }

View File

@ -32,14 +32,13 @@ def create_solution(path, vs_version, arch):
conan, _, _ = conan_api.ConanAPIV1.factory() conan, _, _ = conan_api.ConanAPIV1.factory()
conan.remote_add('bincrafters', 'https://api.bintray.com/conan/bincrafters/public-conan', force=True) conan.remote_add('bincrafters', 'https://api.bintray.com/conan/bincrafters/public-conan', force=True)
conan_arch = conan_arch_map[arch] conan_arch = conan_arch_map[arch]
conan.install(path=openrw_path, generators=('cmake_multi',), build=['missing', ], conan.install(path=openrw_path, generators=('cmake',), build=['missing', ],
settings=('build_type=Debug', 'arch={}'.format(conan_arch), ), install_folder=path) settings=('build_type=Release', 'arch={}'.format(conan_arch), 'compiler.runtime=MD', ),
conan.install(path=openrw_path, generators=('cmake_multi',), build=['missing', ], install_folder=path)
settings=('build_type=Release', 'arch={}'.format(conan_arch), ), install_folder=path)
cmake_generator = to_cmake_generator(vs_version=vs_version, arch=arch) cmake_generator = to_cmake_generator(vs_version=vs_version, arch=arch)
subprocess.run([ subprocess.run([
'cmake', '-DUSE_CONAN=TRUE', '-DBOOST_STATIC=TRUE', 'cmake', '-DUSE_CONAN=ON', '-DBOOST_STATIC=ON', '-DMSVC_NO_DEBUG_RUNTIME=ON',
'-DBUILD_TESTS=TRUE', '-DBUILD_VIEWER=TRUE', '-DBUILD_TOOLS=TRUE', '-DBUILD_TESTS=ON', '-DBUILD_VIEWER=ON', '-DBUILD_TOOLS=ON',
'-G{}'.format(cmake_generator), str(openrw_path), '-G{}'.format(cmake_generator), str(openrw_path),
], cwd=path, check=True) ], cwd=path, check=True)