First off, setting up a cross-platform Ogre and using a Git repository do not have any direct relationship.
The Source Control Management (whether it's Git or not) is used to synchronize multiple computers no matter if all the team use the same OS or different OS’s.
If you want to use Source Control Management with your friend, you will need a place to host it. The most famous one if you choose Git is probably github.
However, you can also use Mercurial in conjunction of bitbucket as host.
The duo Mercurial / bitbucket is often used by Indies and students because bitbucket offers the ability to create a free 5 user account and to keep your project private, whereas the free account on github is limited to open-source project and require paid account to get it private.
Now let's talk about CMake.
I'm working on a cross-platform project (Linux, OSX, Windows) using Ogre, and here is why and how I use CMake.
CMake is useful, because it offers the ability to supplant the Makefiles with one file for all platforms. You write a nice CMakeLists.txt and it will generate the Makefile for each platform (if you gave it the correct informations indeed) with all the little variations required.
So typically, I use the exactly same files on the three platforms and Cmake generate different Makefiles using the CMakeLists.txt (I use the same source folder from the same Hard-Drive and I sat up CMake so it generates the 3 makefile versions in build/Win build/OSX build/Linux)
At that point, all I need to do is to run "make" etc. on each platform to get it compile.
So using a "Source Control Management" and "Cmake", you should be able to work on the exactly same sources and to compile it without major headaches (well except those needed to set up the Cmake file ^^)
As you need more details about CMake and OSX here is the CMakeLists.txt of my project with lots of stuff removed (should almost double in size, but I removed all redundant stuffs).
This example is neither perfect (I am still not really fluent with Cmake commands) nor does it fits your needs (remember I use GCC under the 3 platforms so it's not configured to run with Xcode! it might work through as Xcode can use GCC but I'm not 100% sure.)
cmake_minimum_required(VERSION 2.6)
#------------------------------------------------------------------------------
#-------------------------------------------------------------- Init project --
set(CMAKE_PROJECT_NAME "OgreApp")
project(CMAKE_PROJECT_NAME)
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
set(CMAKE_DEBUG_POSTFIX "_d")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dist")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OGRE_SDK "${PROJECT_SOURCE_DIR}/data/osx/SDK" ) # I placed the SDK into my project/data/osx/SDK, if you place it anywhere else, you need to change this
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#------------------------------------------------------------------------------
#---------------------------------------------------- Ogre, OIS & Boost Libs --
if(WIN32)
set(CMAKE_MODULE_PATH "$ENV{OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}")
endif(WIN32)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MODULE_PATH
"${OGRE_SDK}/CMake"
"${OGRE_SDK}/CMake/Utils"
"${OGRE_SDK}/CMake/Packages"
)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#------------------
#------ Ogre Lib --
if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(OGRE REQUIRED)
if (OGRE_Terrain_FOUND)
set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_Terrain_LIBRARIES})
message(STATUS "Found OGRE_Terrain: ${OGRE_Terrain_LIBRARIES}")
else (OGRE_Terrain_FOUND)
message(SEND_ERROR "OgreTerrain Library not found.")
endif(OGRE_Terrain_FOUND)
endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories( ${OGRE_SDK}/lib/release/Ogre.framework/Headers/ ) # will search for OgreSDK/lib/release/Ogre.framework/Headers in OGRE_SDK (defined line 20)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
MESSAGE(STATUS "This will use the following Ogre version: ${OGRE_VERSION_NAME}")
#-----------------
#------ OIS Lib --
find_package(OIS REQUIRED)
if(NOT OIS_FOUND)
message(SEND_ERROR "Failed to find OIS.")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories( ${OGRE_SDK}/include/OIS/ ) # will search for OgreSDK/include/OIS/
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#-------------------
#------ Boost Lib --
#if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# set(Boost_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/data/osx/SDK/include")
#endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(WIN32) #-- Required by the Ogre Window 32 version (not Linux nor OSX atm)
# Find Boost
if (NOT OGRE_BUILD_PLATFORM_IPHONE)
if (WIN32 OR APPLE)
set(Boost_USE_STATIC_LIBS TRUE)
else ()
# Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit
set(Boost_USE_STATIC_LIBS ${OGRE_STATIC})
endif ()
if (MINGW)
# this is probably a bug in CMake: the boost find module tries to look for
# boost libraries with name libboost_*, but CMake already prefixes library
# search names with "lib". This is the workaround.
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
endif ()
set(Boost_ADDITIONAL_VERSIONS "1.46" "1.46.0" "1.42" "1.42.0" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" )
# Components that need linking (NB does not include header-only components like bind)
set(OGRE_BOOST_COMPONENTS thread date_time)
find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
if (NOT Boost_FOUND)
# Try again with the other type of libs
set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS})
find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
endif()
find_package(Boost QUIET)
# Set up referencing of Boost
include_directories(${Boost_INCLUDE_DIR})
add_definitions(-DBOOST_ALL_NO_LIB)
set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
endif()
endif()
#------------------------------------------------------------------------------
#---------------------------------------------------------------- Extra Libs --
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
FIND_LIBRARY(IOKit_LIBRARY IOKit)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(CARBON_LIBRARY Carbon)
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
#FIND_LIBRARY(GLUT_LIBRARY GLUT )
SET(EXTRA_LIBS ${EXTRA_LIBS} ${IOKit_LIBRARY} ${COCOA_LIBRARY} ${CARBON_LIBRARY} ${OPENGL_LIBRARY})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(EXTRA_LIBS ${EXTRA_LIBS} GL GLU )
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(WIN32)
SET(EXTRA_LIBS ${EXTRA_LIBS} opengl32 glu32 ) #-lopengl32 -lglu32 -lglut32
endif(WIN32)
#------------------------------------------------------------------------------
#------------------------------------------ Prepare non library source files --
set(HDRS
./
)
set(SRCS
./main.cpp
)
include_directories(
${OIS_INCLUDE_DIRS}
${OGRE_INCLUDE_DIRS}
)
#------------------------------------------------------------------------------
#------------------------------------------------- Initialize Compiler flags --
#set(CMAKE_CXX_COMPILER "g++") #define the compiler to use
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") #define the C++0X flag
set(CMAKE_VERBOSE_MAKEFILE ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Volumes/Dev/OgreSDK/lib/release/Ogre.framework/Versions/1.7.3/Ogre ") # not sure it's still required !
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#------------------------------------------------------------------------------
#----------------------------------------------------- Initialize Executable --
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} PRE_BUILD COMMAND export LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/dist/bin:$LD_LIBRARY_PATH )
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_executable(${CMAKE_PROJECT_NAME} MACOSX_BUNDLE ${HDRS} ${SRCS})
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND install_name_tool -change /opt/local/lib/gcc46/libstdc++.6.dylib @executable_path/libs/libstdc++.6.dylib ${CMAKE_PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/${CMAKE_PROJECT_NAME}.app/Contents/MacOS )
else ()
add_executable(${CMAKE_PROJECT_NAME} WIN32 ${HDRS} ${SRCS})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES DEBUG_POSTFIX _d)
#------------------------------------------------------------------------------
#----------------------------------------------- Initialize Static Libraries --
#------ GameBoard --
file(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} core/GameBoard.cpp core/GameBoard.h)
source_group("" FILES ${SRCS})
add_library(GameBoard STATIC ${SRCS})
#------ Player --
file(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} core/Player.cpp core/Player.h)
source_group("" FILES ${SRCS})
add_library(Player STATIC ${SRCS})
#------ DebugTools --
file(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} core/tools/*.cpp core/tools/*.h) #*/
source_group("" FILES ${SRCS})
add_library(DebugTools STATIC ${SRCS})
#------ etc. etc. etc.
## Tips for linking problems : If "A" depends on "B", then "A" must be BEFORE "B" in the following list. And remove "etc." indeed ;)
target_link_libraries(${CMAKE_PROJECT_NAME} GameBoard Player DebugTools etc. ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${EXTRA_LIBS} )
#------------------------------------------------------------------------------
#------------------------------------------------------------------- Install --
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/bin)
# post-build copy for win32
if(WIN32 AND NOT MINGW)
add_custom_command( TARGET ${CMAKE_PROJECT_NAME} PRE_BUILD
COMMAND if not exist .\\dist\\bin mkdir .\\dist\\bin )
add_custom_command( TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND copy \"$(TargetPath)\" .\\dist\\bin )
endif(WIN32 AND NOT MINGW)
if(MINGW OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/dist/bin)
endif(MINGW OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}\\dist\\bin)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Install required files into the OSX Bundle (once again I placed all the stuff required into my project folder/data/etc.)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/data/media DESTINATION bin/${CMAKE_PROJECT_NAME}.app/Contents/Resources)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/data/osx/Plugins DESTINATION bin/${CMAKE_PROJECT_NAME}.app/Contents)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/data/osx/Resources DESTINATION bin/${CMAKE_PROJECT_NAME}.app/Contents)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/data/osx/MacOS DESTINATION bin/${CMAKE_PROJECT_NAME}.app/Contents)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/data/osx/Frameworks DESTINATION bin/${CMAKE_PROJECT_NAME}.app/Contents)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Install required files for the Windows version
if(WIN32)
install(TARGETS ${CMAKE_PROJECT_NAME}
RUNTIME DESTINATION bin
CONFIGURATIONS All)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/dist/Media
DESTINATION ./
CONFIGURATIONS Release RelWithDebInfo Debug
)
install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins.cfg
${CMAKE_SOURCE_DIR}/dist/bin/resources.cfg
DESTINATION bin
CONFIGURATIONS Release RelWithDebInfo
)
install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins_d.cfg
${CMAKE_SOURCE_DIR}/dist/bin/resources_d.cfg
DESTINATION bin
CONFIGURATIONS Debug
)
install(FILES ${OGRE_PLUGIN_DIR_REL}/OgreMain.dll
${OGRE_PLUGIN_DIR_REL}/RenderSystem_Direct3D9.dll
${OGRE_PLUGIN_DIR_REL}/RenderSystem_GL.dll
${OGRE_PLUGIN_DIR_REL}/OIS.dll
DESTINATION bin
CONFIGURATIONS Release RelWithDebInfo
)
install(FILES ${OGRE_PLUGIN_DIR_DBG}/OgreMain_d.dll
${OGRE_PLUGIN_DIR_DBG}/RenderSystem_Direct3D9_d.dll
${OGRE_PLUGIN_DIR_DBG}/RenderSystem_GL_d.dll
${OGRE_PLUGIN_DIR_DBG}/OIS_d.dll
DESTINATION bin
CONFIGURATIONS Debug
)
endif(WIN32)
# similar install with Linux etc..