From Luigi Calori, introduction of versioning of dll's and placement of dll and plugins into bin directory during build.
This commit is contained in:
@@ -96,6 +96,34 @@ IF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
ENDIF(UNIX)
|
||||
########################################################################################################
|
||||
# the foolowing options are MSVC specific,
|
||||
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
|
||||
# fron bin folder without requiring installation step.
|
||||
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
|
||||
# it also use a hack to get rid of Debug and Release folder in MSVC projects
|
||||
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
|
||||
#
|
||||
# the second option disable incremental linking in debug build , that is enabled by default by CMake
|
||||
##########################################################################################################
|
||||
|
||||
IF(MSVC)
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
MESSAGE("Warning: disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7")
|
||||
SET(OSG_MSVC_VERSIONED_DLL OFF)
|
||||
SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
|
||||
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
OPTION(OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" OFF)
|
||||
MARK_AS_ADVANCED(OSG_MSVC_VERSIONED_DLL)
|
||||
OPTION(OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON)
|
||||
MARK_AS_ADVANCED(OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
IF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
ENDIF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
ENDIF(MSVC)
|
||||
ENDIF(WIN32)
|
||||
|
||||
########################################################################################################
|
||||
@@ -219,7 +247,9 @@ SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
|
||||
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
|
||||
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
|
||||
IF(NOT MSVC)
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
|
||||
ENDIF(NOT MSVC)
|
||||
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
|
||||
|
||||
|
||||
@@ -299,6 +329,8 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# And do we need to further subcase this for different versions of VS?
|
||||
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS "/Wall /W4")
|
||||
|
||||
|
||||
ELSE(MSVC)
|
||||
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
|
||||
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
|
||||
|
||||
@@ -21,6 +21,9 @@ SOURCE_GROUP(
|
||||
FILES ${LIB_PUBLIC_HEADERS}
|
||||
)
|
||||
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
HANDLE_MSVC_DLL()
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
INSTALL(
|
||||
TARGETS ${LIB_NAME}
|
||||
|
||||
@@ -22,7 +22,17 @@ ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
|
||||
|
||||
MACRO(LINK_INTERNAL TRGTNAME)
|
||||
FOREACH(LINKLIB ${ARGN})
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
#when using versioned names, the .dll name differ from .lib name, there is a problem with that:
|
||||
#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}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
|
||||
ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
ENDFOREACH(LINKLIB)
|
||||
ENDMACRO(LINK_INTERNAL TRGTNAME)
|
||||
|
||||
@@ -82,16 +92,21 @@ MACRO(SETUP_LINK_LIBRARIES)
|
||||
ENDIF(TO_INSERT)
|
||||
ENDFOREACH(LINKLIB)
|
||||
|
||||
FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDFOREACH(LINKLIB)
|
||||
|
||||
# FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
||||
# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
# ENDFOREACH(LINKLIB)
|
||||
LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES})
|
||||
FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB})
|
||||
ENDFOREACH(LINKLIB)
|
||||
IF(TARGET_LIBRARIES_VARS)
|
||||
LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS})
|
||||
ENDIF(TARGET_LIBRARIES_VARS)
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
#when using full path name to specify linkage, it seems that already linked libs must be specified
|
||||
LINK_EXTERNAL(${TARGET_TARGETNAME} ${OPENGL_LIBRARIES})
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
ENDMACRO(SETUP_LINK_LIBRARIES)
|
||||
|
||||
############################################################################################
|
||||
@@ -121,9 +136,28 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
|
||||
ENDIF(DYNAMIC_OPENSCENEGRAPH)
|
||||
|
||||
#not sure if needed, but for plugins only msvc need the d suffix
|
||||
#not sure if needed, but for plugins only Msvc need the d suffix
|
||||
IF(NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
|
||||
ELSE(NOT MSVC)
|
||||
IF(OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
|
||||
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
|
||||
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
|
||||
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
|
||||
#changing bin to something else breaks this hack
|
||||
#the dll are placed in bin/${OSG_PLUGINS}
|
||||
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/")
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES IMPORT_PREFIX "../")
|
||||
ELSE(OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
#in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
|
||||
#here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
|
||||
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
|
||||
ENDIF(OSG_MSVC_VERSIONED_DLL)
|
||||
ENDIF(NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
|
||||
|
||||
@@ -189,7 +223,9 @@ MACRO(SETUP_EXE 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})
|
||||
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
SETUP_LINK_LIBRARIES()
|
||||
|
||||
ENDMACRO(SETUP_EXE)
|
||||
@@ -240,3 +276,15 @@ MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
|
||||
SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
|
||||
|
||||
ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
|
||||
|
||||
MACRO(HANDLE_MSVC_DLL)
|
||||
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
|
||||
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
|
||||
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
|
||||
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
|
||||
#changing bin to something else breaks this hack
|
||||
#the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
|
||||
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
|
||||
ENDMACRO(HANDLE_MSVC_DLL)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
SUBDIRS(
|
||||
OpenThreads
|
||||
#the old construct SUBDIRS( was substituded by ADD_SUBDIRECTORY that is to be preferred according on CMake docs.
|
||||
FOREACH( mylibfolder
|
||||
OpenThreads
|
||||
osg
|
||||
osgDB
|
||||
osgUtil
|
||||
@@ -14,7 +14,8 @@ SUBDIRS(
|
||||
osgTerrain
|
||||
osgViewer
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(${mylibfolder})
|
||||
ENDFOREACH( mylibfolder )
|
||||
OPTION(BUILD_OSG_PLUGINS "Enable to build OSG Plugins" ON)
|
||||
IF (BUILD_OSG_PLUGINS)
|
||||
ADD_SUBDIRECTORY(osgPlugins)
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
PROJECT(OSG_PLUGINS_MASTER)
|
||||
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/${OSG_PLUGINS}")
|
||||
IF(NOT MSVC)
|
||||
SET(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/${OSG_PLUGINS}")
|
||||
ENDIF(NOT MSVC)
|
||||
|
||||
IF(NOT MINGW)
|
||||
SET(CMAKE_SHARED_MODULE_PREFIX "")
|
||||
|
||||
@@ -62,7 +62,7 @@ SET(TARGET_H
|
||||
|
||||
INCLUDE_DIRECTORIES(.)
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgSim )
|
||||
SET(TARGET_ADDED_LIBRARIES osgSim osgText)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_PLUGIN(txp)
|
||||
|
||||
@@ -66,6 +66,7 @@ ADD_LIBRARY(${LIB_NAME}
|
||||
LINK_INTERNAL(${LIB_NAME}
|
||||
osgText
|
||||
osgUtil
|
||||
osgDB
|
||||
osg
|
||||
OpenThreads
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user