Skip to content

Commit

Permalink
Update cmake files to fix OS X build issues
Browse files Browse the repository at this point in the history
Updated OS X deployment target to 10.7 and set architecture to x86_64.
Also, removed existing unused code used to copy libraries for OS X from
CorsixTH and MapEdit cmake files and replaced with new code that
automatically bundles app up and includes them in the app. Added
the code to create a bundle to the AnimView cmake file. Finally, updated
the MapEdit cmake file to use the Lua find package code from the CorsixTH
cmake file, which includes a fix for OS X 64bit.
  • Loading branch information
admdly committed Dec 9, 2014
1 parent 2c9a82a commit e4a79ff
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 52 deletions.
7 changes: 7 additions & 0 deletions AnimView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ ENDIF(UNIX)

IF(APPLE)
install(TARGETS AnimView BUNDLE DESTINATION .)

# Fix the OS X bundle to include required libraries (create a redistributable app)
install(CODE "
INCLUDE(BundleUtilities)
SET(BU_CHMOD_BUNDLE_ITEMS ON)
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/AnimView.app \"\" \"\")
")
ELSE()
install(TARGETS AnimView RUNTIME DESTINATION AnimView)
install(FILES LICENSE.txt DESTINATION AnimView )
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ ENDIF(MSVC)
INCLUDE(CheckIncludeFiles)
SET(CORSIX_TH_DONE_TOP_LEVEL_CMAKE ON)

IF (APPLE)
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
IF(APPLE)
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF()

# Define our options
Expand Down
27 changes: 6 additions & 21 deletions CorsixTH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,15 @@ ENDIF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)

# Declaration of the install process
IF(APPLE)

#Just use the prefix as it's sufficient to just set the prefix to /Applications on Mac.
install(TARGETS CorsixTH BUNDLE DESTINATION .)

#Copy the required frameworks into the bundle.
IF(SDL_FOUND)
IF(SDL_LIBRARY MATCHES "\\.framework") #Only copy if it's an actual framework.
string(REPLACE "-framework Cocoa" "" SDL_FRAMEWORK_LOC ${SDL_LIBRARY})
install(DIRECTORY ${SDL_FRAMEWORK_LOC} DESTINATION CorsixTH.app/Contents/Frameworks)
ENDIF()
ENDIF()

IF(SDLMIXER_FOUND)
IF(${SDLMIXER_LIBRARY} MATCHES "\\.framework$") #Only copy if it's an actual framework.
install(DIRECTORY ${SDLMIXER_LIBRARY} DESTINATION CorsixTH.app/Contents/Frameworks)
ENDIF()
ENDIF()

IF(LUA_FOUND)
IF(${LUA_LIBRARY} MATCHES "\\.framework$") #Only copy if it's an actual framework.
install(DIRECTORY ${LUA_LIBRARY} DESTINATION CorsixTH.app/Contents/Frameworks)
ENDIF()
ENDIF()

# Fix the OS X bundle to include required libraries (create a redistributable app)
install(CODE "
INCLUDE(BundleUtilities)
SET(BU_CHMOD_BUNDLE_ITEMS ON)
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/CorsixTH.app \"\" \"\")
")
ELSE()
install(TARGETS CorsixTH RUNTIME DESTINATION CorsixTH)
install(DIRECTORY Lua Levels DESTINATION CorsixTH PATTERN "*.svn" EXCLUDE)
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/SDLMain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
IF(APPLE)
find_package(SDL REQUIRED)

set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
include_directories(${SDL_INCLUDE_DIR})

add_library (SDLmain STATIC SDLMain.m)
Expand Down
47 changes: 19 additions & 28 deletions MapEdit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,20 @@ IF(CORSIX_TH_USE_OGL_RENDERER)
ENDIF(CORSIX_TH_USE_OGL_RENDERER)

# Find Lua
FIND_PACKAGE(Lua51 REQUIRED)
IF(LUA51_FOUND)
TARGET_LINK_LIBRARIES( MapEdit ${LUA_LIBRARY})
FIND_PACKAGE(Lua REQUIRED)
IF(Lua_FOUND)
TARGET_LINK_LIBRARIES(MapEdit ${LUA_LIBRARY})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
message( " Lua 5.1 found" )
ELSE(LUA51_FOUND)
message( FATAL_ERROR "error: Lua library not found, it is required to build")
ENDIF(LUA51_FOUND)
# Special link flags needed on OSX/64bit, according to: http://luajit.org/install.html
# If these are not specified, luaL_newstate() returns NULL and we get this:
# Fatal error starting CorsixTH: Cannot open Lua state.
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND LUA_INTERPRETER_TYPE STREQUAL "LuaJIT" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
TARGET_LINK_LIBRARIES(MapEdit "-pagezero_size 10000" "-image_base 100000000")
ENDIF()
message(" ${LUA_INTERPRETER_TYPE} found")
ELSE(Lua_FOUND)
message(FATAL_ERROR "Error: Lua library not found, it is required to build")
ENDIF(Lua_FOUND)

# Find msinttypes for MSVC
IF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)
Expand All @@ -182,30 +188,15 @@ IF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)
ENDIF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)

IF(APPLE)

#Just use the prefix as it's sufficient to just set the prefix to /Applications on Mac.
install(TARGETS MapEdit BUNDLE DESTINATION .)

#Copy the required frameworks into the bundle.
IF(SDL_FOUND)
IF(SDL_LIBRARY MATCHES "\\.framework") #Only copy if it's an actual framework.
string(REPLACE "-framework Cocoa" "" SDL_FRAMEWORK_LOC ${SDL_LIBRARY})
install(DIRECTORY ${SDL_FRAMEWORK_LOC} DESTINATION MapEdit.app/Contents/Frameworks)
ENDIF()
ENDIF()

IF(SDLMIXER_FOUND)
IF(${SDLMIXER_LIBRARY} MATCHES "\\.framework$") #Only copy if it's an actual framework.
install(DIRECTORY ${SDLMIXER_LIBRARY} DESTINATION MapEdit.app/Contents/Frameworks)
ENDIF()
ENDIF()

IF(LUA51_FOUND)
IF(${LUA_LIBRARY} MATCHES "\\.framework$") #Only copy if it's an actual framework.
install(DIRECTORY ${LUA_LIBRARY} DESTINATION MapEdit.app/Contents/Frameworks)
ENDIF()
ENDIF()

# Fix the OS X bundle to include required libraries (create a redistributable app)
install(CODE "
INCLUDE(BundleUtilities)
SET(BU_CHMOD_BUNDLE_ITEMS ON)
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/MapEdit.app \"\" \"\")
")
ELSE()
install(TARGETS MapEdit RUNTIME DESTINATION CorsixTH)
ENDIF()

0 comments on commit e4a79ff

Please sign in to comment.