From 127ec49d7a38bab685dceeee31a1ece01f93a42b 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 f997e4aa1..07e71261e 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 ad9fe66747240aa1382077d7944a0c6266ff142e 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 24d4b1fde..7fd44a882 100644 --- a/cmake/extensions/CMakeLists.txt +++ b/cmake/extensions/CMakeLists.txt @@ -122,10 +122,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 defd5f4013fd4f16e3edc10e6dd6095b4b268484 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 07e71261e..8ab7bb0d1 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 8cc39fea57f6ac1765b919a226d81d57c6c892bc 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 8ab7bb0d1..a92f7b95d 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()