some comments and simplifications for cmake files
authorkoda
Sun, 24 Apr 2011 21:35:23 +0200
changeset 5169 e353ca78d28b
parent 5168 8a074a255af0
child 5170 f7e49eff3708
some comments and simplifications for cmake files
CMakeLists.txt
cmake_modules/FindOggVorbis.cmake
hedgewars/CMakeLists.txt
tools/CMakeLists.txt
--- a/CMakeLists.txt	Thu Apr 21 08:22:34 2011 +0200
+++ b/CMakeLists.txt	Sun Apr 24 21:35:23 2011 +0200
@@ -1,11 +1,11 @@
 project(hedgewars)
 
 cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
-cmake_policy(SET CMP0003 NEW)
-
-IF(POLICY CMP0012)
-	cmake_policy(SET CMP0012 NEW)
-ENDIF()
+FOREACH(policy CMP0003 CMP0012)
+	IF(POLICY ${policy})
+		CMAKE_POLICY(SET ${policy} NEW)
+	ENDIF()
+ENDFOREACH()
 
 #detect Mercurial revision (if present)
 set(version_suffix "-dev") #UNSET THIS VARIABLE AT RELEASE TIME
@@ -53,6 +53,7 @@
 
 	#paths for creating the bundle
 	set(bundle_name Hedgewars.app)
+	set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
 	set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
 	set(DATA_INSTALL_DIR "../Resources/")
 	set(target_dir ".")
@@ -61,9 +62,8 @@
 	set(minimum_macosx $ENV{MACOSX_DEPLOYMENT_TARGET})
 
 	#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]+" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
+	EXEC_PROGRAM("/usr/bin/sw_vers" ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version)
+	STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
 
 	#if nothing is set, we deploy only for the current system
 	if(NOT minimum_macosx)
@@ -74,6 +74,7 @@
 		set(FATAL "Hedgewars is not supported for pre-10.4 systems")
 	endif()
 
+	#this variable needs to be set for frapascal universal binary
 	if(NOT CMAKE_OSX_ARCHITECTURES)
 		if(current_macosx_version MATCHES "10.6")
 			set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
--- a/cmake_modules/FindOggVorbis.cmake	Thu Apr 21 08:22:34 2011 +0200
+++ b/cmake_modules/FindOggVorbis.cmake	Sun Apr 24 21:35:23 2011 +0200
@@ -18,11 +18,14 @@
 
 include (CheckLibraryExists)
 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
-#  [koda] (for Hedgewars) added libraries with capital names for compatibility with Mac frameworks
 
 find_library(OGG_LIBRARY NAMES ogg)
 find_library(VORBIS_LIBRARY NAMES vorbis)
 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
+if(APPLE AND NOT VORBISFILE_LIBRARY)
+#  [koda] (for Hedgewars) frameworks don't come with libvorbisfile
+   set(VORBISFILE_LIBRARY "${VORBIS_LIBRARY}")
+endif()
 
 if (OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    set(OGGVORBIS_FOUND TRUE)
--- a/hedgewars/CMakeLists.txt	Thu Apr 21 08:22:34 2011 +0200
+++ b/hedgewars/CMakeLists.txt	Sun Apr 24 21:35:23 2011 +0200
@@ -127,7 +127,7 @@
     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}")
+    message(STATUS "Freepascal version installed: ${fpc_vers_major}.${fpc_vers_minor}")
     math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
 
     if(fpc_ver LESS "020200")
--- a/tools/CMakeLists.txt	Thu Apr 21 08:22:34 2011 +0200
+++ b/tools/CMakeLists.txt	Sun Apr 24 21:35:23 2011 +0200
@@ -1,10 +1,9 @@
 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)
@@ -16,32 +15,26 @@
 	find_package(SDL_mixer REQUIRED)
 	find_package(OGGVORBIS REQUIRED)
         if(NOT NOAUTOUPDATE)
-		find_package(SPARKLE)
-		if(SPARKLE_FOUND)
-			set(SPARKLE_FOUND 1)
-		else()
-			set(SPARKLE_FOUND 0)
-		endif()
+		#needed for SPARKLE_FOUND variable
+		find_package(Sparkle QUIET)
 	endif()
 
 	#use the associated tool from the libraries we've selected
 	string(REGEX REPLACE "(.*)/include.*" "\\1" qt_base_dir "${QT_INCLUDE_DIR}")
-	find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin NO_DEFAULT_PATH)
+
+	#remove the ";-framework Cocoa" from the SDL_LIBRARY variable
+	string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
 
 	#this tool is present in qt 4.5 but only if you compile from sources; from qt 4.6 is present also in the binary version
+	find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin NO_DEFAULT_PATH)
 	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 file
 	add_custom_target(bundle)
-
 	set_target_properties(bundle PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
 
-	set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
-
-	string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
+	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
+endif()
 
-	CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
-
-endif()