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

Revision 11197, 18.4 kB (checked in by robert, 5 years ago)

From David Fries,"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."

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