From 2168eac1d4e8d0a13c81a264472be5bc485ec5e1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Apr 2007 10:29:48 +0000 Subject: [PATCH] From Eric Wing, " Here are more changes for the CMake scripts: - I removed CMAKE_INSTALL_PREFIX in FindOpenThreads as a follow up to the discussion thread. - I introduced an experimental CMAKE_PREFIX_PATH to replace it. - I added CMAKE_PREFIX_PATH, CMAKE_INCLUDE_PATH, and CMAKE_LIBRARY_PATH to the CMake GUI so users can enter values there instead of in the environment. - I added OPENSCENEGRAPH_*_VERSION variables (MAJOR, MINOR, PATCH). These should be kept up-to-date with the real version numbers. Mac bundles like to have version information so users can find out the version they are running through standard About panels and also automated system reporters for troubleshooting/bug tracking. In theory, this information could be used for library versioning. We should do the same for OpenThreads, but I forgot about it. - I added some Mac Info.plist stuff (which uses the version information). " --- CMakeLists.txt | 26 ++++++++++++++++++++ CMakeModules/FindOpenThreads.cmake | 39 ++++++++++++++++++++++++++---- CMakeModules/OsgMacroUtils.cmake | 14 +++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c692c2406..a88cedbeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ ENDIF(WIN32) PROJECT(OpenSceneGraph) +SET(OPENSCENEGRAPH_MAJOR_VERSION 1) +SET(OPENSCENEGRAPH_MINOR_VERSION 9) +SET(OPENSCENEGRAPH_PATCH_VERSION 1) + # 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 "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") @@ -221,6 +225,28 @@ SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR}) ################################################################################ # 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_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking. Use OFF for static." ON) IF (DYNAMIC_OPENSCENEGRAPH) diff --git a/CMakeModules/FindOpenThreads.cmake b/CMakeModules/FindOpenThreads.cmake index 6e0af40f5..05f07e9b8 100644 --- a/CMakeModules/FindOpenThreads.cmake +++ b/CMakeModules/FindOpenThreads.cmake @@ -37,6 +37,10 @@ # If nothing is found, then the second find will search the # standard install paths. # Explicit -DVAR=value arguments should still be able to override everything. +# Note: We have added an additional check for ${CMAKE_PREFIX_PATH}. +# This is not an official CMake variable, but one we are proposing be +# added to CMake. Be warned that this may go away or the variable name +# may change. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread $ENV{OPENTHREADS_INCLUDE_DIR} @@ -48,6 +52,13 @@ FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread NO_DEFAULT_PATH ) +IF(NOT OPENTHREADS_INCLUDE_DIR) + FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread + PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. + PATH_SUFFIXES include + ) +ENDIF(NOT OPENTHREADS_INCLUDE_DIR) + IF(NOT OPENTHREADS_INCLUDE_DIR) FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread ~/Library/Frameworks @@ -58,8 +69,8 @@ IF(NOT OPENTHREADS_INCLUDE_DIR) /opt/local/include # DarwinPorts /opt/csw/include # Blastwave /opt/include + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include - ${CMAKE_INSTALL_PREFIX}/include # hack: this should be last because it can interfere badly with other search paths in the case where you do not explicitly set this value and CMake invokes its default value which may not be what you want. ) ENDIF(NOT OPENTHREADS_INCLUDE_DIR) @@ -78,6 +89,14 @@ FIND_LIBRARY(OPENTHREADS_LIBRARY NO_DEFAULT_PATH ) +IF(NOT OPENTHREADS_LIBRARY) + FIND_LIBRARY(OPENTHREADS_LIBRARY + NAMES OpenThreads OpenThreadsWin32 + PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. + PATH_SUFFIXES lib64 lib + ) +ENDIF(NOT OPENTHREADS_LIBRARY) + IF(NOT OPENTHREADS_LIBRARY) FIND_LIBRARY(OPENTHREADS_LIBRARY NAMES OpenThreads OpenThreadsWin32 @@ -96,9 +115,8 @@ IF(NOT OPENTHREADS_LIBRARY) /opt/csw/lib /opt/lib64 /opt/lib + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib - ${CMAKE_INSTALL_PREFIX}/lib64 # hack: this should be last because it can interfere badly with other search paths in the case where you do not explicitly set this value and CMake invokes its default value which may not be what you want. - ${CMAKE_INSTALL_PREFIX}/lib # hack ) ENDIF(NOT OPENTHREADS_LIBRARY) @@ -106,6 +124,7 @@ ENDIF(NOT OPENTHREADS_LIBRARY) FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG NAMES OpenThreadsd OpenThreadsWin32d PATHS + $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR} $ENV{OPENTHREADS_LIBRARY_DIR} $ENV{OPENTHREADS_DIR}/lib64 $ENV{OPENTHREADS_DIR}/lib @@ -114,9 +133,20 @@ FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG $ENV{OSG_DIR}/lib64 $ENV{OSG_DIR}/lib $ENV{OSG_DIR} + ${CMAKE_PREFIX_PATH}/lib64 + ${CMAKE_PREFIX_PATH}/lib + ${CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) +IF(NOT OPENTHREADS_LIBRARY_DEBUG) + FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG + NAMES OpenThreadsd OpenThreadsWin32d + PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. + PATH_SUFFIXES lib64 lib + ) +ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG) + IF(NOT OPENTHREADS_LIBRARY_DEBUG) FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG NAMES OpenThreadsd OpenThreadsWin32d @@ -133,9 +163,8 @@ IF(NOT OPENTHREADS_LIBRARY_DEBUG) /opt/csw/lib /opt/lib64 /opt/lib + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib - ${CMAKE_INSTALL_PREFIX}/lib64 # hack: this should be last because it can interfere badly with other search paths in the case where you do not explicitly set this value and CMake invokes its default value which may not be what you want. - ${CMAKE_INSTALL_PREFIX}/lib # hack ) ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG) diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 704cdcdb3..b55e9cb9e 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -149,6 +149,20 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP) IF(${IS_COMMANDLINE_APP}) ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H}) ELSE(${IS_COMMANDLINE_APP}) + IF(APPLE) + # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}") + # Short Version is the "marketing version". It is the version + # the user sees in an information panel. + SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}") + # Bundle version is the version the OS looks at. + SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}") + SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.openscenegraph.${TARGET_TARGETNAME}" ) + SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" ) + # SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns") + # SET(MACOSX_BUNDLE_COPYRIGHT "") + # SET(MACOSX_BUNDLE_INFO_STRING "Info string, localized?") + ENDIF(APPLE) + ADD_EXECUTABLE(${TARGET_TARGETNAME} MACOSX_BUNDLE ${TARGET_SRC} ${TARGET_H}) ENDIF(${IS_COMMANDLINE_APP}) SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")