From 712b6cb2d948528a4937f785e9f8d8dc0d52b85f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 May 2008 12:49:47 +0000 Subject: [PATCH] From Mathieu Marache, first post: "I had the problem that debug and release version of the plugins had the same name under linux. These minors modification to Registry and the CMake support files enable to have both Release and Debug version of the plugins to coexist and be found by there respective runtimes." follow up post: "I've gone ahead and added a preprocessor directive with the editable CMAKE_DEBUG_POSTFIX. I modified Registry.cpp to take this new preprocessor directive called OSG_DEBUG_POSTFIX while looking for libraries in Debug mode for the windows (msvc) and the linux platforms. MinGW, cygwin and Apple are still left out this proposal." Notes from Robert Osfield, completed the work in change d entries to use OSG_DEBUG_POSTFIX --- CMakeLists.txt | 7 +++++++ CMakeModules/OsgMacroUtils.cmake | 4 +++- src/osgDB/Registry.cpp | 20 ++++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acecb01a3..9e916be1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,13 @@ ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") # Installation stuff SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows") +ADD_DEFINITIONS("-DOSG_DEBUG_POSTFIX='\"${CMAKE_DEBUG_POSTFIX}\"'") +IF(UNIX AND NOT WIN32 AND NOT APPLE) + IF(CMAKE_BUILD_TYPE STREQUAL "Debug") + ADD_DEFINITIONS("-D_DEBUG") + ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") +ENDIF(UNIX AND NOT WIN32 AND NOT APPLE) + IF(UNIX AND NOT WIN32 AND NOT APPLE) IF(CMAKE_SIZEOF_VOID_P MATCHES "8") diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index fdf1febc0..4abeb0973 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -145,7 +145,9 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME) #not sure if needed, but for plugins only Msvc need the d suffix IF(NOT MSVC) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "") + IF(NOT UNIX) + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "") + ENDIF(NOT UNIX) ELSE(NOT MSVC) IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) IF(NOT MSVC_IDE) diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 26a3c354c..d83933e65 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -39,6 +39,9 @@ using std::tolower; #endif +#ifndef OSG_DEBUG_POSTFIX +#define OSG_DEBUG_POSTFIX "d" +#endif using namespace osg; using namespace osgDB; @@ -603,7 +606,7 @@ std::string Registry::createLibraryNameForExtension(const std::string& ext) return prepend+"mingw_"+"osgdb_"+lowercase_ext+".dll"; #elif defined(WIN32) #ifdef _DEBUG - return prepend+"osgdb_"+lowercase_ext+"d.dll"; + return prepend+"osgdb_"+lowercase_ext+ OSG_DEBUG_POSTFIX +".dll"; #else return prepend+"osgdb_"+lowercase_ext+".dll"; #endif @@ -613,7 +616,12 @@ std::string Registry::createLibraryNameForExtension(const std::string& ext) // why don't we use PLUGIN_EXT from the makefiles here? return prepend+"osgdb_"+lowercase_ext+".sl"; #else - return prepend+"osgdb_"+lowercase_ext+".so"; + #ifdef _DEBUG +#pragma message(OSG_DEBUG_POSTFIX) + return prepend+"osgdb_"+lowercase_ext+ OSG_DEBUG_POSTFIX + ".so"; + #else + return prepend+"osgdb_"+lowercase_ext+".so"; + #endif #endif } @@ -626,7 +634,7 @@ std::string Registry::createLibraryNameForNodeKit(const std::string& name) return "lib"+name+".dll"; #elif defined(WIN32) #ifdef _DEBUG - return name+"d.dll"; + return name+OSG_DEBUG_POSTFIX +".dll"; #else return name+".dll"; #endif @@ -636,7 +644,11 @@ std::string Registry::createLibraryNameForNodeKit(const std::string& name) // why don't we use PLUGIN_EXT from the makefiles here? return "lib"+name+".sl"; #else - return "lib"+name+".so"; + #ifdef _DEBUG + return "lib"+name+OSG_DEBUG_POSTFIX +".so"; + #else + return "lib"+name+".so"; + #endif #endif }