--- a/CMakeLists.txt Tue Nov 24 20:40:08 2009 +0000
+++ b/CMakeLists.txt Wed Nov 25 04:27:53 2009 +0000
@@ -12,6 +12,14 @@
set(CPACK_PACKAGE_VERSION_MINOR "9")
set(CPACK_PACKAGE_VERSION_PATCH "13-dev")
+#forbid in-tree building
+#IF (${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
+# MESSAGE(STATUS "Please do an out-of-tree build:")
+# MESSAGE(STATUS "rm CMakeCache.txt; mkdir build; cd build; cmake ..; make")
+# MESSAGE(FATAL_ERROR "In-tree-build detected!")
+#ENDIF (${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
+
+
if(APPLE)
set(CMAKE_FIND_FRAMEWORK "FIRST")
@@ -21,37 +29,44 @@
set(DATA_INSTALL_DIR "../Resources/")
set(target_dir ".")
- #build architecture / os version
- set(minimum_os $ENV{MACOSX_DEPLOYMENT_TARGET})
- if(minimum_os MATCHES "10.4")
- message(STATUS "Target: Mac OS X 10.4 i386/ppc")
- set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
- set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
- endif()
- if(minimum_os MATCHES "10.5")
- message(STATUS "Target: Mac OS X 10.5 i386/ppc")
- set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk/")
- set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
+ #detect on which system are we
+ EXEC_PROGRAM("/usr/bin/sw_vers" OUTPUT_VARIABLE MACOSX_VERSION_TMP)
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
+ STRING(REGEX REPLACE "([0-9][0-9].[0-9]+).[0-9]" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
+
+ set(minimum_macosx $ENV{MACOSX_DEPLOYMENT_TARGET})
+
+ if(NOT minimum_macosx)
+ set(minimum_macosx ${current_macosx_version})
endif()
- if(minimum_os MATCHES "10.6")
- message(STATUS "Target: Mac OS X 10.6 i386/ppc/x86_64")
- set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk/")
- set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
- set(build_type "universal64")
+
+ #create universal binaries only when it's time to bundle the application
+ IF(BUNDLE)
+ if(current_macosx_version MATCHES "10.6")
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
+ set(build_64_universal TRUE)
+ else()
+ set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
+ endif()
+ ENDIF()
+
+ message(STATUS "Target system: Mac OS X ${minimum_macosx} for ${CMAKE_OSX_ARCHITECTURES}")
+
+ if(minimum_macosx MATCHES "10.4")
+ set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
+ else()
+ set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${minimum_macosx}.sdk/")
endif()
- if(NOT minimum_os)
- #use the default sysroot with default archs
- EXEC_PROGRAM(sw_vers OUTPUT_VARIABLE MACOSX_VERSION)
- string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION "${MACOSX_VERSION}")
- STRING(REGEX REPLACE "[0-9][0-9].([0-9]+).[0-9]" "\\1" MACOSX_VERSION ${MACOSX_VERSION})
- set(minimum_os "10.${MACOSX_VERSION}")
- endif()
+
else(APPLE)
set(target_dir "bin")
endif(APPLE)
#this snippet sets "Release" mode by default
+#IF (NOT CMAKE_BUILD_TYPE)
+# SET(CMAKE_BUILD_TYPE "Release")
+#ENDIF (NOT CMAKE_BUILD_TYPE)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
@@ -67,9 +82,9 @@
#set default flags values for all the project
-set(CMAKE_C_FLAGS "-Wall -pipe")
+set(CMAKE_C_FLAGS "-pipe")
set(CMAKE_C_FLAGS_RELEASE "-w -O2 -fomit-frame-pointer")
-set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG")
+set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
@@ -77,14 +92,8 @@
set(pascal_compiler_flags_cmn "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi")
if(Optz)
- set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Nu" "-Si" ${pascal_compiler_flags_cmn})
+ set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
set(haskell_compiler_flags_cmn "-w" "-O2")
- if(APPLE AND NOT universal_build)
- set(CMAKE_C_FLAGS_RELEASE "-fPIC -msse2 ${CMAKE_C_FLAGS_RELEASE}")
- set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -msse2 ${CMAKE_CXX_FLAGS_RELEASE}")
- set(pascal_compiler_flags_cmn "-fPIC" ${pascal_compiler_flags_cmn})
- #-Cf7400 for ppc, -CfSSE2 for x86 (but none for x86_64)
- endif()
else(Optz)
set(pascal_compiler_flags_cmn "-O-" "-gl" "-dDEBUGFILE" "-pg" "-vv" ${pascal_compiler_flags_cmn})
set(haskell_compiler_flags_cmn "-Wall" "-debug" "-dcore-lint")
--- a/QTfrontend/CMakeLists.txt Tue Nov 24 20:40:08 2009 +0000
+++ b/QTfrontend/CMakeLists.txt Wed Nov 25 04:27:53 2009 +0000
@@ -43,7 +43,7 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
-set(hwfr_src
+set( hwfr_src
game.cpp
main.cpp
hwform.cpp
@@ -100,7 +100,7 @@
set(hwfr_src ${hwfr_src} hedgewars.rc)
endif(MINGW)
-set(hwfr_moc_hdrs
+set( hwfr_moc_hdrs
game.h
hats.h
hwform.h
@@ -141,15 +141,15 @@
)
if(APPLE)
-find_package(Sparkle)
+ find_package(Sparkle)
-set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
-if(SPARKLE_FOUND)
-set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
-endif()
+ set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
+ if(SPARKLE_FOUND)
+ set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
+ endif()
endif()
-set(hwfr_hdrs
+set( hwfr_hdrs
binds.h
ui_hwform.h
predefteams.h
@@ -159,30 +159,26 @@
set(hwfr_rez hedgewars.qrc)
-qt4_add_resources(hwfr_rez_src
- ${hwfr_rez})
+qt4_add_resources(hwfr_rez_src ${hwfr_rez})
-qt4_wrap_cpp(hwfr_moc_srcs
- ${hwfr_moc_hdrs})
+qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs})
add_executable(hedgewars WIN32
${hwfr_src}
${hwfr_moc_srcs}
${hwfr_hdrs}
- ${hwfr_rez_src})
+ ${hwfr_rez_src}
+ )
set(HW_LINK_LIBS
${QT_LIBRARIES}
${SDL_LIBRARY}
${SDLMIXER_LIBRARY}
-)
+ )
if(APPLE)
- set(HW_LINK_LIBS
- ${HW_LINK_LIBS}
- IOKit
- )
+ set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS})
if (SPARKLE_FOUND)
set(HW_LINK_LIBS ${HW_LINK_LIBS} ${SPARKLE_LIBRARY})
add_definitions(-DSPARKLE_ENABLED)
--- a/hedgewars/CMakeLists.txt Tue Nov 24 20:40:08 2009 +0000
+++ b/hedgewars/CMakeLists.txt Wed Nov 25 04:27:53 2009 +0000
@@ -63,12 +63,13 @@
file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
exec_program(${fpc_executable} ${EXECUTABLE_OUTPUT_PATH}
- ARGS ${noexecstack_flags} checkstack.pas
- OUTPUT_VARIABLE noout
- RETURN_VALUE testnoexecstack)
+ ARGS ${noexecstack_flags} checkstack.pas
+ OUTPUT_VARIABLE noout
+ RETURN_VALUE testnoexecstack
+ )
if (${testnoexecstack})
-set (noexecstack_flags "")
+ set (noexecstack_flags "")
endif (${testnoexecstack})
@@ -79,10 +80,14 @@
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
+ message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}")
math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
if (fpc_ver LESS "020200")
message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
else()
+ if (APPLE AND build_64_universal AND fpc_ver LESS "020400")
+ message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications")
+ endif()
set(pascal_compiler ${fpc_executable})
endif ()
endif (fpc_version)
@@ -107,9 +112,6 @@
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
include_directories(${SDL_INCLUDE_DIR})
link_libraries(${SDL_LIBRARY})
-
- #apparently this variable is not exported here
- set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
add_library (SDLmain STATIC SDLMain.m)
set(engine_sources SDLmain ${engine_sources})
@@ -125,50 +127,44 @@
)
ELSE()
#these are the dependencies for building a universal binary on Mac OS X
- find_program(pascal_x86 NAMES ppc386)
- find_program(pascal_ppc NAMES ppcppc)
+ set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
- COMMAND "${pascal_x86}"
- ARGS ${pascal_compiler_flags} -ohwengine.386
+ COMMAND "${pascal_compiler}"
+ ARGS ${pascal_compiler_flags} -ohwengine.386 -Pi386
MAIN_DEPENDENCY ${hwengine_project}
DEPENDS ${engine_sources}
)
add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
- COMMAND "${pascal_ppc}"
- ARGS ${pascal_compiler_flags} -ohwengine.ppc
+ COMMAND "${pascal_compiler}"
+ ARGS ${pascal_compiler_flags} -ohwengine.ppc -Ppowerpc
MAIN_DEPENDENCY ${hwengine_project}
DEPENDS ${engine_sources}
)
add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
- IF(build_type MATCHES "universal64")
- find_program(pascal_x64 NAMES ppcx64)
-
+ IF(build_64_universal)
+ set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" ${lipo_args_list})
+
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64"
- COMMAND "${pascal_x64}"
- ARGS ${pascal_compiler_flags} -ohwengine.x64
+ COMMAND "${pascal_compiler}"
+ ARGS ${pascal_compiler_flags} -ohwengine.x64 -Px86_64
MAIN_DEPENDENCY ${hwengine_project}
DEPENDS ${engine_sources}
)
add_custom_target(hwengine.x64 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64")
+ ENDIF()
- add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
- COMMAND "lipo"
- ARGS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
- DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64"
- )
- else()
- add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
- COMMAND "lipo"
- ARGS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
- DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
- )
- endif()
+ add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
+ COMMAND "lipo"
+ ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
+ DEPENDS ${lipo_args_list}
+ )
ENDIF()
+
add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
--- a/share/CMakeLists.txt Tue Nov 24 20:40:08 2009 +0000
+++ b/share/CMakeLists.txt Wed Nov 25 04:27:53 2009 +0000
@@ -1,4 +1,5 @@
add_subdirectory(hedgewars)
+
IF(APPLE)
configure_file(${hedgewars_SOURCE_DIR}/share/Info.plist.in
${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
--- a/share/Info.plist.in Tue Nov 24 20:40:08 2009 +0000
+++ b/share/Info.plist.in Wed Nov 25 04:27:53 2009 +0000
@@ -22,12 +22,16 @@
<string>GPL</string>
<key>NSAppleScriptEnabled</key>
<false/>
- <key>LSExecutableArchitectures</key>
- <string>i386</string>
- <key>LSMinimumSystemVersion</key>
- <string>${minimum_os}</string>
<key>LSRequiresNativeExecution</key>
<true/>
+ <key>LSArchitecturePriority</key>
+ <array>
+ <string>x86_64</string>
+ <string>i386</string>
+ <string>ppc</string>
+ </array>
+ <key>LSMinimumSystemVersion</key>
+ <string>${minimum_macosx}</string>
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
</dict>
--- a/tools/CMakeLists.txt Tue Nov 24 20:40:08 2009 +0000
+++ b/tools/CMakeLists.txt Wed Nov 25 04:27:53 2009 +0000
@@ -1,38 +1,43 @@
if (NOT APPLE)
-CONFIGURE_FILE(
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
- IMMEDIATE @ONLY)
+ 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")
+ ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
endif()
if (APPLE AND BUNDLE)
-find_package(OGGVORBIS REQUIRED)
-find_package(SPARKLE)
-find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac)
+ find_package(Qt4 REQUIRED)
+ find_package(SDL REQUIRED)
+ find_package(SDL_image REQUIRED)
+ find_package(SDL_net REQUIRED)
+ find_package(SDL_ttf REQUIRED)
+ find_package(SDL_mixer REQUIRED)
+ find_package(OGGVORBIS REQUIRED)
+ find_package(SPARKLE)
+ find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac)
-if(NOT macdeployqt_EXE)
- message(FATAL_ERROR "The utility macdeployqt is required to create the bundle!")
-endif()
-
-#dummy target, we're interested in the postscript
-add_custom_target(bundle)
+ if(NOT macdeployqt_EXE)
+ message(FATAL_ERROR "The utility macdeployqt is required to create the bundle!")
+ endif()
-set_target_properties(bundle PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
+ #dummy target, we're interested in the postscript file
+ add_custom_target(bundle)
-set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
+ set_target_properties(bundle PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
-string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
+ set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
-if(SPARKLE_FOUND)
- set(SPARKLE_FOUND 1)
-else()
- set(SPARKLE_FOUND 0)
-endif()
+ string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
+ if(SPARKLE_FOUND)
+ set(SPARKLE_FOUND 1)
+ else()
+ set(SPARKLE_FOUND 0)
+ endif()
+
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
endif(APPLE AND BUNDLE)