this should help people hacking the cmake files
authorkoda
Sun, 27 Mar 2011 01:53:59 +0100
changeset 5053 a767954cfa03
parent 5052 74a81c276d67
child 5054 71dd49f31582
this should help people hacking the cmake files (removes old comments, BUNDLE and other macros, updates to INSTALL file)
CMakeLists.txt
INSTALL
tools/CMakeLists.txt
tools/CreateMacBundle.cmake.in
--- a/CMakeLists.txt	Sat Mar 26 22:49:38 2011 +0100
+++ b/CMakeLists.txt	Sun Mar 27 01:53:59 2011 +0100
@@ -39,13 +39,6 @@
 set(CPACK_PACKAGE_VERSION_MINOR "9")
 set(CPACK_PACKAGE_VERSION_PATCH "16${version_suffix}")
 
-#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})
-
 #set some safe values
 IF(NOT WITH_SERVER)
 	SET(WITH_SERVER 0)
@@ -72,8 +65,8 @@
 	STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
 	STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
 
+	#if nothing is set, we deploy only for the current system
 	if(NOT minimum_macosx)
-		#if nothing is set, we deploy only for the current system
 		set(minimum_macosx ${current_macosx_version})
 	endif()
 
@@ -81,30 +74,21 @@
 		set(FATAL "Hedgewars is not supported for pre-10.4 systems")
 	endif()
 
-	set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
-
-	#create universal binaries only when it's time to bundle the application, also build server
-	IF(BUNDLE)
-		set(WITH_SERVER true)
-		if(NOT minimum_macosx MATCHES "10.6")
-			set(CMAKE_C_COMPILER "gcc-4.0")
-			set(CMAKE_CXX_COMPILER "g++-4.0")
+	if(NOT CMAKE_OSX_ARCHITECTURES)
+		if(current_macosx_version MATCHES "10.6")
+			set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
 		else()
-			if(current_macosx_version MATCHES "10.6")
-				if(MACAPPSTORE)
-					set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
-				else()
-					set(CMAKE_OSX_ARCHITECTURES "x86_64")
-				endif()
-			endif()
+			set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
 		endif()
-	ELSE()
-		if(current_macosx_version MATCHES "10.6")
-			set(CMAKE_OSX_ARCHITECTURES "x86_64")
-		endif()
-	ENDIF()
+	endif()
+
+	message(STATUS "Build system: Mac OS X ${current_macosx_version} - Target ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
 
-	message(STATUS "Target system: Mac OS X ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
+	#be sure to select ppc-compatible toolchains just in case
+	if(NOT minimum_macosx MATCHES "10.6")
+		set(CMAKE_C_COMPILER "gcc-4.0")
+		set(CMAKE_CXX_COMPILER "g++-4.0")
+	endif()
 
 	if(minimum_macosx MATCHES "10.4")
 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
@@ -129,9 +113,6 @@
 
 
 #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)
@@ -141,7 +122,6 @@
 	set(Optz true)
 else()
 	message(STATUS "Building Debug")
-	#set(CMAKE_VERBOSE_MAKEFILE true)
 	set(Optz false)
 endif()
 
@@ -177,16 +157,22 @@
 set(HEDGEWARS_PROTO_VER 38)
 
 if(WITH_SERVER)
-	message(STATUS "Server is going to be built! Make sure you have GHC installed")
-	set(HAVE_NETSERVER true)
-	add_subdirectory(gameServer)
+	find_program(ghc_executable ghc)
+
+	if(ghc_executable)
+		set(HAVE_NETSERVER true)
+		add_subdirectory(gameServer)
+	else()
+		message(STATUS "No GHC executable found, server will *not* be built")
+		set(HAVE_NETSERVER false)
+	endif()
 else(WITH_SERVER)
 	set(HAVE_NETSERVER false)
 endif(WITH_SERVER)
 
 add_subdirectory(misc/liblua)
 add_subdirectory(hedgewars)
-#add_subdirectory(misc/libopenalbridge)
+
 if(NOT BUILD_ENGINE_LIBRARY)
 	add_subdirectory(bin)
 	add_subdirectory(QTfrontend)
--- a/INSTALL	Sat Mar 26 22:49:38 2011 +0100
+++ b/INSTALL	Sun Mar 27 01:53:59 2011 +0100
@@ -1,5 +1,5 @@
 To compile and install you need:
- - Qt >= 4.4
+ - Qt >= 4.5
  - FreePascal >= 2.2.4
  - SDL >= 1.2.5
  - SDL_net >= 1.2.5
@@ -9,21 +9,19 @@
  - CMake >= 2.6.0
  - Lua >= 5.1.0
 For server:
- - Glasgow Haskell Compiler 6.10
+ - Glasgow Haskell Compiler >= 6.10
+ - bytestring-show package
  - dataenc package
  - hslogger package
- - utf8-string package
 
 1. Configure:
 $ cmake .
 or
-$ cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="install_prefix" -DDATA_INSTALL_DIR="data_dir" .
-
-add -DWITH_SERVER=1 to compile net server; to create a relocatable bundle under Mac OS X you can do
+$ cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="install_prefix" \
+-DDATA_INSTALL_DIR="data_dir" .
 
-$ cmake -DCMAKE_BUILD_TYPE="Release" -DBUNDLE=1 .
-
-if you have Qt installed but it is not found you can set it up with -DQT_QMAKE_EXECUTABLE="path_to_qmake"
+add -DWITH_SERVER=1 to compile net server; if you have Qt installed but it is
+not found you can set it up with -DQT_QMAKE_EXECUTABLE="path_to_qmake"
 
 2. Compile:
 $ make
--- a/tools/CMakeLists.txt	Sat Mar 26 22:49:38 2011 +0100
+++ b/tools/CMakeLists.txt	Sun Mar 27 01:53:59 2011 +0100
@@ -7,8 +7,7 @@
 	ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
 endif()
 
-if (APPLE AND BUNDLE)
-
+if (APPLE)
 	find_package(Qt4 REQUIRED)
 	find_package(SDL REQUIRED)
 	find_package(SDL_image REQUIRED)
@@ -44,4 +43,4 @@
 
 	CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
 
-endif(APPLE AND BUNDLE)
+endif()
--- a/tools/CreateMacBundle.cmake.in	Sat Mar 26 22:49:38 2011 +0100
+++ b/tools/CreateMacBundle.cmake.in	Sun Mar 27 01:53:59 2011 +0100
@@ -1,18 +1,24 @@
 message(STATUS "Performing standalone bundle creation...")
 
-execute_process(COMMAND mkdir -p ${frameworks_dir})
+execute_process(COMMAND ls ${frameworks_dir} RESULT_VARIABLE doBundle OUTPUT_QUIET ERROR_QUIET)
 
-execute_process(COMMAND ${macdeployqt_EXE} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET)
+if(doBundle EQUAL 1)
+    execute_process(COMMAND mkdir -p ${frameworks_dir})
+
+    execute_process(COMMAND ${macdeployqt_EXE} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET)
 
-execute_process(COMMAND cp -pPR ${sdl_dir}		${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework)
-execute_process(COMMAND cp -pPR ${SDLIMAGE_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_image.framework)
-execute_process(COMMAND cp -pPR ${SDLNET_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_net.framework)
-execute_process(COMMAND cp -pPR ${SDLTTF_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_ttf.framework)
-execute_process(COMMAND cp -pPR ${SDLMIXER_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_mixer.framework)
-execute_process(COMMAND cp -pPR ${OGG_LIBRARY}	 	${CMAKE_BINARY_DIR}/${frameworks_dir}/Ogg.framework)
-execute_process(COMMAND cp -pPR ${VORBIS_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/Vorbis.framework)
+    execute_process(COMMAND cp -pPR ${sdl_dir}          ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework)
+    execute_process(COMMAND cp -pPR ${SDLIMAGE_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_image.framework)
+    execute_process(COMMAND cp -pPR ${SDLNET_LIBRARY}   ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_net.framework)
+    execute_process(COMMAND cp -pPR ${SDLTTF_LIBRARY}   ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_ttf.framework)
+    execute_process(COMMAND cp -pPR ${SDLMIXER_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_mixer.framework)
+    execute_process(COMMAND cp -pPR ${OGG_LIBRARY}      ${CMAKE_BINARY_DIR}/${frameworks_dir}/Ogg.framework)
+    execute_process(COMMAND cp -pPR ${VORBIS_LIBRARY}   ${CMAKE_BINARY_DIR}/${frameworks_dir}/Vorbis.framework)
 
-if(${SPARKLE_FOUND})
-	execute_process(COMMAND cp -pPR ${SPARKLE_LIBRARY}	${CMAKE_BINARY_DIR}/${frameworks_dir}/Sparkle.framework)
+    if(${SPARKLE_FOUND})
+        execute_process(COMMAND cp -pPR ${SPARKLE_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/Sparkle.framework)
+    endif()
+    message(STATUS "Bundle frameworks added")
+else()
+    message(STATUS "Bundle frameworks already present; skipping...")
 endif()
-