CMakeLists.txt
changeset 5053 a767954cfa03
parent 4904 0eab727d4717
child 5168 8a074a255af0
equal deleted inserted replaced
5052:74a81c276d67 5053:a767954cfa03
    37 
    37 
    38 set(CPACK_PACKAGE_VERSION_MAJOR "0")
    38 set(CPACK_PACKAGE_VERSION_MAJOR "0")
    39 set(CPACK_PACKAGE_VERSION_MINOR "9")
    39 set(CPACK_PACKAGE_VERSION_MINOR "9")
    40 set(CPACK_PACKAGE_VERSION_PATCH "16${version_suffix}")
    40 set(CPACK_PACKAGE_VERSION_PATCH "16${version_suffix}")
    41 
    41 
    42 #forbid in-tree building
       
    43 #IF (${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
       
    44 #	MESSAGE(STATUS "Please do an out-of-tree build:")
       
    45 #	MESSAGE(STATUS "rm CMakeCache.txt; mkdir build; cd build; cmake ..; make")
       
    46 #	MESSAGE(FATAL_ERROR "In-tree-build detected!")
       
    47 #ENDIF (${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
       
    48 
       
    49 #set some safe values
    42 #set some safe values
    50 IF(NOT WITH_SERVER)
    43 IF(NOT WITH_SERVER)
    51 	SET(WITH_SERVER 0)
    44 	SET(WITH_SERVER 0)
    52 ENDIF(NOT WITH_SERVER)
    45 ENDIF(NOT WITH_SERVER)
    53 IF(NOT BUILD_ENGINE_LIBRARY)
    46 IF(NOT BUILD_ENGINE_LIBRARY)
    70 	#detect on which system are we
    63 	#detect on which system are we
    71 	EXEC_PROGRAM("/usr/bin/sw_vers" OUTPUT_VARIABLE MACOSX_VERSION_TMP)
    64 	EXEC_PROGRAM("/usr/bin/sw_vers" OUTPUT_VARIABLE MACOSX_VERSION_TMP)
    72 	STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
    65 	STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
    73 	STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
    66 	STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
    74 
    67 
       
    68 	#if nothing is set, we deploy only for the current system
    75 	if(NOT minimum_macosx)
    69 	if(NOT minimum_macosx)
    76 		#if nothing is set, we deploy only for the current system
       
    77 		set(minimum_macosx ${current_macosx_version})
    70 		set(minimum_macosx ${current_macosx_version})
    78 	endif()
    71 	endif()
    79 
    72 
    80 	if (minimum_macosx LESS "10.4")
    73 	if (minimum_macosx LESS "10.4")
    81 		set(FATAL "Hedgewars is not supported for pre-10.4 systems")
    74 		set(FATAL "Hedgewars is not supported for pre-10.4 systems")
    82 	endif()
    75 	endif()
    83 
    76 
    84 	set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
    77 	if(NOT CMAKE_OSX_ARCHITECTURES)
    85 
    78 		if(current_macosx_version MATCHES "10.6")
    86 	#create universal binaries only when it's time to bundle the application, also build server
    79 			set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
    87 	IF(BUNDLE)
       
    88 		set(WITH_SERVER true)
       
    89 		if(NOT minimum_macosx MATCHES "10.6")
       
    90 			set(CMAKE_C_COMPILER "gcc-4.0")
       
    91 			set(CMAKE_CXX_COMPILER "g++-4.0")
       
    92 		else()
    80 		else()
    93 			if(current_macosx_version MATCHES "10.6")
    81 			set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
    94 				if(MACAPPSTORE)
       
    95 					set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
       
    96 				else()
       
    97 					set(CMAKE_OSX_ARCHITECTURES "x86_64")
       
    98 				endif()
       
    99 			endif()
       
   100 		endif()
    82 		endif()
   101 	ELSE()
    83 	endif()
   102 		if(current_macosx_version MATCHES "10.6")
    84 
   103 			set(CMAKE_OSX_ARCHITECTURES "x86_64")
    85 	message(STATUS "Build system: Mac OS X ${current_macosx_version} - Target ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
   104 		endif()
    86 
   105 	ENDIF()
    87 	#be sure to select ppc-compatible toolchains just in case
   106 
    88 	if(NOT minimum_macosx MATCHES "10.6")
   107 	message(STATUS "Target system: Mac OS X ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
    89 		set(CMAKE_C_COMPILER "gcc-4.0")
       
    90 		set(CMAKE_CXX_COMPILER "g++-4.0")
       
    91 	endif()
   108 
    92 
   109 	if(minimum_macosx MATCHES "10.4")
    93 	if(minimum_macosx MATCHES "10.4")
   110 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
    94 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
   111 		if(current_macosx_version MATCHES "10.4")
    95 		if(current_macosx_version MATCHES "10.4")
   112 			find_package(SDL_mixer REQUIRED)
    96 			find_package(SDL_mixer REQUIRED)
   127 	set(target_dir "bin")
   111 	set(target_dir "bin")
   128 endif(APPLE)
   112 endif(APPLE)
   129 
   113 
   130 
   114 
   131 #this snippet sets "Release" mode by default
   115 #this snippet sets "Release" mode by default
   132 #IF (NOT CMAKE_BUILD_TYPE)
       
   133 #	SET(CMAKE_BUILD_TYPE "Release")
       
   134 #ENDIF (NOT CMAKE_BUILD_TYPE)
       
   135 if (NOT CMAKE_BUILD_TYPE)
   116 if (NOT CMAKE_BUILD_TYPE)
   136 	set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
   117 	set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
   137 endif (NOT CMAKE_BUILD_TYPE)
   118 endif (NOT CMAKE_BUILD_TYPE)
   138 
   119 
   139 if(CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES "Release")
   120 if(CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES "Release")
   140 	message(STATUS "Building Release")
   121 	message(STATUS "Building Release")
   141 	set(Optz true)
   122 	set(Optz true)
   142 else()
   123 else()
   143 	message(STATUS "Building Debug")
   124 	message(STATUS "Building Debug")
   144 	#set(CMAKE_VERBOSE_MAKEFILE true)
       
   145 	set(Optz false)
   125 	set(Optz false)
   146 endif()
   126 endif()
   147 
   127 
   148 
   128 
   149 #set default flags values for all the project
   129 #set default flags values for all the project
   175 
   155 
   176 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
   156 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
   177 set(HEDGEWARS_PROTO_VER 38)
   157 set(HEDGEWARS_PROTO_VER 38)
   178 
   158 
   179 if(WITH_SERVER)
   159 if(WITH_SERVER)
   180 	message(STATUS "Server is going to be built! Make sure you have GHC installed")
   160 	find_program(ghc_executable ghc)
   181 	set(HAVE_NETSERVER true)
   161 
   182 	add_subdirectory(gameServer)
   162 	if(ghc_executable)
       
   163 		set(HAVE_NETSERVER true)
       
   164 		add_subdirectory(gameServer)
       
   165 	else()
       
   166 		message(STATUS "No GHC executable found, server will *not* be built")
       
   167 		set(HAVE_NETSERVER false)
       
   168 	endif()
   183 else(WITH_SERVER)
   169 else(WITH_SERVER)
   184 	set(HAVE_NETSERVER false)
   170 	set(HAVE_NETSERVER false)
   185 endif(WITH_SERVER)
   171 endif(WITH_SERVER)
   186 
   172 
   187 add_subdirectory(misc/liblua)
   173 add_subdirectory(misc/liblua)
   188 add_subdirectory(hedgewars)
   174 add_subdirectory(hedgewars)
   189 #add_subdirectory(misc/libopenalbridge)
   175 
   190 if(NOT BUILD_ENGINE_LIBRARY)
   176 if(NOT BUILD_ENGINE_LIBRARY)
   191 	add_subdirectory(bin)
   177 	add_subdirectory(bin)
   192 	add_subdirectory(QTfrontend)
   178 	add_subdirectory(QTfrontend)
   193 	add_subdirectory(share)
   179 	add_subdirectory(share)
   194 	add_subdirectory(tools)
   180 	add_subdirectory(tools)