My apologies...I forgot the attachment(s).  Just for clarification -
these changes are specifically for building/using osgEphemeris on
Windows.

Thanks,
Brandon


-----Original Message-----
From: Hamm, Brandon 
Sent: Sunday, December 06, 2009 3:03 AM
To: [email protected]
Subject: Updates for building osgEphemeris on Windows using CMake

Robert,

I've made the following additions/modifications to support a clean build
of osgEphemeris using your CMake port:

* Added osg* debug libraries to FindOSG.cmake
* Added osgText link library depenendency to osgEphemeris 
* Added mission declspec export declaration to
osgEphemeris::EphemerisUpdateCallbackRegistry

Thanks,

Brandon Hamm

set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)

IF(WIN32)
    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
ELSE()
    IF(APPLE)
        CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
    ELSE()
        CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
    ENDIF()
ENDIF()

if(COMMAND cmake_policy)
    # Works around warnings libraries linked against that don't
    # have absolute paths (e.g. -lpthreads)
    cmake_policy(SET CMP0003 NEW)

    # Works around warnings about escaped quotes in ADD_DEFINITIONS
    # statements.
    cmake_policy(SET CMP0005 NEW)

    # cmake-2.6.1 introduces policy cmp0008 decide how to treat full path 
libraries that do not appear to be valid library file names
    # quote from cvslog "Such libraries worked by accident in the VS IDE and 
Xcode generators in CMake 2.4 and below."
    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND 
${CMAKE_PATCH_VERSION} GREATER 0)
        cmake_policy(SET CMP0008 OLD)
    endif()
endif()

PROJECT(OSGEPHEMERIS)

SET(OSGEPHEMERIS_MAJOR_VERSION 0)
SET(OSGEPHEMERIS_MINOR_VERSION 9)
SET(OSGEPHEMERIS_PATCH_VERSION 0)
SET(OSGEPHEMERIS_SOVERSION 0)

# set to 0 when not a release candidate, non zero means that any generated 
# svn tags will be treated as release candidates of given number
SET(OSGEPHEMERIS_RELEASE_CANDIDATE 0)

# We have some custom .cmake scripts not in the official distribution.
# Maybe this can be used override existing behavior if needed?
SET(CMAKE_MODULE_PATH 
"${OSGEPHEMERIS_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")

FIND_PACKAGE(OSG)

SET(OSGEPHEMERIS_VERSION 
${OSGEPHEMERIS_MAJOR_VERSION}.${OSGEPHEMERIS_MINOR_VERSION}.${OSGEPHEMERIS_PATCH_VERSION})

SET(OSGEPHEMERIS_PLUGINS osgPlugins-${OPENSCENEGRAPH_VERSION})

SET(OSGEPHEMERIS_PLUGIN_PREFIX "") 

IF (CYGWIN)
    SET(OSGEPHEMERIS_PLUGIN_PREFIX "cygwin_")
ENDIF()

IF(MINGW)
    SET(OSGEPHEMERIS_PLUGIN_PREFIX "mingw_")
ENDIF()

# We want to build SONAMES shared librariess
SET(OSGEPHEMERIS_SONAMES TRUE)



# Okay, here's the problem: On some platforms, linking against OpenThreads
# is not enough and explicit linking to the underlying thread library
# is also required (e.g. FreeBSD). But OpenThreads may be built with different
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
# thread library is because some platforms support multiple backends (e.g.
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
# because the libraries may be incompatible.
# So the current solution is to attempt best guess linking and exempt certain
# cases. With IRIX, we're going to hope explicit linking to the underlying
# library is not necessary. We currently don't case for pthreads on Windows
# which might be an issue on things like Cygwin. This may need to be fixed.
FIND_PACKAGE(Threads)
IF(CMAKE_SYSTEM MATCHES IRIX)
    # Erase CMAKE_THREAD_LIBS_INIT and hope it works
    SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
ENDIF()

OPTION(EPH_MAINTAINER "Enable osgEphemeris maintainer build methods, such as 
making svn branches, tags, updating ChangeLog." OFF)
IF (EPH_MAINTAINER)

    SET(OSGEPHEMERIS_SVN "trunk")
    #SET(OSGEPHEMERIS_SVN "branches")
    SET(OSGEPHEMERIS_BRANCH 
OSGEPHEMERIS-${OSGEPHEMERIS_MAJOR_VERSION}.${OSGEPHEMERIS_MINOR_VERSION})

    #
    # Provide target for tagging a release
    #
    SET(SVNCOMMAND svn)
    SET(SVNTRUNKDIR     http://www.openscenegraph.org/svn/osgEphemeris/trunk)
    SET(SVNTAGDIR       http://www.openscenegraph.org/svn/osgEphemeris/tags)
    SET(SVNBRANCHDIR    http://www.openscenegraph.org/svn/osgEphemeris/branch)

    IF   (OSGEPHEMERIS_SVN STREQUAL "trunk")
        SET(SVNSOURCEDIR ${SVNTRUNKDIR})
    ELSE ()
        SET(SVNSOURCEDIR ${SVNBRANCH_DIR}/${OSGEPHEMERIS_BRANCH})
    ENDIF()


    IF   (OSGEPHEMERIS_RELEASE_CANDIDATE EQUAL 0)
        SET(RELEASE_NAME osgEphemeris-${OSGEPHEMERIS_VERSION})
    ELSE ()
        SET(RELEASE_NAME 
osgEphemeris-${OSGEPHEMERIS_VERSION}-rc${OSGEPHEMERIS_RELEASE_CANDIDATE})
    ENDIF()


    ADD_CUSTOM_TARGET(tag-test
        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} 
${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
    )

    ADD_CUSTOM_TARGET(tag-run
        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} 
-m "Release ${RELEASE_NAME}"
    )

    ADD_CUSTOM_TARGET(branch-test
        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} 
${SVNBRANCHDIR}/${OSGEPHEMERIS_BRANCH} -m "Branch ${OSGEPHEMERIS_BRANCH}"
    )

    ADD_CUSTOM_TARGET(branch-run
        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} 
${SVNBRANCHDIR}/${OSGEPHEMERIS_BRANCH} -m "Branch ${OSGEPHEMERIS_BRANCH}"
    )

    #
    # Provide target for generating ChangeLog
    #
    SET(GENERATELOGS svn2cl)

    ADD_CUSTOM_TARGET(ChangeLog
        COMMAND ${SVNCOMMAND} update
        COMMAND ${GENERATELOGS}
    )
    
ENDIF()



# Find OpenGL
FIND_PACKAGE(OpenGL)

IF(UNIX)
    # Not sure what this will do on Cygwin and Msys
    # Also, remember OS X X11 is a user installed option so it may not exist.
    FIND_PACKAGE(X11)
    # Some Unicies need explicit linkage to the Math library or the build fails.
    FIND_LIBRARY(MATH_LIBRARY m)
ENDIF()

# Make the headers visible to everything
INCLUDE_DIRECTORIES(
    ${OSGEPHEMERIS_SOURCE_DIR}/include
    ${OPENGL_INCLUDE_DIR}
)

# Common global definitions
#ADD_DEFINITIONS(-D)
# Platform specific definitions

########################################################################################################
##### these were settings located in SetupCommon.cmake used in Luigi builds.... 
find out what are useful
########################################################################################################
#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
#luigi#SET(CMAKE_SKIP_RPATH TRUE)
#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
#luigi#IF(UNIX)
#luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
#luigi#    IF (contains)
#luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} 
"${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  
CMAKE_CXX_COMPILER to g++")
#luigi#        SET(CMAKE_CXX_COMPILER "g++")
#luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
#luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
#luigi#    ENDIF ()
#luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
#luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
#luigi#ENDIF()
########################################################################################################

# Common to all platforms:
SET(OSG_DIR "" CACHE PATH "set to base osg install path")

SET(CMAKE_DEBUG_POSTFIX  "d")

################################################################################
# Create bin and lib directories if required

IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib)
ENDIF()


################################################################################
# Installation stuff


IF(UNIX AND NOT WIN32 AND NOT APPLE)
  IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
      SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
      MARK_AS_ADVANCED(LIB_POSTFIX)
  ENDIF()
ENDIF()
IF(NOT DEFINED LIB_POSTFIX)
    SET(LIB_POSTFIX "")
ENDIF()

# Here we apparantly do some funky stuff with making the bin/ and lib/
# folders which is probably needed to work around a very old CMake bug?

#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
MAKE_DIRECTORY(${OUTPUT_BINDIR})
IF(MSVC AND NOT MSVC_IDE)
    MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
ENDIF(MSVC AND NOT MSVC_IDE)

#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
IF(NOT MSVC)
    MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
ENDIF(NOT MSVC)

# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
# we work around the DLL placement by use of the PREFIX target property hack
#
# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY

IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 5)
    SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
    SET(LIBRARY_OUTPUT_PATH    ${OUTPUT_LIBDIR})
ELSE()
  # If CMake >= 2.6.0
  SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
  SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
  IF(WIN32)
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
  ELSE(WIN32)
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
  ENDIF(WIN32)
ENDIF()

#SET(INSTALL_BINDIR osgEphemeris/bin)
#SET(INSTALL_INCDIR osgEphemeris/include)
#SET(INSTALL_LIBDIR osgEphemeris/lib)
#SET(INSTALL_DOCDIR osgEphemeris/doc)

################################################################################
# User Options


# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
# may set these values without needing to manipulate the environment.
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add 
additional search paths here. Use ; to separate multiple paths.")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add 
additional search paths here. Use ; to separate multiple paths.")
# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
# A formal feature request has been submited to CMake, Bug #4947.
# It is intended for those users who have common prefixes for their INCLUDE
# and LIBRARY locations. So if users have headers in /usr/local/include
# and libraries in /usr/local/lib, the common prefix is /usr/local.
# It should also cover the case where headers and libraries are
# in the same directory.
# Our proposal expects that FIND_* commands will automatically search for
# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
# Obviously, since CMake does not currently support this, we must write
# our Find*.cmake modules to explicitly support this. Otherwise, this variable
# will have no impact.
# This is unofficial so this may be removed or changed at anytime.
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may 
add additional search paths here. Use ; to separate multiple paths.")

# Dynamic vs Static Linking
OPTION(DYNAMIC_OSGEPHEMERIS "Set to ON to build OSGEPHEMERIS for dynamic 
linking.  Use OFF for static." ON)
IF   (DYNAMIC_OSGEPHEMERIS)
    SET(OSGEPHEMERIS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
ELSE ()
    SET(OSGEPHEMERIS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
ENDIF()

INCLUDE(OsgEphemerisMacroUtils)

# VPB Core
ADD_SUBDIRECTORY(src)

# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
IF(APPLE)
    # These are just defaults/recommendations, but how we want to build
    # out of the box. But the user needs to be able to change these options.
    # So we must only set the values the first time CMake is run, or we
    # will overwrite any changes the user sets.
    # FORCE is used because the options are not reflected in the UI otherwise.
    # Seems like a good place to add version specific compiler flags too.
    IF(NOT EPH_CONFIG_HAS_BEEN_RUN_BEFORE)
        # This is really fragile, but CMake doesn't provide the OS system
        # version information we need. (Darwin versions can be changed
        # independently of OS X versions.)
        # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
        IF(EXISTS /Developer/SDKs/10.5.sdk)
            SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING 
"Build architectures for OSX" FORCE)
            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 
-ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the 
compiler during all build types." FORCE)
        ELSE()
            IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build 
architectures for OSX" FORCE)
                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} 
-mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE 
STRING "Flags used by the compiler during all build types." FORCE)
            ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
                # No Universal Binary support
                # Should break down further to set the -mmacosx-version-min,
                # but the SDK detection is too unreliable here.
            ENDIF()
        ENDIF()
    ENDIF()

    OPTION(EPH_BUILD_APPLICATION_BUNDLES "Enable the building of applications 
and examples as OSX Bundles" OFF)

ENDIF()


# This needs to be run very last so other parts of the scripts can take
# advantage of this.
IF(NOT EPH_CONFIG_HAS_BEEN_RUN_BEFORE)
    SET(EPH_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether 
this is the first time running CMake or if CMake has been configured before")
ENDIF()


#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

Attachment: FindOSG.cmake
Description: FindOSG.cmake

Attachment: EphemerisUpdateCallback
Description: EphemerisUpdateCallback

IF   (DYNAMIC_OSGEPHEMERIS)
    ADD_DEFINITIONS(-DOSGEPHEMERIS_LIBRARY)
ELSE (DYNAMIC_OSGEPHEMERIS)
    ADD_DEFINITIONS(-DOSGEPHEMERIS_LIBRARY_STATIC)
ENDIF(DYNAMIC_OSGEPHEMERIS)
SET(LIB_NAME osgEphemeris)

SET(HEADER_PATH ${OSGEPHEMERIS_SOURCE_DIR}/include/${LIB_NAME})
SET(LIB_PUBLIC_HEADERS
    ${HEADER_PATH}/CelestialBodies
    ${HEADER_PATH}/DateTime
    ${HEADER_PATH}/EphemerisData
    ${HEADER_PATH}/EphemerisEngine
    ${HEADER_PATH}/EphemerisModel
    ${HEADER_PATH}/EphemerisUpdateCallback
    ${HEADER_PATH}/Export
    ${HEADER_PATH}/GroundPlane
    ${HEADER_PATH}/MoonModel
    ${HEADER_PATH}/Planets
    ${HEADER_PATH}/SkyDome
    ${HEADER_PATH}/Sphere
    ${HEADER_PATH}/StarField
)

ADD_LIBRARY(${LIB_NAME}
    ${OSGEPHEMERIS_USER_DEFINED_DYNAMIC_OR_STATIC}
    ${LIB_PUBLIC_HEADERS}
    CelestialBodies.cpp
    DateTime.cpp
    EphemerisData.cpp
    EphemerisEngine.cpp
    EphemerisModel.cpp
    EphemerisUpdateCallback.cpp
    GroundPlane.cpp
    moon_images.cpp
    MoonModel.cpp
    Planets.cpp
    SkyDome.cpp
    Sphere.cpp
    StarField.cpp
    sun_image.cpp
)

INCLUDE_DIRECTORIES(${OSG_INCLUDE_DIRS} )

IF (WIN32)
  LINK_EXTERNAL(${LIB_NAME}  ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} 
${GDAL_LIBRARY} Ws2_32.lib)
ELSE(WIN32)
  LINK_EXTERNAL(${LIB_NAME}  ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} 
${GDAL_LIBRARY})
ENDIF(WIN32)

LINK_WITH_VARIABLES(${LIB_NAME} OSG_LIBRARY OSGUTIL_LIBRARY OSGDB_LIBRARY 
OSGFX_LIBRARY OSGTEXT_LIBRARY OPENTHREADS_LIBRARY)
LINK_CORELIB_DEFAULT(${LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} )

INCLUDE(ModuleInstall OPTIONAL)
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to