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

Revision 11354, 18.6 kB (checked in by robert, 4 years ago)

From Wang Rui, "The OSG book I'm working on will focus on helping beginners build
latest OSG source code with Visual Studio 2010 express, without
setting too many options and without facing unexpected errors. But at
present, the compilation process will fail because the INSTALL project
'cannot find' generated DLLs while copying files. I have looked into
the build directory and found that the places of generated file
folders were just different from previous VS versions. In this case,
the old hack in OsgMacroUtils?.cmake may become invalid:

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,

...
ELSE(NOT MSVC_IDE)

SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX

"../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")

ENDIF(NOT MSVC_IDE)

ENDMACRO(HANDLE_MSVC_DLL)

Here the prefix "../../bin" may need to be fixed. I just modified it to:

IF(MSVC_VERSION LESS 1600)

SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX

"../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
ENDIF()

It should keep compatible with old MSVC versions. There are similar
fixes in the SETUP_PLUGIN and SETUP_EXE macros. I haven't tested them
on more platforms.
"

  • 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)
[11354]173                IF(MSVC_VERSION LESS 1600)
174                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${OSG_PLUGINS}/")
175                ENDIF()
[8358]176            ENDIF(NOT MSVC_IDE)
177        ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
178            IF(OSG_MSVC_VERSIONED_DLL)
179
[7865]180                #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
181                #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
182                #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
183                #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
184                #changing bin to something else breaks this hack
185                #the dll are placed in bin/${OSG_PLUGINS}
[8358]186
[7865]187                IF(NOT MSVC_IDE)
188                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")                     
189                ELSE(NOT MSVC_IDE)
190                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
191                ENDIF(NOT MSVC_IDE)
192
[8358]193            ELSE(OSG_MSVC_VERSIONED_DLL)
194
195                #in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
196                #here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
197
198                SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
199            ENDIF(OSG_MSVC_VERSIONED_DLL)
200        ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
[6561]201    ENDIF(NOT MSVC)
[8358]202
[6561]203    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
[6709]204 
[6561]205    SETUP_LINK_LIBRARIES()
[6309]206
[6705]207#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
[6561]208    IF(WIN32)
[8358]209        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]210            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
211            ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
212            LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]213    ELSE(WIN32)
[8358]214        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]215            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
216            ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
217            LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]218    ENDIF(WIN32)
[6375]219ENDMACRO(SETUP_PLUGIN)
[6309]220
221
[6375]222#################################################################################################################
223# this is the macro for example and application setup
224###########################################################
[6309]225
[6483]226MACRO(SETUP_EXE IS_COMMANDLINE_APP)
[6561]227    #MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
228    IF(NOT TARGET_TARGETNAME)
229            SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
230    ENDIF(NOT TARGET_TARGETNAME)
231    IF(NOT TARGET_LABEL)
232            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
233    ENDIF(NOT TARGET_LABEL)
[6309]234
[6561]235    IF(${IS_COMMANDLINE_APP})
[6750]236   
[6561]237        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H})
[6750]238       
[6561]239    ELSE(${IS_COMMANDLINE_APP})
[6750]240   
[6562]241        IF(APPLE)
242            # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
243            # Short Version is the "marketing version". It is the version
244            # the user sees in an information panel.
245            SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
246            # Bundle version is the version the OS looks at.
247            SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
248            SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.openscenegraph.${TARGET_TARGETNAME}" )
249            SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" )
250            # SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns")
251            # SET(MACOSX_BUNDLE_COPYRIGHT "")
252            # SET(MACOSX_BUNDLE_INFO_STRING "Info string, localized?")
253        ENDIF(APPLE)
[6750]254
[6837]255        IF(WIN32)
256            IF (REQUIRE_WINMAIN_FLAG)
257                SET(PLATFORM_SPECIFIC_CONTROL WIN32)
258            ENDIF(REQUIRE_WINMAIN_FLAG)
259        ENDIF(WIN32)
260
261        IF(APPLE)
262            IF(OSG_BUILD_APPLICATION_BUNDLES)
263                SET(PLATFORM_SPECIFIC_CONTROL MACOSX_BUNDLE)
264            ENDIF(OSG_BUILD_APPLICATION_BUNDLES)
265        ENDIF(APPLE)
266
267        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
[6562]268       
[6561]269    ENDIF(${IS_COMMANDLINE_APP})
[8358]270
[6561]271    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
272    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
[11197]273    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}${CMAKE_DEBUG_POSTFIX}")
274    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELEASE_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELEASE_POSTFIX}")
275    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELWITHDEBINFO_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELWITHDEBINFO_POSTFIX}")
276    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES MINSIZEREL_OUTPUT_NAME "${TARGET_NAME}${CMAKE_MINSIZEREL_POSTFIX}")
[8358]277
[7865]278    IF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[11354]279        IF(MSVC_VERSION LESS 1600)
[7865]280            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")   
[11354]281        ENDIF()
[7865]282    ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[8358]283
[6561]284    SETUP_LINK_LIBRARIES()   
[6309]285
[6375]286ENDMACRO(SETUP_EXE)
[6309]287
[6483]288# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]289MACRO(SETUP_APPLICATION APPLICATION_NAME)
[6329]290
[6378]291        SET(TARGET_NAME ${APPLICATION_NAME} )
292
[6561]293        IF(${ARGC} GREATER 1)
294            SET(IS_COMMANDLINE_APP ${ARGV1})
295        ELSE(${ARGC} GREATER 1)
296            SET(IS_COMMANDLINE_APP 0)
297        ENDIF(${ARGC} GREATER 1)
298           
[6483]299        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]300       
[8487]301        IF(APPLE)
302            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
303        ELSE(APPLE)
[9339]304            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin COMPONENT openscenegraph  )
[8487]305        ENDIF(APPLE)
[6309]306
[6375]307ENDMACRO(SETUP_APPLICATION)
[6309]308
[6484]309MACRO(SETUP_COMMANDLINE_APPLICATION APPLICATION_NAME)
[6309]310
[6489]311    SETUP_APPLICATION(${APPLICATION_NAME} 1)
[6484]312
313ENDMACRO(SETUP_COMMANDLINE_APPLICATION)
314
[6483]315# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]316MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
[6309]317
[6378]318        SET(TARGET_NAME ${EXAMPLE_NAME} )
319
[6561]320        IF(${ARGC} GREATER 1)
321            SET(IS_COMMANDLINE_APP ${ARGV1})
322        ELSE(${ARGC} GREATER 1)
323            SET(IS_COMMANDLINE_APP 0)
324        ENDIF(${ARGC} GREATER 1)
325           
[6483]326        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]327       
[8487]328        IF(APPLE)
329            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )           
330        ELSE(APPLE)
[9342]331            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples )
[8487]332        ENDIF(APPLE)
[6309]333
[6375]334ENDMACRO(SETUP_EXAMPLE)
[6309]335
[6375]336
[6484]337MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
338
[6489]339    SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
[6484]340
341ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
[7322]342
[7425]343# Takes two optional arguments -- osg prefix and osg version
[7322]344MACRO(HANDLE_MSVC_DLL)
[8358]345        #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
346        #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
347        #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
348        #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
349        #changing bin to something else breaks this hack
350        #the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
[7425]351
352        # LIB_PREFIX: use "osg" by default, else whatever we've been given.
353        IF(${ARGC} GREATER 0)
354                SET(LIB_PREFIX ${ARGV0})
355        ELSE(${ARGC} GREATER 0)
356                SET(LIB_PREFIX osg)
357        ENDIF(${ARGC} GREATER 0)
358
359        # LIB_SOVERSION: use OSG's soversion by default, else whatever we've been given
360        IF(${ARGC} GREATER 1)
361                SET(LIB_SOVERSION ${ARGV1})
362        ELSE(${ARGC} GREATER 1)
363                SET(LIB_SOVERSION ${OPENSCENEGRAPH_SOVERSION})
364        ENDIF(${ARGC} GREATER 1)
[7865]365   
366        IF(NOT MSVC_IDE)
367            SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-")
[9057]368            IF (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
369                SET(NEW_LIB_NAME "${OUTPUT_BINDIR}/${LIB_PREFIX}${LIB_SOVERSION}-${LIB_NAME}")
370                ADD_CUSTOM_COMMAND(
371                    TARGET ${LIB_NAME}
372                    POST_BUILD
373                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.lib"  "${OUTPUT_LIBDIR}/${LIB_NAME}.lib"
374                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.exp"  "${OUTPUT_LIBDIR}/${LIB_NAME}.exp"
375                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.lib"
376                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.exp"
377                    )
378            ENDIF (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
379        ELSE(NOT MSVC_IDE)
[11354]380            IF(MSVC_VERSION LESS 1600)
381                SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
382            ENDIF()
[9057]383        ENDIF(NOT MSVC_IDE)
[7425]384
[7865]385#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
386#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
[7322]387ENDMACRO(HANDLE_MSVC_DLL)
Note: See TracBrowser for help on using the browser.