We are needing to compile Debug, Release, and MinSizeWithDebInfo, but
currently only Debug appends "d" so the Release and MinSizeWithDebInfo
(and MinSizeRel) all produce the same filenames.  This set of changes
lets each build type have a cmake defined string appended, defaulting
to Release none, Debug d, RelWithDebInfo rd, MinSizeRel s.  But a user
still can have Release, RelWithDebInfo, and MinSizeRel to produce the
same filenames.  It does so by setting the preprocessor define
OSG_LIBRARY_POSTFIX in src/osgDB/CMakeLists.txt to one of the
previously defined cmake variables CMAKE_DEBUG_POSTFIX
CMAKE_RELEASE_POSTFIX CMAKE_RELWITHDEBINFO_POSTFIX
CMAKE_MINSIZEREL_POSTFIX.  This method cuts down on the #ifdef _DEBUG
#else preprocessor directives in Registry.cpp as the extension is
always passed in OSG_LIBRARY_POSTFIX.  That and __MINGW32__ didn't
have the _DEBUG check which looks like a bug.

-- 
David Fries <[email protected]>
http://fries.net/~david/ (PGP encryption key available)


diff --git a/CMakeLists.txt b/CMakeLists.txt
index e88e451..5039900 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -508,7 +508,9 @@ ENDIF()
 # Installation stuff
 
 SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
-ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX})
+SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on 
windows")
+SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually 
empty on windows")
+SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on 
windows")
 
 IF(UNIX AND NOT WIN32)
   SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
diff --git a/CMakeModules/FindOSG.cmake b/CMakeModules/FindOSG.cmake
index 0560645..c82b51b 100644
--- a/CMakeModules/FindOSG.cmake
+++ b/CMakeModules/FindOSG.cmake
@@ -61,7 +61,7 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
     )
     
     FIND_LIBRARY(${MYLIBRARY}
-        NAMES ${MYLIBRARYNAME}
+        NAMES "${MYLIBRARYNAME}${CMAKE_RELEASE_POSTFIX}"
         PATHS
         ${OSG_DIR}/lib/Release
         ${OSG_DIR}/lib64/Release
@@ -81,7 +81,7 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
     )
 
     FIND_LIBRARY(${MYLIBRARY}
-        NAMES ${MYLIBRARYNAME}
+        NAMES "${MYLIBRARYNAME}${CMAKE_RELEASE_POSTFIX}"
         PATHS
         ~/Library/Frameworks
         /Library/Frameworks
diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake
index 77e3795..6cb4603 100644
--- a/CMakeModules/OsgMacroUtils.cmake
+++ b/CMakeModules/OsgMacroUtils.cmake
@@ -4,7 +4,7 @@
 #  full path of the library name. in order to differentiate release and debug, 
this macro get the
 #  NAME of the variables, so the macro gets as arguments the target name and 
the following list of parameters
 #  is intended as a list of variable names each one containing  the path of 
the libraries to link to
-#  The existance of a varibale name with _DEBUG appended is tested and, in 
case it' s value is used
+#  The existance of a variable name with _DEBUG appended is tested and, in 
case it' s value is used
 #  for linking to when in debug mode 
 #  the content of this library for linking when in debugging
 
#######################################################################################################
@@ -30,10 +30,10 @@ MACRO(LINK_INTERNAL TRGTNAME)
                 #CMake 2.4.7, at least seem to use PREFIX instead of 
IMPORT_PREFIX  for computing linkage info to use into projects,
                 # so we full path name to specify linkage, this prevent 
automatic inferencing of dependencies, so we add explicit depemdencies
                 #to library targets used
-                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized 
"${OUTPUT_LIBDIR}/${LINKLIB}.lib" debug 
"${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
+                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized 
"${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_RELEASE_POSTFIX}.lib" debug 
"${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
                 ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
             ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
-                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug 
"${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
+                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized 
"${LINKLIB}${CMAKE_RELEASE_POSTFIX}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
             ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
         ENDFOREACH(LINKLIB)
     ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
@@ -266,8 +266,11 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
     ENDIF(${IS_COMMANDLINE_APP})
 
     SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL 
"${TARGET_LABEL}")
-    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX 
"${CMAKE_DEBUG_POSTFIX}")
     SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME 
${TARGET_NAME})
+    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_OUTPUT_NAME 
"${TARGET_NAME}${CMAKE_DEBUG_POSTFIX}")
+    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELEASE_OUTPUT_NAME 
"${TARGET_NAME}${CMAKE_RELEASE_POSTFIX}")
+    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES 
RELWITHDEBINFO_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELWITHDEBINFO_POSTFIX}")
+    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES 
MINSIZEREL_OUTPUT_NAME "${TARGET_NAME}${CMAKE_MINSIZEREL_POSTFIX}")
 
     IF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
             SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX 
"../")    
diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt
index d363a0c..8f304dd 100644
--- a/src/osgDB/CMakeLists.txt
+++ b/src/osgDB/CMakeLists.txt
@@ -10,6 +10,24 @@ IF   (DYNAMIC_OPENSCENEGRAPH)
         
ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS})
     ENDIF()
 
+    # Set the library extension according to what configuration is being built.
+    # If the string is empty, don't set the define.
+    IF(CMAKE_DEBUG_POSTFIX)
+        SET(CMAKE_CXX_FLAGS_DEBUG
+            "${CMAKE_CXX_FLAGS_DEBUG} 
-DOSG_LIBRARY_POSTFIX=${CMAKE_DEBUG_POSTFIX}")
+    ENDIF()
+    IF(CMAKE_RELEASE_POSTFIX)
+        SET(CMAKE_CXX_FLAGS_RELEASE
+            "${CMAKE_CXX_FLAGS_RELEASE} 
-DOSG_LIBRARY_POSTFIX=${CMAKE_RELEASE_POSTFIX}")
+    ENDIF()
+    IF(CMAKE_RELWITHDEBINFO_POSTFIX)
+        SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
+            "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} 
-DOSG_LIBRARY_POSTFIX=${CMAKE_RELWITHDEBINFO_POSTFIX}")
+    ENDIF()
+    IF(CMAKE_MINSIZEREL_POSTFIX)
+        SET(CMAKE_CXX_FLAGS_MINSIZEREL
+            "${CMAKE_CXX_FLAGS_MINSIZEREL} 
-DOSG_LIBRARY_POSTFIX=${CMAKE_MINSIZEREL_POSTFIX}")
+    ENDIF()
 ELSE ()
     ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
 ENDIF()
diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp
index c034704..5f0dcad 100644
--- a/src/osgDB/Registry.cpp
+++ b/src/osgDB/Registry.cpp
@@ -43,10 +43,10 @@
     using std::tolower;
 #endif
 
-#ifdef OSG_DEBUG_POSTFIX
-    #define OSG_DEBUG_POSTFIX_WITH_QUOTES ADDQUOTES(OSG_DEBUG_POSTFIX)
+#ifdef OSG_LIBRARY_POSTFIX
+    #define OSG_LIBRARY_POSTFIX_WITH_QUOTES ADDQUOTES(OSG_LIBRARY_POSTFIX)
 #else
-    #define OSG_DEBUG_POSTFIX_WITH_QUOTES "d"
+    #define OSG_LIBRARY_POSTFIX_WITH_QUOTES ""
 #endif
 
 using namespace osg;
@@ -608,31 +608,15 @@ std::string Registry::createLibraryNameForExtension(const 
std::string& ext)
 #endif
 
 #if defined(__CYGWIN__)
-    #ifdef _DEBUG
-        return 
prepend+"cygwin_"+"osgdb_"+lowercase_ext+OSG_DEBUG_POSTFIX_WITH_QUOTES+".dll";
-    #else
-        return prepend+"cygwin_"+"osgdb_"+lowercase_ext+".dll";
-    #endif
+    return 
prepend+"cygwin_"+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif defined(__MINGW32__)
-    return prepend+"mingw_"+"osgdb_"+lowercase_ext+".dll";
+    return 
prepend+"mingw_"+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif defined(WIN32)
-    #ifdef _DEBUG
-        return prepend+"osgdb_"+lowercase_ext+ OSG_DEBUG_POSTFIX_WITH_QUOTES 
+".dll";
-    #else
-        return prepend+"osgdb_"+lowercase_ext+".dll";
-    #endif
+    return 
prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif macintosh
-    #ifdef _DEBUG
-        return prepend+"osgdb_"+lowercase_ext+ OSG_DEBUG_POSTFIX_WITH_QUOTES;
-    #else
-        return prepend+"osgdb_"+lowercase_ext;
-    #endif
+    return prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES;
 #else
-    #ifdef _DEBUG
-         return prepend+"osgdb_"+lowercase_ext+ OSG_DEBUG_POSTFIX_WITH_QUOTES 
+ ADDQUOTES(OSG_PLUGIN_EXTENSION);
-    #else
-         return prepend+"osgdb_"+lowercase_ext+ADDQUOTES(OSG_PLUGIN_EXTENSION);
-    #endif
+    return 
prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+ADDQUOTES(OSG_PLUGIN_EXTENSION);
 #endif
 
 }
@@ -640,27 +624,15 @@ std::string Registry::createLibraryNameForExtension(const 
std::string& ext)
 std::string Registry::createLibraryNameForNodeKit(const std::string& name)
 {
 #if defined(__CYGWIN__)
-    return "cyg"+name+".dll";
+    return "cyg"+name+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif defined(__MINGW32__)
-    return "lib"+name+".dll";
+    return "lib"+name+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif defined(WIN32)
-    #ifdef _DEBUG
-        return name+OSG_DEBUG_POSTFIX_WITH_QUOTES +".dll";
-    #else
-        return name+".dll";
-    #endif
+    return name+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
 #elif macintosh
-    #ifdef _DEBUG
-        return name+OSGDEBUG_POSTFIX_WITH_QUOTES;
-    #else
-        return name;
-    #endif
+    return name+OSG_LIBRARY_POSTFIX_WITH_QUOTES;
 #else
-    #ifdef _DEBUG
-        return "lib"+name+OSG_DEBUG_POSTFIX_WITH_QUOTES + 
ADDQUOTES(OSG_PLUGIN_EXTENSION);
-    #else
-        return "lib"+name+ADDQUOTES(OSG_PLUGIN_EXTENSION);
-    #endif
+    return "lib"+name+OSG_LIBRARY_POSTFIX_WITH_QUOTES + 
ADDQUOTES(OSG_PLUGIN_EXTENSION);
 #endif
 }
 

Attachment: suffix.tar.gz
Description: Binary data

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to