[geos-commits] r3375 - in trunk: . capi include src tools

svn_geos at osgeo.org svn_geos at osgeo.org
Sun May 22 19:34:04 EDT 2011


Author: mloskot
Date: 2011-05-22 16:34:04 -0700 (Sun, 22 May 2011)
New Revision: 3375

Modified:
   trunk/CMakeLists.txt
   trunk/capi/CMakeLists.txt
   trunk/include/CMakeLists.txt
   trunk/src/CMakeLists.txt
   trunk/tools/CMakeLists.txt
Log:
Added OS X framework build option to CMake configuration (Ticket #385)

Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt	2011-05-20 08:02:17 UTC (rev 3374)
+++ trunk/CMakeLists.txt	2011-05-22 23:34:04 UTC (rev 3375)
@@ -68,6 +68,13 @@
     "Set to OFF|ON (default) to control IEEE754 conformance and remove extra precision" ON)
 endif()
 
+if(APPLE)
+  option(GEOS_ENABLE_MACOSX_FRAMEWORK
+    "Set to OFF|ON (default) to build GEOS as a Mac OS X framework" ON)
+  option(GEOS_ENABLE_MACOSX_FRAMEWORK_UNIXCOMPAT
+    "Set to ON|OFF (default) to add Unix compatibility to the Mac OS X framework" OFF)
+endif()
+
 #################################################################################
 # Setup C/C++ compiler options
 #################################################################################

Modified: trunk/capi/CMakeLists.txt
===================================================================
--- trunk/capi/CMakeLists.txt	2011-05-20 08:02:17 UTC (rev 3374)
+++ trunk/capi/CMakeLists.txt	2011-05-22 23:34:04 UTC (rev 3375)
@@ -22,30 +22,41 @@
 
 file(GLOB geos_capi_HEADERS ${CMAKE_BINARY_DIR}/capi/*.h) # fix source_group issue
 
-add_library(geos_c SHARED ${geos_c_SOURCES} ${geos_capi_HEADERS})
+if(NOT APPLE AND NOT GEOS_ENABLE_MACOSX_FRAMEWORK) 
+  # if building OS X framework, CAPI built into C++ library 
+  add_library(geos_c SHARED ${geos_c_SOURCES}) 
 
-target_link_libraries(geos_c geos-static)
+  target_link_libraries(geos_c geos-static)
 
-# TODO: Enable SOVERSION property
-set_target_properties(geos_c
-  PROPERTIES
-  VERSION ${CAPI_VERSION}
-  CLEAN_DIRECT_OUTPUT 1)
+  # TODO: Enable SOVERSION property
+  set_target_properties(geos_c
+    PROPERTIES
+    VERSION ${CAPI_VERSION}
+    CLEAN_DIRECT_OUTPUT 1)
+endif()
 
 #################################################################################
 # Installation
 #################################################################################
 
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos_c.h
-  DESTINATION include)
+if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos_c.h
+    DESTINATION GEOS.framework/Versions/${VERSION_MAJOR}/Headers)
+  install(CODE "execute_process(COMMAND sed -E -i \"\" \"s,# *include[[:space:]]+<geos/,#include <GEOS/,g\" \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/GEOS.framework/Versions/${VERSION_MAJOR}/Headers/geos_c.h\")")
+else()
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos_c.h
+    DESTINATION include)
+endif()
 
-install(TARGETS geos_c
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib)
+if(NOT APPLE AND NOT GEOS_ENABLE_MACOSX_FRAMEWORK) 
+  install(TARGETS geos_c
+    RUNTIME DESTINATION bin
+    LIBRARY DESTINATION lib
+    ARCHIVE DESTINATION lib)
+endif()
 
 #################################################################################
 # Group source files for IDE source explorers (e.g. Visual Studio)
 #################################################################################
-
-source_group("Header Files" FILES ${geos_capi_HEADERS})
\ No newline at end of file
+
+source_group("Header Files" FILES ${geos_capi_HEADERS})

Modified: trunk/include/CMakeLists.txt
===================================================================
--- trunk/include/CMakeLists.txt	2011-05-20 08:02:17 UTC (rev 3374)
+++ trunk/include/CMakeLists.txt	2011-05-22 23:34:04 UTC (rev 3375)
@@ -12,24 +12,42 @@
 #
 #################################################################################
 
-#add_subdirectory(geos)
-
 #################################################################################
 # Install/Uninstall
 #################################################################################
 
+# There is a builtin cmake way to get headers in the right location
+# for OS X framework, but it's not practical this complex tree
+
+if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
+  set(installdest GEOS.framework/Versions/${VERSION_MAJOR}/Headers)
+else()
+  set(installdest include/geos)
+endif()
+
+
 install(FILES geos.h
-  DESTINATION include/geos)
+  DESTINATION ${installdest})
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos/platform.h
-  DESTINATION include/geos)
+  DESTINATION ${installdest})
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos/version.h
-  DESTINATION include/geos)
+  DESTINATION ${installdest})
 
 install(DIRECTORY geos/
-  DESTINATION include/geos
+  DESTINATION ${installdest}
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "*.inl"
-  PATTERN ".svn" EXCLUDE)
+  PATTERN ".svn" EXCLUDE)
+
+# Some post-processing for the framework
+# luckily GEOS uses header subdir already, just need to change case
+if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
+  install(CODE 
+    "execute_process(COMMAND find \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${installdest}\" -name *.* -print0 
+    COMMAND xargs -0 sed -E -i \"\" \"s,# *include[[:space:]]+<geos/,#include <GEOS/,g\")")
+  install(CODE 
+    "execute_process(COMMAND ln -sfh Versions/Current/Headers \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/GEOS.framework/Headers\")")
+endif()

Modified: trunk/src/CMakeLists.txt
===================================================================
--- trunk/src/CMakeLists.txt	2011-05-20 08:02:17 UTC (rev 3374)
+++ trunk/src/CMakeLists.txt	2011-05-22 23:34:04 UTC (rev 3375)
@@ -15,6 +15,46 @@
 file(GLOB_RECURSE geos_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
 file(GLOB_RECURSE geos_ALL_HEADERS ${CMAKE_SOURCE_DIR}/include/*.h) # fix source_group issue
 
+if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
+  # OS X frameworks don't have static libs
+  # also 1 binary, so include CAPI here
+  # and, make name all caps
+
+  set(geos_c_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_c.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_ts_c.cpp)
+
+  add_library(GEOS SHARED ${geos_SOURCES} ${geos_c_SOURCES})
+  set_target_properties(GEOS
+    PROPERTIES
+    CLEAN_DIRECT_OUTPUT 1
+    FRAMEWORK 1
+    FRAMEWORK_VERSION ${VERSION_MAJOR}
+    MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
+    MACOSX_FRAMEWORK_BUNDLE_VERSION "GEOS ${VERSION}"
+    MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION}
+    MACOSX_FRAMEWORK_IDENTIFIER org.osgeo.geos)
+
+  install(TARGETS GEOS FRAMEWORK DESTINATION .)
+
+  if(GEOS_ENABLE_MACOSX_FRAMEWORK_UNIXCOMPAT)
+    # Unix compatibility option, provides typical bin/lib/include folder
+    # structure for framework-challenged projects
+
+    set(GEOS_FWDIR "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/GEOS.framework")
+    set(GEOS_FWDIR_VER "${GEOS_FWDIR}/Versions/${VERSION_MAJOR}")
+    install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/bin\")")
+    install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/include\")")
+    install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/lib\")")
+    install(CODE "execute_process(COMMAND ln -sfh ../../Headers \"${GEOS_FWDIR_VER}/unix/include/geos\")")
+    install(CODE "execute_process(COMMAND ln -sf ../../Headers/geos_c.h \"${GEOS_FWDIR_VER}/unix/include/geos_c.h\")")
+    install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos.dylib\")")
+    install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos_c.dylib\")")
+    install(CODE "execute_process(COMMAND ln -sfh Versions/Current/unix \"${GEOS_FWDIR}/unix\")")
+  endif()
+
+else()
+
 add_library(geos SHARED ${geos_SOURCES} ${geos_ALL_HEADERS})
 add_library(geos-static STATIC ${geos_SOURCES} ${geos_ALL_HEADERS})
 
@@ -31,14 +71,18 @@
   PREFIX "lib"
   CLEAN_DIRECT_OUTPUT 1)
 
+endif()
+
 #################################################################################
 # Installation
 #################################################################################
 
-install(TARGETS geos geos-static
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib)
+if(NOT APPLE AND NOT GEOS_ENABLE_MACOSX_FRAMEWORK)
+  install(TARGETS geos geos-static
+    RUNTIME DESTINATION bin
+    LIBRARY DESTINATION lib
+    ARCHIVE DESTINATION lib)
+endif()
 
 #################################################################################
 # Group source files for IDE source explorers (e.g. Visual Studio)

Modified: trunk/tools/CMakeLists.txt
===================================================================
--- trunk/tools/CMakeLists.txt	2011-05-20 08:02:17 UTC (rev 3374)
+++ trunk/tools/CMakeLists.txt	2011-05-22 23:34:04 UTC (rev 3375)
@@ -14,17 +14,28 @@
 
 if(UNIX)
 
-  # Autoconf compatibility variables to use the same script source.
-  set(prefix ${CMAKE_INSTALL_PREFIX})
-  set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
-  set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
+  if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK AND GEOS_ENABLE_MACOSX_FRAMEWORK_UNIXCOMPAT)
+    set(installdest GEOS.framework/Versions/${VERSION_MAJOR}/unix/bin)
+    set(prefix ${CMAKE_INSTALL_PREFIX}/GEOS.framework/Versions/${VERSION_MAJOR}/unix)
+  elseif(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
+    # just a dummy so installdest not set
+    # want geos-config only for Mac unix build or framework+unixcompat
+  else()
+    set(installdest bin)
+    set(prefix ${CMAKE_INSTALL_PREFIX})
+  endif()
 
-  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/geos-config.in
-    ${CMAKE_CURRENT_BINARY_DIR}/geos-config @ONLY)
+  set(exec_prefix ${prefix}/bin)
+  set(libdir ${prefix}/lib)
+  
+  if(installdest)
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/geos-config.in
+                   ${CMAKE_CURRENT_BINARY_DIR}/geos-config @ONLY)
+  
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos-config
+      DESTINATION ${installdest}
+      PERMISSIONS
+      OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+endif()
 
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geos-config
-    DESTINATION bin/
-    PERMISSIONS
-    OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
 endif()



More information about the geos-commits mailing list