# HG changeset patch # User Benjamin Golinvaux # Date 1586198389 -7200 # Node ID b0d1308280d8f0e1e8c8e2717f2623e2957d6149 # Parent 3b59f5dd7e72d30321c7a12122b97be6d8575b8a 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. diff -r 3b59f5dd7e72 -r b0d1308280d8 CMakeLists.txt --- 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 ) diff -r 3b59f5dd7e72 -r b0d1308280d8 CodeAnalysis/sdk.h.mustache --- 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 +#include "../PythonHeaderWrapper.h" void RegisterOrthancSdk(PyObject* module); PyMethodDef* GetOrthancSdkFunctions(); diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/Autogenerated/sdk.h --- 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 +#include "../PythonHeaderWrapper.h" void RegisterOrthancSdk(PyObject* module); PyMethodDef* GetOrthancSdkFunctions(); diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/OnChangeCallback.h --- 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 +#include "PythonHeaderWrapper.h" void FinalizeOnChangeCallback(); diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/OnStoredInstanceCallback.h --- 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 +#include "PythonHeaderWrapper.h" PyObject* RegisterOnStoredInstanceCallback(PyObject* module, PyObject* args); diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/PythonHeaderWrapper.h --- /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 . + **/ + +#if defined(_MSC_VER) && (ORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS == 1) && defined(_DEBUG) +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif + diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/PythonLock.h --- 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 #define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */ -#include +#include "PythonHeaderWrapper.h" #include #include diff -r 3b59f5dd7e72 -r b0d1308280d8 Sources/RestCallbacks.h --- a/Sources/RestCallbacks.h Fri Apr 03 12:18:45 2020 +0200 +++ b/Sources/RestCallbacks.h Mon Apr 06 20:39:49 2020 +0200 @@ -19,7 +19,7 @@ #pragma once -#include +#include "PythonHeaderWrapper.h" PyObject* RegisterRestCallback(PyObject* module, PyObject* args);