Mercurial > hg > orthanc-python
changeset 26:b0d1308280d8
Added the PYTHON_WINDOWS_USE_RELEASE_LIBS CMake option
to allow usage of debug or release Python builds when building
in debug mode under Windows with Visual Studio.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 06 Apr 2020 20:39:49 +0200 |
parents | 3b59f5dd7e72 |
children | ec7860ac40e9 |
files | CMakeLists.txt CodeAnalysis/sdk.h.mustache Sources/Autogenerated/sdk.h Sources/OnChangeCallback.h Sources/OnStoredInstanceCallback.h Sources/PythonHeaderWrapper.h Sources/PythonLock.h Sources/RestCallbacks.h |
diffstat | 8 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Apr 03 12:18:45 2020 +0200 +++ b/CMakeLists.txt Mon Apr 06 20:39:49 2020 +0200 @@ -6,6 +6,7 @@ set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") +set(PYTHON_WINDOWS_USE_RELEASE_LIBS ON CACHE BOOL "Use the release Python libraries when building with Microsoft Visual Studio, even when compiling in _DEBUG mode (set it to OFF if you require linking to a Python debug build)") set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost") set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)") @@ -28,6 +29,9 @@ if (MSVC) set(Prefix "") set(Suffix ".lib") + if(PYTHON_WINDOWS_USE_RELEASE_LIBS) + add_definitions(-DORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS=1) + endif() else() list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) set(Suffix ".a") @@ -77,6 +81,7 @@ include_directories( + #${CMAKE_SOURCE_DIR}/Sources ${ORTHANC_ROOT}/Sdk-1.5.7 )
--- a/CodeAnalysis/sdk.h.mustache Fri Apr 03 12:18:45 2020 +0200 +++ b/CodeAnalysis/sdk.h.mustache Mon Apr 06 20:39:49 2020 +0200 @@ -19,7 +19,7 @@ #pragma once -#include <Python.h> +#include "../PythonHeaderWrapper.h" void RegisterOrthancSdk(PyObject* module); PyMethodDef* GetOrthancSdkFunctions();
--- a/Sources/Autogenerated/sdk.h Fri Apr 03 12:18:45 2020 +0200 +++ b/Sources/Autogenerated/sdk.h Mon Apr 06 20:39:49 2020 +0200 @@ -19,7 +19,7 @@ #pragma once -#include <Python.h> +#include "../PythonHeaderWrapper.h" void RegisterOrthancSdk(PyObject* module); PyMethodDef* GetOrthancSdkFunctions();
--- a/Sources/OnChangeCallback.h Fri Apr 03 12:18:45 2020 +0200 +++ b/Sources/OnChangeCallback.h Mon Apr 06 20:39:49 2020 +0200 @@ -19,7 +19,7 @@ #pragma once -#include <Python.h> +#include "PythonHeaderWrapper.h" void FinalizeOnChangeCallback();
--- a/Sources/OnStoredInstanceCallback.h Fri Apr 03 12:18:45 2020 +0200 +++ b/Sources/OnStoredInstanceCallback.h Mon Apr 06 20:39:49 2020 +0200 @@ -19,7 +19,7 @@ #pragma once -#include <Python.h> +#include "PythonHeaderWrapper.h" PyObject* RegisterOnStoredInstanceCallback(PyObject* module, PyObject* args);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sources/PythonHeaderWrapper.h Mon Apr 06 20:39:49 2020 +0200 @@ -0,0 +1,26 @@ +/** + * Python plugin for Orthanc + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + +#if defined(_MSC_VER) && (ORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS == 1) && defined(_DEBUG) +# undef _DEBUG +# include <Python.h> +# define _DEBUG +#else +# include <Python.h> +#endif +
--- a/Sources/PythonLock.h Fri Apr 03 12:18:45 2020 +0200 +++ b/Sources/PythonLock.h Mon Apr 06 20:39:49 2020 +0200 @@ -22,7 +22,7 @@ #include <orthanc/OrthancCPlugin.h> #define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */ -#include <Python.h> +#include "PythonHeaderWrapper.h" #include <boost/noncopyable.hpp> #include <string>