root/OpenSceneGraph/trunk/CMakeModules/OsgMacroUtils.cmake @ 11817

Revision 11817, 18.7 kB (checked in by robert, 4 years ago)

Copied libutil and libtess implementations in form Mesa 7.9/src/glu into the src/osg/glu,
changed extensions from .c to .cpp and got compiling as C files as part of the osg core library.

Updated and cleaned up the rest of the OSG to use the new internal GLU.

  • Property svn:eol-style set to native
RevLine 
[6402]1
[6375]2#######################################################################################################
[6402]3#  macro for linking libraries that come from Findxxxx commands, so there is a variable that contains the
4#  full path of the library name. in order to differentiate release and debug, this macro get the
5#  NAME of the variables, so the macro gets as arguments the target name and the following list of parameters
6#  is intended as a list of variable names each one containing  the path of the libraries to link to
[11197]7#  The existance of a variable name with _DEBUG appended is tested and, in case it' s value is used
[6402]8#  for linking to when in debug mode
9#  the content of this library for linking when in debugging
10#######################################################################################################
11
12
13MACRO(LINK_WITH_VARIABLES TRGTNAME)
[6561]14    FOREACH(varname ${ARGN})
15        IF(${varname}_DEBUG)
16            TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${${varname}}" debug "${${varname}_DEBUG}")
17        ELSE(${varname}_DEBUG)
18            TARGET_LINK_LIBRARIES(${TRGTNAME} "${${varname}}" )
19        ENDIF(${varname}_DEBUG)
20    ENDFOREACH(varname)
[6402]21ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
22
23MACRO(LINK_INTERNAL TRGTNAME)
[8358]24    IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
25        TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN})
26    ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
27        FOREACH(LINKLIB ${ARGN})
28            IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
29                #when using versioned names, the .dll name differ from .lib name, there is a problem with that:
30                #CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX  for computing linkage info to use into projects,
31                # so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
32                #to library targets used
[11197]33                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_RELEASE_POSTFIX}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
[8358]34                ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
35            ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
[11197]36                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}${CMAKE_RELEASE_POSTFIX}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
[8358]37            ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
38        ENDFOREACH(LINKLIB)
39    ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
[6402]40ENDMACRO(LINK_INTERNAL TRGTNAME)
41
42MACRO(LINK_EXTERNAL TRGTNAME)
[6561]43    FOREACH(LINKLIB ${ARGN})
44        TARGET_LINK_LIBRARIES(${TRGTNAME} "${LINKLIB}" )
45    ENDFOREACH(LINKLIB)
[6402]46ENDMACRO(LINK_EXTERNAL TRGTNAME)
47
48
49#######################################################################################################
[6592]50#  macro for common setup of core libraries: it links OPENGL_LIBRARIES in undifferentiated mode
[6402]51#######################################################################################################
52
53MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
[11817]54    #SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
55    SET(ALL_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
[10703]56    IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
57        SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
58    ENDIF()
59
60    LINK_EXTERNAL(${CORELIB_NAME} ${ALL_GL_LIBRARIES})
[6709]61    LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY)
62    IF(OPENSCENEGRAPH_SONAMES)
63      SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OPENSCENEGRAPH_VERSION} SOVERSION ${OPENSCENEGRAPH_SOVERSION})
64    ENDIF(OPENSCENEGRAPH_SONAMES)
[6402]65ENDMACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
66
67
68#######################################################################################################
[6375]69#  macro for common setup of plugins, examples and applications it expect some variables to be set:
70#  either within the local CMakeLists or higher in hierarchy
71#  TARGET_NAME is the name of the folder and of the actually .exe or .so or .dll
72#  TARGET_TARGETNAME  is the name of the target , this get buit out of a prefix, if present and TARGET_TARGETNAME
73#  TARGET_SRC  are the sources of the target
74#  TARGET_H are the eventual headers of the target
75#  TARGET_LIBRARIES are the libraries to link to that are internal to the project and have d suffix for debug
76#  TARGET_EXTERNAL_LIBRARIES are external libraries and are not differentiated with d suffix
77#  TARGET_LABEL is the label IDE should show up for targets
78##########################################################################################################
[6309]79
[6375]80MACRO(SETUP_LINK_LIBRARIES)
[6402]81    ######################################################################
82    #
83    # This set up the libraries to link to, it assumes there are two variable: one common for a group of examples or plagins
84    # kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES
85    # they are combined in a single list checked for unicity
86    # the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug
87    #
88    # a second variable TARGET_EXTERNAL_LIBRARIES hold the list of  libraries not differentiated between debug and optimized
89    ##################################################################################
90    SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES})
91
92    FOREACH(LINKLIB ${TARGET_ADDED_LIBRARIES})
[6561]93      SET(TO_INSERT TRUE)
94      FOREACH (value ${TARGET_COMMON_LIBRARIES})
95            IF (${value} STREQUAL ${LINKLIB})
96                  SET(TO_INSERT FALSE)
97            ENDIF (${value} STREQUAL ${LINKLIB})
[6402]98        ENDFOREACH (value ${TARGET_COMMON_LIBRARIES})
[6561]99      IF(TO_INSERT)
100          LIST(APPEND TARGET_LIBRARIES ${LINKLIB})
101      ENDIF(TO_INSERT)
[6402]102    ENDFOREACH(LINKLIB)
103
[11817]104    #SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
105    SET(ALL_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
[10703]106    IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
107        SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
108    ENDIF()
109
[7322]110#    FOREACH(LINKLIB ${TARGET_LIBRARIES})
111#            TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
112#    ENDFOREACH(LINKLIB)
[7865]113        LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES})
[11162]114#    FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES})
115#            TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB})
116#    ENDFOREACH(LINKLIB)
117        TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${TARGET_EXTERNAL_LIBRARIES})
[6561]118        IF(TARGET_LIBRARIES_VARS)
119            LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS})
120        ENDIF(TARGET_LIBRARIES_VARS)
[7322]121    IF(MSVC  AND OSG_MSVC_VERSIONED_DLL)
[7865]122        #when using full path name to specify linkage, it seems that already linked libs must be specified
[10703]123            LINK_EXTERNAL(${TARGET_TARGETNAME} ${ALL_GL_LIBRARIES})
[7322]124    ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
125
[6375]126ENDMACRO(SETUP_LINK_LIBRARIES)
[6309]127
[6375]128############################################################################################
129# this is the common set of command for all the plugins
130#
[6309]131
[6379]132MACRO(SETUP_PLUGIN PLUGIN_NAME)
133
[8358]134    SET(TARGET_NAME ${PLUGIN_NAME} )
[6379]135
[6561]136    #MESSAGE("in -->SETUP_PLUGIN<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
[6375]137
[6561]138    ## we have set up the target label and targetname by taking into account global prfix (osgdb_)
[6375]139
[6561]140    IF(NOT TARGET_TARGETNAME)
141            SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
142    ENDIF(NOT TARGET_TARGETNAME)
143    IF(NOT TARGET_LABEL)
144            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
145    ENDIF(NOT TARGET_LABEL)
[9339]146
147    ## plugins gets put in libopenscenegraph by default
148    IF(${ARGC} GREATER 1)
149      SET(PACKAGE_COMPONENT libopenscenegraph-${ARGV1})
150    ELSE(${ARGC} GREATER 1)
151      SET(PACKAGE_COMPONENT libopenscenegraph)
152    ENDIF(${ARGC} GREATER 1)
[9808]153
154    # Add the VisualStudio versioning info   
155    SET(TARGET_SRC ${TARGET_SRC} ${OPENSCENEGRAPH_VERSIONINFO_RC})
[6561]156   
[8358]157    # here we use the command to generate the library   
[6741]158
159    IF   (DYNAMIC_OPENSCENEGRAPH)
160        ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H})
161    ELSE (DYNAMIC_OPENSCENEGRAPH)
162        ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
163    ENDIF(DYNAMIC_OPENSCENEGRAPH)
[6561]164   
[7322]165    #not sure if needed, but for plugins only Msvc need the d suffix
[6561]166    IF(NOT MSVC)
[8375]167        IF(NOT UNIX)
168            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
169        ENDIF(NOT UNIX)
[7322]170    ELSE(NOT MSVC)
[8358]171        IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
172            IF(NOT MSVC_IDE)
173                SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")                     
174            ELSE(NOT MSVC_IDE)
[11354]175                IF(MSVC_VERSION LESS 1600)
176                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${OSG_PLUGINS}/")
177                ENDIF()
[8358]178            ENDIF(NOT MSVC_IDE)
179        ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
180            IF(OSG_MSVC_VERSIONED_DLL)
181
[7865]182                #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
183                #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
184                #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
185                #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
186                #changing bin to something else breaks this hack
187                #the dll are placed in bin/${OSG_PLUGINS}
[8358]188
[7865]189                IF(NOT MSVC_IDE)
190                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")                     
191                ELSE(NOT MSVC_IDE)
192                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
193                ENDIF(NOT MSVC_IDE)
194
[8358]195            ELSE(OSG_MSVC_VERSIONED_DLL)
196
197                #in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
198                #here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
199
200                SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
201            ENDIF(OSG_MSVC_VERSIONED_DLL)
202        ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
[6561]203    ENDIF(NOT MSVC)
[8358]204
[6561]205    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
[6709]206 
[6561]207    SETUP_LINK_LIBRARIES()
[6309]208
[6705]209#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
[6561]210    IF(WIN32)
[8358]211        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]212            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
213            ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
214            LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]215    ELSE(WIN32)
[8358]216        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]217            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
218            ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
219            LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]220    ENDIF(WIN32)
[6375]221ENDMACRO(SETUP_PLUGIN)
[6309]222
223
[6375]224#################################################################################################################
225# this is the macro for example and application setup
226###########################################################
[6309]227
[6483]228MACRO(SETUP_EXE IS_COMMANDLINE_APP)
[6561]229    #MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
230    IF(NOT TARGET_TARGETNAME)
231            SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
232    ENDIF(NOT TARGET_TARGETNAME)
233    IF(NOT TARGET_LABEL)
234            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
235    ENDIF(NOT TARGET_LABEL)
[6309]236
[6561]237    IF(${IS_COMMANDLINE_APP})
[6750]238   
[6561]239        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H})
[6750]240       
[6561]241    ELSE(${IS_COMMANDLINE_APP})
[6750]242   
[6562]243        IF(APPLE)
244            # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
245            # Short Version is the "marketing version". It is the version
246            # the user sees in an information panel.
247            SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
248            # Bundle version is the version the OS looks at.
249            SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
250            SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.openscenegraph.${TARGET_TARGETNAME}" )
251            SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" )
252            # SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns")
253            # SET(MACOSX_BUNDLE_COPYRIGHT "")
254            # SET(MACOSX_BUNDLE_INFO_STRING "Info string, localized?")
255        ENDIF(APPLE)
[6750]256
[6837]257        IF(WIN32)
258            IF (REQUIRE_WINMAIN_FLAG)
259                SET(PLATFORM_SPECIFIC_CONTROL WIN32)
260            ENDIF(REQUIRE_WINMAIN_FLAG)
261        ENDIF(WIN32)
262
263        IF(APPLE)
264            IF(OSG_BUILD_APPLICATION_BUNDLES)
265                SET(PLATFORM_SPECIFIC_CONTROL MACOSX_BUNDLE)
266            ENDIF(OSG_BUILD_APPLICATION_BUNDLES)
267        ENDIF(APPLE)
268
269        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
[6562]270       
[6561]271    ENDIF(${IS_COMMANDLINE_APP})
[8358]272
[6561]273    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
274    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
[11197]275    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}${CMAKE_DEBUG_POSTFIX}")
276    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELEASE_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELEASE_POSTFIX}")
277    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELWITHDEBINFO_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELWITHDEBINFO_POSTFIX}")
278    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES MINSIZEREL_OUTPUT_NAME "${TARGET_NAME}${CMAKE_MINSIZEREL_POSTFIX}")
[8358]279
[7865]280    IF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[11354]281        IF(MSVC_VERSION LESS 1600)
[7865]282            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")   
[11354]283        ENDIF()
[7865]284    ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[8358]285
[6561]286    SETUP_LINK_LIBRARIES()   
[6309]287
[6375]288ENDMACRO(SETUP_EXE)
[6309]289
[6483]290# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]291MACRO(SETUP_APPLICATION APPLICATION_NAME)
[6329]292
[6378]293        SET(TARGET_NAME ${APPLICATION_NAME} )
294
[6561]295        IF(${ARGC} GREATER 1)
296            SET(IS_COMMANDLINE_APP ${ARGV1})
297        ELSE(${ARGC} GREATER 1)
298            SET(IS_COMMANDLINE_APP 0)
299        ENDIF(${ARGC} GREATER 1)
300           
[6483]301        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]302       
[8487]303        IF(APPLE)
304            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
305        ELSE(APPLE)
[9339]306            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin COMPONENT openscenegraph  )
[8487]307        ENDIF(APPLE)
[6309]308
[6375]309ENDMACRO(SETUP_APPLICATION)
[6309]310
[6484]311MACRO(SETUP_COMMANDLINE_APPLICATION APPLICATION_NAME)
[6309]312
[6489]313    SETUP_APPLICATION(${APPLICATION_NAME} 1)
[6484]314
315ENDMACRO(SETUP_COMMANDLINE_APPLICATION)
316
[6483]317# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]318MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
[6309]319
[6378]320        SET(TARGET_NAME ${EXAMPLE_NAME} )
321
[6561]322        IF(${ARGC} GREATER 1)
323            SET(IS_COMMANDLINE_APP ${ARGV1})
324        ELSE(${ARGC} GREATER 1)
325            SET(IS_COMMANDLINE_APP 0)
326        ENDIF(${ARGC} GREATER 1)
327           
[6483]328        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]329       
[8487]330        IF(APPLE)
331            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )           
332        ELSE(APPLE)
[9342]333            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples )
[8487]334        ENDIF(APPLE)
[6309]335
[6375]336ENDMACRO(SETUP_EXAMPLE)
[6309]337
[6375]338
[6484]339MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
340
[6489]341    SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
[6484]342
343ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
[7322]344
[7425]345# Takes two optional arguments -- osg prefix and osg version
[7322]346MACRO(HANDLE_MSVC_DLL)
[8358]347        #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
348        #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
349        #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
350        #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
351        #changing bin to something else breaks this hack
352        #the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
[7425]353
354        # LIB_PREFIX: use "osg" by default, else whatever we've been given.
355        IF(${ARGC} GREATER 0)
356                SET(LIB_PREFIX ${ARGV0})
357        ELSE(${ARGC} GREATER 0)
358                SET(LIB_PREFIX osg)
359        ENDIF(${ARGC} GREATER 0)
360
361        # LIB_SOVERSION: use OSG's soversion by default, else whatever we've been given
362        IF(${ARGC} GREATER 1)
363                SET(LIB_SOVERSION ${ARGV1})
364        ELSE(${ARGC} GREATER 1)
365                SET(LIB_SOVERSION ${OPENSCENEGRAPH_SOVERSION})
366        ENDIF(${ARGC} GREATER 1)
[7865]367   
368        IF(NOT MSVC_IDE)
369            SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-")
[9057]370            IF (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
371                SET(NEW_LIB_NAME "${OUTPUT_BINDIR}/${LIB_PREFIX}${LIB_SOVERSION}-${LIB_NAME}")
372                ADD_CUSTOM_COMMAND(
373                    TARGET ${LIB_NAME}
374                    POST_BUILD
375                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.lib"  "${OUTPUT_LIBDIR}/${LIB_NAME}.lib"
376                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.exp"  "${OUTPUT_LIBDIR}/${LIB_NAME}.exp"
377                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.lib"
378                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.exp"
379                    )
380            ENDIF (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
381        ELSE(NOT MSVC_IDE)
[11354]382            IF(MSVC_VERSION LESS 1600)
383                SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
384            ENDIF()
[9057]385        ENDIF(NOT MSVC_IDE)
[7425]386
[7865]387#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
388#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
[7322]389ENDMACRO(HANDLE_MSVC_DLL)
Note: See TracBrowser for help on using the browser.