From 275811d02a44bba59d2ddf07175de27975fed8e1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 23 Jun 2008 09:57:45 +0000 Subject: [PATCH] From Eric Sokolowsky, "I have made a number of changes intended to get a few things working better on OSX. However, since I'm still pretty new at Mac development and cmake I'm not entirely certain that the changes I have made are benign on other platforms. I have tested these changes on Leopard with CMake 2.6 generating Xcode 3.0 projects, compiling on ppc and i386 for 10.5 and 10.4, and on Linux (CentOS) and everything still seems to work ok. Here are the changes I made (against OSG svn as of this afternoon): - Added osgviewerCocoa example to APPLE builds - Fixed corrupt Xcode project generation with CMake 2.6 dealing with ADD_DEFINITIONS and CMake Policy CMP0005 on Leopard - Resolved CMP0006 warning for examples and programs by setting BUNDLE DESTINATION to same as RUNTIME DESTINATION with CMake 2.6 - Fixed freetype plugin on Leopard to avoid OpenGL linking problem - Figured out how to use a custom Info.plist included in the project (see osgviewerCocoa application CMakeLists.txt)" --- CMakeLists.txt | 8 ++++++-- CMakeModules/OsgMacroUtils.cmake | 12 ++++++++++-- examples/CMakeLists.txt | 18 +++++++++++------- examples/osgviewerCocoa/ViewerCocoa.mm | 2 +- src/osgPlugins/freetype/CMakeLists.txt | 3 +++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3cba5c8f..c2894a501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ if(COMMAND cmake_policy) # Works around warnings about escaped quotes in ADD_DEFINITIONS # statements. - cmake_policy(SET CMP0005 OLD) + cmake_policy(SET CMP0005 NEW) endif(COMMAND cmake_policy) PROJECT(OpenSceneGraph) @@ -348,7 +348,11 @@ ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") # Installation stuff SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows") -ADD_DEFINITIONS("-DOSG_DEBUG_POSTFIX='\"${CMAKE_DEBUG_POSTFIX}\"'") +IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) + ADD_DEFINITIONS("-DOSG_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX} ") +ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) + ADD_DEFINITIONS("-DOSG_DEBUG_POSTFIX='\"${CMAKE_DEBUG_POSTFIX}\"'") +ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) IF(UNIX AND NOT WIN32 AND NOT APPLE) IF(CMAKE_BUILD_TYPE STREQUAL "Debug") ADD_DEFINITIONS("-D_DEBUG") diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 4abeb0973..51ae33eb5 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -274,7 +274,11 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME) SETUP_EXE(${IS_COMMANDLINE_APP}) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ) + IF(APPLE) + INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin) + ELSE(APPLE) + INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ) + ENDIF(APPLE) ENDMACRO(SETUP_APPLICATION) @@ -297,7 +301,11 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME) SETUP_EXE(${IS_COMMANDLINE_APP}) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin ) + IF(APPLE) + INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin ) + ELSE(APPLE) + INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin ) + ENDIF(APPLE) ENDMACRO(SETUP_EXAMPLE) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bffbd96f3..38cd6befb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,13 +5,13 @@ SET(TARGET_DEFAULT_PREFIX "example_") SET(TARGET_DEFAULT_LABEL_PREFIX "Examples") SET(TARGET_COMMON_LIBRARIES - OpenThreads - osg - osgDB - osgUtil - osgGA - osgViewer - osgText + OpenThreads + osg + osgDB + osgUtil + osgGA + osgViewer + osgText ) IF(DYNAMIC_OPENSCENEGRAPH) @@ -145,6 +145,10 @@ IF(DYNAMIC_OPENSCENEGRAPH) ENDIF(WIN32) + IF (APPLE) + ADD_SUBDIRECTORY(osgviewerCocoa) + ENDIF(APPLE) + #ADD_SUBDIRECTORY(osgcegui) #to add subject to find socket#ADD_SUBDIRECTORY(osgcluster) diff --git a/examples/osgviewerCocoa/ViewerCocoa.mm b/examples/osgviewerCocoa/ViewerCocoa.mm index 872559ec4..65a116843 100644 --- a/examples/osgviewerCocoa/ViewerCocoa.mm +++ b/examples/osgviewerCocoa/ViewerCocoa.mm @@ -368,7 +368,7 @@ static void Internal_SetAlpha(NSBitmapImageRep *imageRep, unsigned char alpha_va // The NSOpenGLCPSwapInterval seems to be vsync. If 1, buffers are swapped with vertical refresh. // If 0, flushBuffer will execute as soon as possible. - long swap_interval = 1 ; + const GLint swap_interval = 1 ; [[self openGLContext] setValues:&swap_interval forParameter:NSOpenGLCPSwapInterval]; diff --git a/src/osgPlugins/freetype/CMakeLists.txt b/src/osgPlugins/freetype/CMakeLists.txt index c4f105508..446a79b40 100644 --- a/src/osgPlugins/freetype/CMakeLists.txt +++ b/src/osgPlugins/freetype/CMakeLists.txt @@ -6,6 +6,9 @@ ENDIF(WIN32) INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS} ) +IF(APPLE) + SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") +ENDIF(APPLE) SET(TARGET_SRC FreeTypeFont.cpp FreeTypeFont3D.cpp FreeTypeLibrary.cpp ReaderWriterFreeType.cpp ) SET(TARGET_H FreeTypeFont.h FreeTypeFont3D.h FreeTypeLibrary.h )