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

Revision 11904, 22.9 kB (checked in by robert, 3 years ago)

From Sukender, "As discussed in osg-users, I found output directories with CMake >= 2.8.1 are wrong under MSVC (As Chuck said, it's to be related to CMake, and not MSVC).

But I also found rev. 11354 (from Wang Rui) added a change in OsgMacroUtils? which adresses a similar issue: Wang told the "../../bin" prefix wasn't working. However I think the fix isn't correct because it checks the MSVC version instead of the CMake version. Here is my fix, against latest trunk (root CMakeLists.txt, and CMakeModules/OsgMacroUtils.cmake).

Tests I made:

| Unix Makefiles | MSVC 9 | MSVC 10 x64


CMake 2.4 | | OK | N/A
CMake 2.6.4 | | OK | N/A
CMake 2.8.0 | | OK | broken support?
CMake 2.8.2 | | OK | OK
"

  • 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
[11904]12# VALID_BUILDER_VERSION: used for replacing CMAKE_VERSION (available in v2.6.3 RC9) and VERSION_GREATER/VERSION_LESS (available in 2.6.2 RC4).
13# This can be replaced by "IF(${CMAKE_VERSION} VERSION_LESS "x.y.z")" from 2.6.4.
14SET(VALID_BUILDER_VERSION OFF)
15MACRO(BUILDER_VERSION_GREATER MAJOR_VER MINOR_VER PATCH_VER)
16    SET(VALID_BUILDER_VERSION OFF)
17    IF(CMAKE_MAJOR_VERSION GREATER ${MAJOR_VER})
18        SET(VALID_BUILDER_VERSION ON)
19    ELSEIF(CMAKE_MAJOR_VERSION EQUAL ${MAJOR_VER})
20        IF(CMAKE_MINOR_VERSION GREATER ${MINOR_VER})
21            SET(VALID_BUILDER_VERSION ON)
22        ELSEIF(CMAKE_MINOR_VERSION EQUAL ${MINOR_VER})
23            IF(CMAKE_PATCH_VERSION GREATER ${PATCH_VER})
24                SET(VALID_BUILDER_VERSION ON)
25            ENDIF(CMAKE_PATCH_VERSION GREATER ${PATCH_VER})
26        ENDIF()
27    ENDIF()
28ENDMACRO(BUILDER_VERSION_GREATER MAJOR_VER MINOR_VER PATCH_VER)
[6402]29
[11904]30# CMAKE24: if CMake version is <2.6.0.
31SET(CMAKE24 OFF)
32IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} LESS 5)
33    SET(CMAKE24 ON)
34ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} LESS 5)
35
36# CMAKE_VERSION_TEST: Define whether "IF(${CMAKE_VERSION} VERSION_LESS "x.y.z")" can be used or not.
37BUILDER_VERSION_GREATER(2 6 3)
38SET(CMAKE_VERSION_TEST ${VALID_BUILDER_VERSION})        # >= 2.6.4
39
40SET(VALID_BUILDER_VERSION OFF)
41
42
[6402]43MACRO(LINK_WITH_VARIABLES TRGTNAME)
[6561]44    FOREACH(varname ${ARGN})
45        IF(${varname}_DEBUG)
46            TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${${varname}}" debug "${${varname}_DEBUG}")
47        ELSE(${varname}_DEBUG)
48            TARGET_LINK_LIBRARIES(${TRGTNAME} "${${varname}}" )
49        ENDIF(${varname}_DEBUG)
50    ENDFOREACH(varname)
[6402]51ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
52
53MACRO(LINK_INTERNAL TRGTNAME)
[11904]54    IF(NOT CMAKE24)
[8358]55        TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN})
[11904]56    ELSE(NOT CMAKE24)
[8358]57        FOREACH(LINKLIB ${ARGN})
58            IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
59                #when using versioned names, the .dll name differ from .lib name, there is a problem with that:
60                #CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX  for computing linkage info to use into projects,
61                # so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
62                #to library targets used
[11197]63                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_RELEASE_POSTFIX}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
[8358]64                ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
65            ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
[11197]66                TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}${CMAKE_RELEASE_POSTFIX}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
[8358]67            ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
68        ENDFOREACH(LINKLIB)
[11904]69    ENDIF(NOT CMAKE24)
[6402]70ENDMACRO(LINK_INTERNAL TRGTNAME)
71
72MACRO(LINK_EXTERNAL TRGTNAME)
[6561]73    FOREACH(LINKLIB ${ARGN})
74        TARGET_LINK_LIBRARIES(${TRGTNAME} "${LINKLIB}" )
75    ENDFOREACH(LINKLIB)
[6402]76ENDMACRO(LINK_EXTERNAL TRGTNAME)
77
78
79#######################################################################################################
[6592]80#  macro for common setup of core libraries: it links OPENGL_LIBRARIES in undifferentiated mode
[6402]81#######################################################################################################
82
83MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
[11817]84    #SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
85    SET(ALL_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
[10703]86    IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
87        SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
88    ENDIF()
89
90    LINK_EXTERNAL(${CORELIB_NAME} ${ALL_GL_LIBRARIES})
[6709]91    LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY)
92    IF(OPENSCENEGRAPH_SONAMES)
93      SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OPENSCENEGRAPH_VERSION} SOVERSION ${OPENSCENEGRAPH_SOVERSION})
94    ENDIF(OPENSCENEGRAPH_SONAMES)
[6402]95ENDMACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
96
97
98#######################################################################################################
[6375]99#  macro for common setup of plugins, examples and applications it expect some variables to be set:
100#  either within the local CMakeLists or higher in hierarchy
101#  TARGET_NAME is the name of the folder and of the actually .exe or .so or .dll
102#  TARGET_TARGETNAME  is the name of the target , this get buit out of a prefix, if present and TARGET_TARGETNAME
103#  TARGET_SRC  are the sources of the target
104#  TARGET_H are the eventual headers of the target
105#  TARGET_LIBRARIES are the libraries to link to that are internal to the project and have d suffix for debug
106#  TARGET_EXTERNAL_LIBRARIES are external libraries and are not differentiated with d suffix
107#  TARGET_LABEL is the label IDE should show up for targets
108##########################################################################################################
[6309]109
[6375]110MACRO(SETUP_LINK_LIBRARIES)
[6402]111    ######################################################################
112    #
113    # This set up the libraries to link to, it assumes there are two variable: one common for a group of examples or plagins
114    # kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES
115    # they are combined in a single list checked for unicity
116    # the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug
117    #
118    # a second variable TARGET_EXTERNAL_LIBRARIES hold the list of  libraries not differentiated between debug and optimized
119    ##################################################################################
120    SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES})
121
122    FOREACH(LINKLIB ${TARGET_ADDED_LIBRARIES})
[6561]123      SET(TO_INSERT TRUE)
124      FOREACH (value ${TARGET_COMMON_LIBRARIES})
125            IF (${value} STREQUAL ${LINKLIB})
126                  SET(TO_INSERT FALSE)
127            ENDIF (${value} STREQUAL ${LINKLIB})
[6402]128        ENDFOREACH (value ${TARGET_COMMON_LIBRARIES})
[6561]129      IF(TO_INSERT)
130          LIST(APPEND TARGET_LIBRARIES ${LINKLIB})
131      ENDIF(TO_INSERT)
[6402]132    ENDFOREACH(LINKLIB)
133
[11817]134    #SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
135    SET(ALL_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
[10703]136    IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
137        SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
138    ENDIF()
139
[7322]140#    FOREACH(LINKLIB ${TARGET_LIBRARIES})
141#            TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
142#    ENDFOREACH(LINKLIB)
[7865]143        LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES})
[11162]144#    FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES})
145#            TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB})
146#    ENDFOREACH(LINKLIB)
147        TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${TARGET_EXTERNAL_LIBRARIES})
[6561]148        IF(TARGET_LIBRARIES_VARS)
149            LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS})
150        ENDIF(TARGET_LIBRARIES_VARS)
[7322]151    IF(MSVC  AND OSG_MSVC_VERSIONED_DLL)
[7865]152        #when using full path name to specify linkage, it seems that already linked libs must be specified
[10703]153            LINK_EXTERNAL(${TARGET_TARGETNAME} ${ALL_GL_LIBRARIES})
[7322]154    ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
155
[6375]156ENDMACRO(SETUP_LINK_LIBRARIES)
[6309]157
[6375]158############################################################################################
159# this is the common set of command for all the plugins
160#
[6309]161
[11904]162# Sets the output directory property for CMake >= 2.6.0, giving an output path RELATIVE to default one
163MACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR)
164    BUILDER_VERSION_GREATER(2 8 0)
165    IF(NOT VALID_BUILDER_VERSION)
166        # If CMake <= 2.8.0 (Testing CMAKE_VERSION is possible in >= 2.6.4)
167        IF(MSVC_IDE)
168            # Using the "prefix" hack
169            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${RELATIVE_OUTDIR}/")
170        ELSE(MSVC_IDE)
171            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${RELATIVE_OUTDIR}/")
172        ENDIF(MSVC_IDE)
173    ELSE(NOT VALID_BUILDER_VERSION)
174        # Using the output directory properties
175
176        # Global properties (All generators but VS & Xcode)
177        FILE(TO_CMAKE_PATH TMPVAR "CMAKE_ARCHIVE_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}")
178        SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${TMPVAR}")
179        FILE(TO_CMAKE_PATH TMPVAR "CMAKE_RUNTIME_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}")
180        SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TMPVAR}")
181        FILE(TO_CMAKE_PATH TMPVAR "CMAKE_LIBRARY_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}")
182        SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TMPVAR}")
183
184        # Per-configuration property (VS, Xcode)
185        FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES})        # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
186            STRING(TOUPPER "${CONF}" CONF)                # Go uppercase (DEBUG, RELEASE...)
187
188            # We use "FILE(TO_CMAKE_PATH", to create nice looking paths
189            FILE(TO_CMAKE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR)
190            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}")
191            FILE(TO_CMAKE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR)
192            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}")
193            FILE(TO_CMAKE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR)
194            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}")
195        ENDFOREACH(CONF ${CMAKE_CONFIGURATION_TYPES})
196    ENDIF(NOT VALID_BUILDER_VERSION)
197ENDMACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR)
198
199
[6379]200MACRO(SETUP_PLUGIN PLUGIN_NAME)
201
[8358]202    SET(TARGET_NAME ${PLUGIN_NAME} )
[6379]203
[6561]204    #MESSAGE("in -->SETUP_PLUGIN<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
[6375]205
[6561]206    ## we have set up the target label and targetname by taking into account global prfix (osgdb_)
[6375]207
[6561]208    IF(NOT TARGET_TARGETNAME)
209            SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
210    ENDIF(NOT TARGET_TARGETNAME)
211    IF(NOT TARGET_LABEL)
212            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
213    ENDIF(NOT TARGET_LABEL)
[9339]214
215    ## plugins gets put in libopenscenegraph by default
216    IF(${ARGC} GREATER 1)
217      SET(PACKAGE_COMPONENT libopenscenegraph-${ARGV1})
218    ELSE(${ARGC} GREATER 1)
219      SET(PACKAGE_COMPONENT libopenscenegraph)
220    ENDIF(${ARGC} GREATER 1)
[9808]221
222    # Add the VisualStudio versioning info   
223    SET(TARGET_SRC ${TARGET_SRC} ${OPENSCENEGRAPH_VERSIONINFO_RC})
[6561]224   
[8358]225    # here we use the command to generate the library   
[6741]226
227    IF   (DYNAMIC_OPENSCENEGRAPH)
228        ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H})
229    ELSE (DYNAMIC_OPENSCENEGRAPH)
230        ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
231    ENDIF(DYNAMIC_OPENSCENEGRAPH)
[6561]232   
[7322]233    #not sure if needed, but for plugins only Msvc need the d suffix
[6561]234    IF(NOT MSVC)
[8375]235        IF(NOT UNIX)
236            SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
237        ENDIF(NOT UNIX)
[7322]238    ELSE(NOT MSVC)
[11904]239        IF(NOT CMAKE24)
240            SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "${OSG_PLUGINS}")        # Sets the ouput to be /osgPlugin-X.X.X ; also ensures the /Debug /Release are removed
241        ELSE(NOT CMAKE24)
242
[8358]243            IF(OSG_MSVC_VERSIONED_DLL)
244
[7865]245                #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
246                #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
247                #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
248                #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
249                #changing bin to something else breaks this hack
250                #the dll are placed in bin/${OSG_PLUGINS}
[8358]251
[7865]252                IF(NOT MSVC_IDE)
253                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")                     
254                ELSE(NOT MSVC_IDE)
255                    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
256                ENDIF(NOT MSVC_IDE)
257
[8358]258            ELSE(OSG_MSVC_VERSIONED_DLL)
259
260                #in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
261                #here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
262
263                SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
264            ENDIF(OSG_MSVC_VERSIONED_DLL)
[11904]265
266        ENDIF(NOT CMAKE24)
[6561]267    ENDIF(NOT MSVC)
[8358]268
[6561]269    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
[6709]270 
[6561]271    SETUP_LINK_LIBRARIES()
[6309]272
[6705]273#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
[6561]274    IF(WIN32)
[8358]275        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]276            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
277            ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
278            LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]279    ELSE(WIN32)
[8358]280        INSTALL(TARGETS ${TARGET_TARGETNAME}
[9339]281            RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
282            ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
283            LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
[6561]284    ENDIF(WIN32)
[6375]285ENDMACRO(SETUP_PLUGIN)
[6309]286
287
[6375]288#################################################################################################################
289# this is the macro for example and application setup
290###########################################################
[6309]291
[6483]292MACRO(SETUP_EXE IS_COMMANDLINE_APP)
[6561]293    #MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
294    IF(NOT TARGET_TARGETNAME)
295            SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
296    ENDIF(NOT TARGET_TARGETNAME)
297    IF(NOT TARGET_LABEL)
298            SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
299    ENDIF(NOT TARGET_LABEL)
[6309]300
[6561]301    IF(${IS_COMMANDLINE_APP})
[6750]302   
[6561]303        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H})
[6750]304       
[6561]305    ELSE(${IS_COMMANDLINE_APP})
[6750]306   
[6562]307        IF(APPLE)
308            # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
309            # Short Version is the "marketing version". It is the version
310            # the user sees in an information panel.
311            SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
312            # Bundle version is the version the OS looks at.
313            SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
314            SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.openscenegraph.${TARGET_TARGETNAME}" )
315            SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" )
316            # SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns")
317            # SET(MACOSX_BUNDLE_COPYRIGHT "")
318            # SET(MACOSX_BUNDLE_INFO_STRING "Info string, localized?")
319        ENDIF(APPLE)
[6750]320
[6837]321        IF(WIN32)
322            IF (REQUIRE_WINMAIN_FLAG)
323                SET(PLATFORM_SPECIFIC_CONTROL WIN32)
324            ENDIF(REQUIRE_WINMAIN_FLAG)
325        ENDIF(WIN32)
326
327        IF(APPLE)
328            IF(OSG_BUILD_APPLICATION_BUNDLES)
329                SET(PLATFORM_SPECIFIC_CONTROL MACOSX_BUNDLE)
330            ENDIF(OSG_BUILD_APPLICATION_BUNDLES)
331        ENDIF(APPLE)
332
333        ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
[6562]334       
[6561]335    ENDIF(${IS_COMMANDLINE_APP})
[8358]336
[6561]337    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
338    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
[11197]339    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}${CMAKE_DEBUG_POSTFIX}")
340    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELEASE_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELEASE_POSTFIX}")
341    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELWITHDEBINFO_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELWITHDEBINFO_POSTFIX}")
342    SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES MINSIZEREL_OUTPUT_NAME "${TARGET_NAME}${CMAKE_MINSIZEREL_POSTFIX}")
[8358]343
[7865]344    IF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[11904]345        SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "")        # Ensure the /Debug /Release are removed
[7865]346    ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
[8358]347
[6561]348    SETUP_LINK_LIBRARIES()   
[6309]349
[6375]350ENDMACRO(SETUP_EXE)
[6309]351
[6483]352# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]353MACRO(SETUP_APPLICATION APPLICATION_NAME)
[6329]354
[6378]355        SET(TARGET_NAME ${APPLICATION_NAME} )
356
[6561]357        IF(${ARGC} GREATER 1)
358            SET(IS_COMMANDLINE_APP ${ARGV1})
359        ELSE(${ARGC} GREATER 1)
360            SET(IS_COMMANDLINE_APP 0)
361        ENDIF(${ARGC} GREATER 1)
362           
[6483]363        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]364       
[8487]365        IF(APPLE)
366            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
367        ELSE(APPLE)
[9339]368            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin COMPONENT openscenegraph  )
[8487]369        ENDIF(APPLE)
[6309]370
[6375]371ENDMACRO(SETUP_APPLICATION)
[6309]372
[6484]373MACRO(SETUP_COMMANDLINE_APPLICATION APPLICATION_NAME)
[6309]374
[6489]375    SETUP_APPLICATION(${APPLICATION_NAME} 1)
[6484]376
377ENDMACRO(SETUP_COMMANDLINE_APPLICATION)
378
[6483]379# Takes optional second argument (is_commandline_app?) in ARGV1
[6378]380MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
[6309]381
[6378]382        SET(TARGET_NAME ${EXAMPLE_NAME} )
383
[6561]384        IF(${ARGC} GREATER 1)
385            SET(IS_COMMANDLINE_APP ${ARGV1})
386        ELSE(${ARGC} GREATER 1)
387            SET(IS_COMMANDLINE_APP 0)
388        ENDIF(${ARGC} GREATER 1)
389           
[6483]390        SETUP_EXE(${IS_COMMANDLINE_APP})
[6375]391       
[8487]392        IF(APPLE)
393            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )           
394        ELSE(APPLE)
[9342]395            INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples )
[8487]396        ENDIF(APPLE)
[6309]397
[6375]398ENDMACRO(SETUP_EXAMPLE)
[6309]399
[6375]400
[6484]401MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
402
[6489]403    SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
[6484]404
405ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
[7322]406
[7425]407# Takes two optional arguments -- osg prefix and osg version
[7322]408MACRO(HANDLE_MSVC_DLL)
[8358]409        #this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
410        #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
411        #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
412        #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
413        #changing bin to something else breaks this hack
414        #the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
[7425]415
416        # LIB_PREFIX: use "osg" by default, else whatever we've been given.
417        IF(${ARGC} GREATER 0)
418                SET(LIB_PREFIX ${ARGV0})
419        ELSE(${ARGC} GREATER 0)
420                SET(LIB_PREFIX osg)
421        ENDIF(${ARGC} GREATER 0)
422
423        # LIB_SOVERSION: use OSG's soversion by default, else whatever we've been given
424        IF(${ARGC} GREATER 1)
425                SET(LIB_SOVERSION ${ARGV1})
426        ELSE(${ARGC} GREATER 1)
427                SET(LIB_SOVERSION ${OPENSCENEGRAPH_SOVERSION})
428        ENDIF(${ARGC} GREATER 1)
[11904]429
430        SET_OUTPUT_DIR_PROPERTY_260(${LIB_NAME} "")        # Ensure the /Debug /Release are removed
[7865]431        IF(NOT MSVC_IDE)
[11904]432            IF (NOT CMAKE24)
433                BUILDER_VERSION_GREATER(2 8 0)
434                IF(NOT VALID_BUILDER_VERSION)
435                    # If CMake < 2.8.1
436                    SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
437                ELSE(NOT VALID_BUILDER_VERSION)
438                    SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-")
439                ENDIF(NOT VALID_BUILDER_VERSION)
440            ELSE (NOT CMAKE24)
441                SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
[9057]442                SET(NEW_LIB_NAME "${OUTPUT_BINDIR}/${LIB_PREFIX}${LIB_SOVERSION}-${LIB_NAME}")
443                ADD_CUSTOM_COMMAND(
444                    TARGET ${LIB_NAME}
445                    POST_BUILD
446                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.lib"  "${OUTPUT_LIBDIR}/${LIB_NAME}.lib"
447                    COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.exp"  "${OUTPUT_LIBDIR}/${LIB_NAME}.exp"
448                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.lib"
449                    COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.exp"
450                    )
[11904]451            ENDIF (NOT CMAKE24)
452        ELSE(NOT MSVC_IDE)
453            IF (NOT CMAKE24)
454                BUILDER_VERSION_GREATER(2 8 0)
455                IF(NOT VALID_BUILDER_VERSION)
456                    # If CMake < 2.8.1
457                    SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
458                ELSE(NOT VALID_BUILDER_VERSION)
459                    SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-")
460                ENDIF(NOT VALID_BUILDER_VERSION)
461            ELSE (NOT CMAKE24)
[11354]462                SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
[11904]463            ENDIF (NOT CMAKE24)
[9057]464        ENDIF(NOT MSVC_IDE)
[7425]465
[7865]466#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
467#     SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
[7322]468ENDMACRO(HANDLE_MSVC_DLL)
Note: See TracBrowser for help on using the browser.