Mercurial > almixer_isolated
view CMakeLists.txt @ 3:a929285e1db0
Added CMake build system.
There are problems with the SDL_sound module due to changes in CMake. Right now they just seem to be warnings, but I am unable to suppress them.
Added license.
Added README.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Wed, 27 Oct 2010 20:43:14 -0700 |
parents | |
children | 26aec5629f68 |
line wrap: on
line source
CMAKE_MINIMUM_REQUIRED(VERSION 2.4) # These are all useless <sigh> cmake_policy(SET CMP0000 OLD) cmake_policy(SET CMP0004 OLD) PROJECT(ALmixer) INCLUDE(CMakeDependentOption) SET(CPACK_SET_DESTDIR TRUE) INCLUDE(CPack) FIND_PACKAGE(OpenAL) FIND_PACKAGE(SDL) # Note: SDL_sound needs to be updated for 2.6+. You'll get annoying warnings. FIND_PACKAGE(SDL_sound) SET(ALMIXER_MAJOR_VERSION 0) SET(ALMIXER_MINOR_VERSION 1) SET(ALMIXER_PATCH_VERSION 0) SET(ALMIXER_VERSION ${ALMIXER_MAJOR_VERSION}.${ALMIXER_MINOR_VERSION}.${ALMIXER_PATCH_VERSION}) SET(ALMIXER_COMPATIBILITY_VERSION ${ALMIXER_MAJOR_VERSION}.${ALMIXER_MINOR_VERSION}.0) # ??? Don't know SET(ALMIXER_SOVERSION ${ALMIXER_MAJOR_VERSION}.${ALMIXER_MINOR_VERSION}.0) OPTION(WANTS_BUILD_SHARED_LIBRARY "Set to ON to build dynamic library." ON) #OPTION(ALMIXER_COMPILE_WITHOUT_SDL "Not supported. Don't use" OFF) OPTION(ENABLE_ALMIXER_THREADS "Use background thread for ALmixer_Update()" OFF) IF(APPLE) CMAKE_DEPENDENT_OPTION(WANTS_BUILD_FRAMEWORK "Set to ON to build framework instead of dylib. Only valid if BUILD_SHARED_LIBRARY is ON an is OS X." ON "WANTS_BUILD_SHARED_LIBRARY" ON) ENDIF(APPLE) SET(ALMIXER_LIBRARY_NAME ALmixer) IF(APPLE) SET(CMAKE_FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.") SET(CMAKE_FRAMEWORK_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install_name path for framework.") #SET(CMAKE_DYLIB_INSTALL_NAME_DIR "" CACHE STRING "install_name path for dylib.") SET(CMAKE_DYLIB_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "install_name path for dylib.") SET(ALMIXER_FRAMEWORK_NAME "${ALMIXER_LIBRARY_NAME}.framework") SET(ALMIXER_FRAMEWORK_VERSION_NUMBER "A") SET(ALMIXER_FRAMEWORK_VERSIONED_EXECUTABLE_DIR "Versions/${ALMIXER_FRAMEWORK_VERSION_NUMBER}/MacOS") SET(ALMIXER_FRAMEWORK_VERSIONED_LIB_DIR "Versions/${ALMIXER_FRAMEWORK_VERSION_NUMBER}/lib") SET(ALMIXER_FRAMEWORK_CURRENT_EXECUTABLE_DIR "Versions/Current/MacOS") # For Apple install_name, is it better to detect if Xcode vs Makefile? # Xcode default=1, Makefile=0? Or detect if Framework vs. dylib, # Framework=1, dylib=0? OPTION(CMAKE_BUILD_WITH_INSTALL_RPATH "Set to YES to set the rpath or install_name on build instead of install." ON) ELSEIF(UNIX) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "rpaths separated by semicolons.") OPTION(CMAKE_BUILD_WITH_INSTALL_RPATH "Set to YES to set the rpath or install_name on build instead of install." OFF) ENDIF(APPLE) SET(ALMIXER_SOURCE ${ALmixer_SOURCE_DIR}/ALmixer.c ${ALmixer_SOURCE_DIR}/CircularQueue.c ${ALmixer_SOURCE_DIR}/CircularQueue.h ) SET(PUBLIC_HEADERS ${ALmixer_SOURCE_DIR}/ALmixer.h ) #SET(RESOURCE_FILES #) ADD_DEFINITIONS(-DALMIXER_BUILD_LIBRARY) IF(ENABLE_ALMIXER_THREADS) ADD_DEFINITIONS(-DENABLE_ALMIXER_THREADS) ELSE(ENABLE_ALMIXER_THREADS) REMOVE_DEFINITIONS(-DENABLE_ALMIXER_THREADS) ENDIF(ENABLE_ALMIXER_THREADS) IF(WANTS_BUILD_SHARED_LIBRARY) ADD_LIBRARY(ALMIXER_LIBRARY SHARED ${PUBLIC_HEADERS} ${ALMIXER_SOURCE} ${RESOURCE_FILES}) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES OUTPUT_NAME "ALmixer") ENDIF(WANTS_BUILD_SHARED_LIBRARY) # Set Dynamic Library and Framework properties IF(WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION "${ALMIXER_FRAMEWORK_VERSION_NUMBER}" # PRIVATE_HEADER "fooPrivate.h;fooBoth.h" PUBLIC_HEADER "${PUBLIC_HEADERS}" RESOURCE "${RESOURCE_FILES}" # INSTALL_NAME_DIR ${CMAKE_FRAMEWORK_INSTALL_NAME_DIR} # BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH} VERSION ${ALMIXER_VERSION} SOVERSION ${ALMIXER_COMPATIBILITY_VERSION} # COMPILE_FLAGS "${ALMIXER_C_FLAGS}" ) # I moved the INSTALL_NAME_DIR to use SET_PROPERTY instead because # SET_TARGET_PROPERTIES will fail if the variable is empty. SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY INSTALL_NAME_DIR ${CMAKE_FRAMEWORK_INSTALL_NAME_DIR}) SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH NO) # If the user deletes the install_name path, use the gcc default # and disable the option completely. But CMake by default places # the name of the library in the install_name if # BUILD_WITH_INSTALL_RPATH is ON. So to avoid this, I need to # disable the switch. IF(CMAKE_FRAMEWORK_INSTALL_NAME_DIR) # MESSAGE("got dir ${CMAKE_FRAMEWORK_INSTALL_NAME_DIR}") SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH}) ELSE(CMAKE_FRAMEWORK_INSTALL_NAME_DIR) # MESSAGE("no dir ${CMAKE_FRAMEWORK_INSTALL_NAME_DIR}") SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH NO) ENDIF(CMAKE_FRAMEWORK_INSTALL_NAME_DIR) # Short Version is the "marketing version". It is the version # the user sees in an information panel. SET(MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${ALMIXER_MAJOR_VERSION}.${ALMIXER_MINOR_VERSION}.${ALMIXER_PATCH_VERSION}") # Bundle version is the version the OS looks at. SET(MACOSX_FRAMEWORK_BUNDLE_VERSION "${ALMIXER_MAJOR_VERSION}.${ALMIXER_MINOR_VERSION}.${ALMIXER_PATCH_VERSION}") SET(MACOSX_FRAMEWORK_IDENTIFIER "net.playcontrol.almixer") ELSEIF(WANTS_BUILD_SHARED_LIBRARY) IF(APPLE) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES FRAMEWORK FALSE # INSTALL_NAME_DIR ${CMAKE_DYLIB_INSTALL_NAME_DIR} # BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH} VERSION ${ALMIXER_VERSION} SOVERSION ${ALMIXER_COMPATIBILITY_VERSION} # COMPILE_FLAGS "${ALMIXER_C_FLAGS}" ) # I moved the INSTALL_NAME_DIR to use SET_PROPERTY instead because # SET_TARGET_PROPERTIES will fail if the variable is empty. SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY INSTALL_NAME_DIR ${CMAKE_DYLIB_INSTALL_NAME_DIR}) SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH NO) # If the user deletes the install_name path, use the gcc default # and disable the option completely. But CMake by default places # the name of the library in the install_name if # BUILD_WITH_INSTALL_RPATH is ON. So to avoid this, I need to # disable the switch. IF(CMAKE_DYLIB_INSTALL_NAME_DIR) SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH}) ELSE(CMAKE_DYLIB_INSTALL_NAME_DIR) SET_PROPERTY(TARGET ALMIXER_LIBRARY PROPERTY BUILD_WITH_INSTALL_RPATH OFF) ENDIF(CMAKE_DYLIB_INSTALL_NAME_DIR) ELSEIF(UNIX) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH} BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH} VERSION ${ALMIXER_VERSION} SOVERSION ${ALMIXER_SOVERSION} # COMPILE_FLAGS "${ALMIXER_C_FLAGS}" ) ELSEIF(WIN32) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES VERSION ${ALMIXER_VERSION} SOVERSION ${ALMIXER_COMPATIBILITY_VERSION} # COMPILE_FLAGS "${ALMIXER_C_FLAGS} -DALMIXER_BUILD_AS_DLL" ) ELSE(APPLE) SET_TARGET_PROPERTIES(ALMIXER_LIBRARY PROPERTIES VERSION ${ALMIXER_VERSION} SOVERSION ${ALMIXER_COMPATIBILITY_VERSION} # COMPILE_FLAGS "${ALMIXER_C_FLAGS}" ) ENDIF(APPLE) ENDIF(WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR} ${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) #TARGET_LINK_LIBRARIES(ALMIXER_LIBRARY "${OPENAL_LIBRARY} ${SDL_LIBRARIES} ${SDL_SOUND_LIBRARIES}") MESSAGE("SDL_libraries: ${SDL_LIBRARY}, ${SDL_SOUND_LIBRARIES}.") TARGET_LINK_LIBRARIES(ALMIXER_LIBRARY ${OPENAL_LIBRARY} "${SDL_SOUND_LIBRARIES}" ${SDL_LIBRARY}) # Install commands below IF(APPLE AND WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK) # Will install framework to /Library/Frameworks directory or user specified INSTALL(TARGETS ALMIXER_LIBRARY FRAMEWORK DESTINATION ${CMAKE_FRAMEWORK_INSTALL_DIR} ) ELSE(APPLE AND WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK) INSTALL(TARGETS ALMIXER_LIBRARY LIBRARY DESTINATION lib ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include ) ENDIF(APPLE AND WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK) # For uninstall (needs cmake_uninstall.cmake.in in the top-level directory) CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/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") # 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 ALMIXER_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/MacOSX10.5.sdk) SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.5" CACHE STRING "Flags used by the compiler during all build types." FORCE) ELSE(EXISTS /Developer/SDKs/MacOSX10.5.sdk) IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.4" 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(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) ENDIF(EXISTS /Developer/SDKs/MacOSX10.5.sdk) ENDIF(NOT ALMIXER_CONFIG_HAS_BEEN_RUN_BEFORE) ENDIF(APPLE) # This needs to be run very last so other parts of the scripts can take # advantage of this. IF(NOT ALMIXER_CONFIG_HAS_BEEN_RUN_BEFORE) SET(ALMIXER_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(NOT ALMIXER_CONFIG_HAS_BEEN_RUN_BEFORE)