← 返回首页
re: Build debug libraries when CMAKE_BUILD_TYPE is set to Debug by jcfr · Pull Request #241 · python-cmake-buildsystem/python-cmake-buildsystem · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

re: Build debug libraries when CMAKE_BUILD_TYPE is set to Debug#241

Open
jcfr wants to merge 4 commits into
python-cmake-buildsystem:masterfrom
jcfr:windebug
Open

re: Build debug libraries when CMAKE_BUILD_TYPE is set to Debug#241
jcfr wants to merge 4 commits into
python-cmake-buildsystem:masterfrom
jcfr:windebug

Conversation

jcfr commented Dec 13, 2018

Copy link
Copy Markdown
Contributor

Supersede PR #151

Comment thread CMakeLists.txt
cmake_minimum_required(VERSION 3.3) # Version introducing CROSSCOMPILING_EMULATOR
endif()

if(MSVC)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Should be WIN32, that way building in Debug on windows using Ninja will work as expected.

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")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Should probably be something like :

set(_limited_definition) 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()

That said, the approach should still be tweaked to handle the case of Visual Studio where CMAKE_CONFIGURATION_TYPES is defined

jcfr Dec 13, 2018
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

@dbrnz I had an other look at this, and if Py_LIMITED_API must not be defined when doing Debug build, relying on a newer version of CMake supporting generator expression would be the way to go.

That way, we will be able to do something like this:

math(EXPR _limited_api_version "${PY_VERSION_MAJOR} * 100 + ${PY_VERSION_MINOR}") target_compile_definition(xxlimited PRIVATE $<$<NOT:$<CONFIG:Debug>>:${_limited_definition}>)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.