Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upre: Build debug libraries when CMAKE_BUILD_TYPE is set to Debug #241
Conversation
| @@ -33,6 +33,10 @@ if(CMAKE_CROSSCOMPILING) | |||
| cmake_minimum_required(VERSION 3.3) # Version introducing CROSSCOMPILING_EMULATOR | |||
| endif() | |||
|
|
|||
| if(MSVC) | |||
jcfr
Dec 13, 2018
Author
Contributor
Should be WIN32, that way building in Debug on windows using Ninja will work as expected.
Should be WIN32, that way building in Debug on windows using Ninja will work as expected.
| @@ -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") | |||
jcfr
Dec 13, 2018
Author
Contributor
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
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
•
Author
Contributor
@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}>)
@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}>)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Supersede PR #151