From a9056ee6bc1dfe3ed8b9599fd8984d7899ff9e99 Mon Sep 17 00:00:00 2001 From: auria Date: Thu, 14 Mar 2013 01:39:23 +0000 Subject: [PATCH] Adapt CMake to make it able to compile on OSX in 10.5 compatibility mode. The next step might be removing the Xcode project, less maintenance... git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12549 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- CMakeLists.txt | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6088cb9bd..cea2cec31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,13 +54,34 @@ if(MSVC) set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies) endif() +if(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F/Library/Frameworks") +endif() + # OpenAL -find_package(OpenAL REQUIRED) -include_directories(${OPENAL_INCLUDE_DIR}) +if(APPLE) + # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has + # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases : + # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting + # CMake pick the library it wants essentially means I can't build. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework OpenAL") + set(OPENAL_LIBRARY) +else() + find_package(OpenAL REQUIRED) + include_directories(${OPENAL_INCLUDE_DIR}) +endif() # OggVorbis -find_package(OggVorbis REQUIRED) -include_directories(${OGGVORBIS_INCLUDE_DIRS}) +if(APPLE) + # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has + # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases : + # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting + # CMake pick the library it wants essentially means I can't build. + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/Library/Frameworks/Ogg.framework/Versions/A/Headers -I/Library/Frameworks/Vorbis.framework/Versions/A/Headers") +else() + find_package(OggVorbis REQUIRED) + include_directories(${OGGVORBIS_INCLUDE_DIRS}) +endif() # CURL find_package(CURL REQUIRED) @@ -197,6 +218,15 @@ target_link_libraries(supertuxkart ${OPENAL_LIBRARY} ${OPENGL_LIBRARIES}) +if(APPLE) + # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has + # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases : + # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting + # CMake pick the library it wants essentially means I can't build. + set_target_properties(supertuxkart PROPERTIES LINK_FLAGS "-F/Library/Frameworks -framework OpenAL -framework Ogg -framework Vorbis") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers") +endif() + if(USE_FRIBIDI) target_link_libraries(supertuxkart ${FRIBIDI_LIBRARIES}) add_definitions(-DENABLE_BIDI)