From f0d78e3f7b518ef91ddcba77f5f2c72425fff840 Mon Sep 17 00:00:00 2001 From: David Brooks Date: Sun, 28 Aug 2016 19:28:42 +0100 Subject: [PATCH 1/4] Add `_d` postfix to MS Windows library names for CMake debug builds. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c897e5f7d..8eccfca7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,10 @@ if(CMAKE_CROSSCOMPILING) cmake_minimum_required(VERSION 3.3) # Version introducing CROSSCOMPILING_EMULATOR endif() +if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set(CMAKE_DEBUG_POSTFIX "_d") +endif() + # Include helper functions include(cmake/CMakeChecks.cmake) include(cmake/Extensions.cmake) From 10a95d0de937c11a1bd0b064a8dc19b586f9d6b1 Mon Sep 17 00:00:00 2001 From: David Brooks Date: Mon, 29 Aug 2016 12:04:57 +0100 Subject: [PATCH 2/4] Debug builds can't have `Py_LIMITED_API` set. --- cmake/extensions/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/extensions/CMakeLists.txt b/cmake/extensions/CMakeLists.txt index c98dfba78..8ffebfcc5 100644 --- a/cmake/extensions/CMakeLists.txt +++ b/cmake/extensions/CMakeLists.txt @@ -114,10 +114,13 @@ add_python_extension(_testmultiphase REQUIRES IS_PY3 SOURCES _testmultiphase.c) # debug tool to trace memory blocks allocated by Python add_python_extension(_tracemalloc BUILTIN REQUIRES IS_PY3 SOURCES hashtable.c _tracemalloc.c) add_python_extension(_weakref BUILTIN REQUIRES IS_PY3 SOURCES _weakref.c) -math(EXPR _limited_api_version "${PY_VERSION_MAJOR} * 100 + ${PY_VERSION_MINOR}") +if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + math(EXPR _limited_api_version "${PY_VERSION_MAJOR} * 100 + ${PY_VERSION_MINOR}") + set(_limited_definition "Py_LIMITED_API=0x${_limited_api_version}0000") +endif() add_python_extension(xxlimited REQUIRES IS_PY3 BUILD_TESTING SOURCES xxlimited.c - DEFINITIONS Py_LIMITED_API=0x${_limited_api_version}0000 + DEFINITIONS ${_limited_definition} NO_INSTALL ) add_python_extension(xxsubtype BUILTIN REQUIRES IS_PY3 SOURCES xxsubtype.c) From 4ef38571e73d8377616c8335c3860cf3c2cb4474 Mon Sep 17 00:00:00 2001 From: David Brooks Date: Mon, 29 Aug 2016 12:06:47 +0100 Subject: [PATCH 3/4] Only add `_d` postfix to Windows debug builds when using Microsoft's compilers. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eccfca7b..fad600642 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if(CMAKE_CROSSCOMPILING) cmake_minimum_required(VERSION 3.3) # Version introducing CROSSCOMPILING_EMULATOR endif() -if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") +if(MSVC AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") set(CMAKE_DEBUG_POSTFIX "_d") endif() From 2ae50278018446c8115ad73c43ea1282124bf63f Mon Sep 17 00:00:00 2001 From: David Brooks Date: Fri, 16 Sep 2016 21:00:51 +0100 Subject: [PATCH 4/4] Remove redundant test on CMAKE_BUILD_TYPE. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fad600642..720d36881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if(CMAKE_CROSSCOMPILING) cmake_minimum_required(VERSION 3.3) # Version introducing CROSSCOMPILING_EMULATOR endif() -if(MSVC AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") +if(MSVC) set(CMAKE_DEBUG_POSTFIX "_d") endif()