[Tux4kids-commits] r468 - in tuxmath/trunk: . cmake-modules doc intl src

tholy-guest at alioth.debian.org tholy-guest at alioth.debian.org
Thu Apr 24 12:03:13 UTC 2008


Author: tholy-guest
Date: 2008-04-24 12:03:11 +0000 (Thu, 24 Apr 2008)
New Revision: 468

Added:
   tuxmath/trunk/cmake-modules/ConfigureChecks.cmake
   tuxmath/trunk/cmake-modules/ConfigureChecksIntl.cmake
   tuxmath/trunk/cmake-modules/FindICONV.cmake
   tuxmath/trunk/cmake-modules/MacroBoolTo01.cmake
Modified:
   tuxmath/trunk/CMakeLists.txt
   tuxmath/trunk/doc/INSTALL.txt
   tuxmath/trunk/intl/CMakeLists.txt
   tuxmath/trunk/src/CMakeLists.txt
Log:
Further work on supporting CMake builds, particularly internationalization.


Modified: tuxmath/trunk/CMakeLists.txt
===================================================================
--- tuxmath/trunk/CMakeLists.txt	2008-04-23 09:30:51 UTC (rev 467)
+++ tuxmath/trunk/CMakeLists.txt	2008-04-24 12:03:11 UTC (rev 468)
@@ -1,77 +1,110 @@
-project (tuxmath)
+# This file implements a build for TuxMath using CMake
+# License information can be found in doc/COPYING.txt
+#
+# Copyright 2008 by Timothy E. Holy
+#
+# This was based on many examples, but a particular debt is owed to
+# Peter Kümmel of the LyX project.
 
-set (TUXMATH_VERSION "1.6.1")
-set (TUXMATHADMIN_VERSION "0.1.1")
+project(TuxMath)
 
-## Allow loading of any tuxmath-specific CMake modules
-set(CMAKE_MODULE_PATH "${tuxmath_SOURCE_DIR}/cmake-modules")
+set(TUXMATH_VERSION "1.6.1")
+set(TUXMATHADMIN_VERSION "0.1.1")
+message("Building TuxMath version ${TUXMATH_VERSION}")
 
-if (UNIX AND NOT APPLE)
-  message("CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}")
-endif (UNIX AND NOT APPLE)
-message("TUXMATH_VERSION is ${TUXMATH_VERSION}")
+## Setting up CMake itself
+cmake_minimum_required(VERSION 2.4)
+set(CMAKE_MODULE_PATH "${TuxMath_SOURCE_DIR}/cmake-modules")
+message("CMP: ${CMAKE_MODULE_PATH}")
 
+## Decide on our build-type: installed or relocatable
+## Linux (& Windows?) would be installed, Mac relocatable
+## Someday we might supply a Linux relocatable package; this would be
+## specified by executing cmake -DTUXMATH_BUILD_TYPE=relocatable
+if (NOT TUXMATH_BUILD_TYPE)
+  if (APPLE)
+    set(TUXMATH_BUILD_TYPE relocatable)
+  else (APPLE)
+    set(TUXMATH_BUILD_TYPE installed)
+  endif (APPLE)
+endif (NOT TUXMATH_BUILD_TYPE)
+if (TUXMATH_BUILD_TYPE MATCHES installed)
+  message("The installation location is ${CMAKE_INSTALL_PREFIX}")
+endif (TUXMATH_BUILD_TYPE MATCHES installed)
+
 ## Define the extra paths
-set (DATA_TUXMATH ${tuxmath_SOURCE_DIR}/data)
-set (DOC_TUXMATH ${tuxmath_SOURCE_DIR}/doc)
-set (PO_TUXMATH ${tuxmath_SOURCE_DIR}/po)
+#set (DATA_TUXMATH ${tuxmath_SOURCE_DIR}/data)
+#set (DOC_TUXMATH ${tuxmath_SOURCE_DIR}/doc)
+#set (PO_TUXMATH ${tuxmath_SOURCE_DIR}/po)
 
-## Set up OS-specific path information
-set (EXTRA_INCLUDE)  # makes it blank
-set (EXTRA_SRC)      # makes it blank
+## Set up OS-specific path & build information
 if (APPLE)
-  set (MACOSX_BUNDLE_NAME tuxmath)
-  set(DATA_PREFIX ${MACOSX_BUNDLE_NAME}.app/Contents/Resources)
-  set(LOCALEDIR ${MACOSX_BUNDLE_NAME}.app/Contents/Resources/locale)
-  # OS X does not have a pre-built libSDLmain, so we instead include
-  # SDLmain.m as a source file
-  set (EXTRA_INCLUDE ${tuxmath_SOURCE_DIR}/macosx)
-  set (EXTRA_SRC ${tuxmath_SOURCE_DIR}/macosx/SDLMain.m)
+  set(TUXMATH_MACOSX_BUNDLE_NAME ${PROJECT_NAME})
+  set(TUXMATH_DATA_PREFIX ${TUXMATH_MACOSX_BUNDLE_NAME}.app/Contents/Resources)
+  set(LOCALE_DIR ${TUXMATH_MACOSX_BUNDLE_NAME}.app/Contents/Resources/locale)
+  # OS X SDL Framework does not have a pre-built libSDLmain, so we
+  # instead include SDLmain.m as a source file
+  set (TUXMATH_EXTRA_INCLUDE ${tuxmath_SOURCE_DIR}/macosx)
+  set (TUXMATH_EXTRA_SRC ${tuxmath_SOURCE_DIR}/macosx/SDLMain.m)
 elseif (UNIX)
   # A non-apple Unix (Linux, Solaris, etc.)
-  set (DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/tuxmath)
-  set (LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
+  # This is where one would test for installed/relocatable, if that
+  # choice is implemented.  For now we just provide installed.
+  set (TUXMATH_DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/tuxmath)
+  set (LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
 endif (APPLE)
 
-## Code for internationalization: if we don't have gettext, we need to
-## compile the intl library.  In some cases, we will need to compile
-## the intl library even if we have gettext---we might not be able to
-## count on the installed system having it, even if the development
-## system does.
-include (CheckSymbolExists)
-check_symbol_exists (gettext libintl.h HAVE_GETTEXT)
-find_package (MSGFMT)
-#message("MSGFMT_FOUND ${MSGFMT_FOUND}    MSGFMT_EXECUTABLE ${MSGFMT_EXECUTABLE}")
-set (BUILD_INTL FALSE)
-if (DEFINED HAVE_GETTEXT)
-  set (BUILD_INTL TRUE)
-endif (DEFINED HAVE_GETTEXT)
-if (NOT MSGFMT_FOUND)
-  message("Warning: internationalization disabled")
-endif (NOT MSGFMT_FOUND)
-message("HAVE_GETTEXT ${HAVE_GETTEXT}   BUILD_INTL ${BUILD_INTL}")
-if (APPLE)
-  set (BUILD_INTL TRUE)
-endif (APPLE)
-message("HAVE_GETTEXT ${HAVE_GETTEXT}   BUILD_INTL ${BUILD_INTL}")
+## Decide on whether we're going to build with internationalization
+# We can't build with internationalization unless the build computer
+# supports msgfmt
+find_package(MSGFMT)
+if (NOT DEFINED TUXMATH_NLS OR NOT MSGFMT_FOUND)
+  # You can disable NLS with -DTUXMATH_NLS=false
+  set(TUXMATH_NLS ${MSGFMT_FOUND})
+endif (NOT DEFINED TUXMATH_NLS OR NOT MSGFMT_FOUND)
+if (NOT TUXMATH_NLS)
+  message("Internationalization disabled")
+endif (NOT TUXMATH_NLS)
+# Even if the build computer supports gettext/msgfmt, we may not be
+# able to guarantee that the computers on which it is installed provides
+# runtime support for gettext.  So we may have to build gettext.
+if (TUXMATH_NLS)
+  if (APPLE)
+    set(TUXMATH_BUILD_INTL true)
+  endif (APPLE)
+else (TUXMATH_NLS)
+  set(TUXMATH_BUILD_INTL false)  # No point in building intl if no NLS
+endif (TUXMATH_NLS)
 
+
+## Run configure checks
+if (TUXMATH_BUILD_INTL)
+  include(ConfigureChecksIntl)
+endif (TUXMATH_BUILD_INTL)
+include(ConfigureChecks)
+
 ## Add subdirectories
-add_subdirectory (src)
-add_subdirectory (data)
-add_subdirectory (doc)
-if (MSGFMT_FOUND)
-  add_subdirectory (po)
-endif (MSGFMT_FOUND)
-if (BUILD_INTL)
-  add_subdirectory (intl)
-endif (BUILD_INTL)
+add_subdirectory(src)
+add_subdirectory(data)
+add_subdirectory(doc)
+if (TUXMATH_NLS)
+  add_subdirectory(po)
+endif (TUXMATH_NLS)
+if (TUXMATH_BUILD_INTL)
+  set(INTL_BINARY_DIR ${CMAKE_BINARY_DIR}/intl)
+  set(INTL_SOURCE_DIR ${CMAKE_SOURCE_DIR}/intl)
+  set(TOP_SRC_DIR ${CMAKE_BINARY_DIR})
+  set(PREFIX ${CMAKE_BINARY_DIR})
+  add_subdirectory(intl)
+endif (TUXMATH_BUILD_INTL)
 
+## Copy any needed libraries to the installation target
 if (APPLE)
   macro (copyFramework headerDir destDir)
     string(REPLACE "/Headers" "" FRAMEWORK_SOURCE_DIR ${headerDir})
     install(DIRECTORY ${FRAMEWORK_SOURCE_DIR} DESTINATION ${destDir})
   endmacro(copyFramework)
-  set(FRAMEWORK_DEST_DIR ${tuxmath_BINARY_DIR}/src/${MACOSX_BUNDLE_NAME}.app/Contents/Frameworks)
+  set(FRAMEWORK_DEST_DIR ${tuxmath_BINARY_DIR}/src/${TUXMATH_MACOSX_BUNDLE_NAME}.app/Contents/Frameworks)
   copyFramework(${SDL_INCLUDE_DIR} ${FRAMEWORK_DEST_DIR})
   copyFramework(${SDLMIXER_INCLUDE_DIR} ${FRAMEWORK_DEST_DIR})
   copyFramework(${SDLIMAGE_INCLUDE_DIR} ${FRAMEWORK_DEST_DIR})

Added: tuxmath/trunk/cmake-modules/ConfigureChecks.cmake
===================================================================
--- tuxmath/trunk/cmake-modules/ConfigureChecks.cmake	                        (rev 0)
+++ tuxmath/trunk/cmake-modules/ConfigureChecks.cmake	2008-04-24 12:03:11 UTC (rev 468)
@@ -0,0 +1,6 @@
+include(CheckIncludeFile)
+include(CheckSymbolExists)
+
+check_symbol_exists(scandir dirent.h HAVE_SCANDIR)
+check_include_file (error.h HAVE_ERROR_H)
+

Added: tuxmath/trunk/cmake-modules/ConfigureChecksIntl.cmake
===================================================================
--- tuxmath/trunk/cmake-modules/ConfigureChecksIntl.cmake	                        (rev 0)
+++ tuxmath/trunk/cmake-modules/ConfigureChecksIntl.cmake	2008-04-24 12:03:11 UTC (rev 468)
@@ -0,0 +1,45 @@
+if (NOT INTL_CHECKS_DONE)
+  include(CheckIncludeFiles)
+  include(CheckSymbolExists)
+  include(CheckCSourceCompiles)
+  include(CheckTypeSize)
+  include(MacroBoolTo01)
+
+  #message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+  #set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} /usr/include)
+  #message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+  
+  #check_include_files(sys/types.h HAVE_SYS_TYPES_H)
+  #check_include_files(inttypes.h HAVE_INTTYPES_H)
+  #check_include_files(stdint.h HAVE_STDINT_H)
+  #check_include_files(stddef.h HAVE_STDDEF_H)
+  
+  check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
+  check_symbol_exists(asprintf "stdio.h" HAVE_ASPRINTF)
+  check_symbol_exists(wprintf "stdio.h" HAVE_WPRINTF)
+  check_symbol_exists(printf "stdio.h" HAVE_POSIX_PRINTF)
+
+  # Alternate for HAVE_POSIX_PRINTF: which is right?
+  check_c_source_compiles("
+  #include <stdio.h>
+  #include <string.h>
+  static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
+  static char buf[100];
+  int main ()
+  {
+    sprintf (buf, format, 33, 55);
+  }" HAVE_POSIX_PRINTF)
+
+
+  check_symbol_exists(intmax_t "inttypes.h" HAVE_INTTYPES_H_WITH_UINTMAX)
+  check_symbol_exists(intmax_t "stdint.h" HAVE_INTTYPES_H_WITH_UINTMAX)
+  check_symbol_exists(uintmax_t "stdint.h" HAVE_STDINT_H_WITH_UINTMAX)
+  check_symbol_exists(LC_MESSAGES "locale.h" HAVE_LC_MESSAGES)
+  check_symbol_exists(fcntl "stdio.h" HAVE_FCNTL)
+
+  check_type_size(intmax_t INTMAX_T)
+  message("HIT ${HAVE_INTMAX_T}, IT ${INTMAX_T}")
+  macro_bool_to_01(HAVE_STDINT_H_WITH_UINTMAX HAVE_UINTMAX_T)
+
+  set(INTL_CHECKS_DONE TRUE)
+endif (NOT INTL_CHECKS_DONE)

Added: tuxmath/trunk/cmake-modules/FindICONV.cmake
===================================================================
--- tuxmath/trunk/cmake-modules/FindICONV.cmake	                        (rev 0)
+++ tuxmath/trunk/cmake-modules/FindICONV.cmake	2008-04-24 12:03:11 UTC (rev 468)
@@ -0,0 +1,99 @@
+#
+#  Copyright (c) 2006, Peter K�mmel, <syntheticpp at gmx.net>
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  
+#  1. Redistributions of source code must retain the copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products 
+#     derived from this software without specific prior written permission.
+#  
+#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+#  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+#  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+#  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+#  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#  
+
+set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+if (ICONV_INCLUDE_DIR)
+  # Already in cache, be silent
+  set(ICONV_FIND_QUIETLY TRUE)
+endif()
+
+find_path(ICONV_INCLUDE_DIR iconv.h
+ /usr/include
+ /usr/local/include)
+
+set(POTENTIAL_ICONV_LIBS iconv libiconv libiconv2)
+
+find_library(ICONV_LIBRARY NAMES ${POTENTIAL_ICONV_LIBS}
+	PATHS /usr/lib /usr/local/lib)
+
+if(WIN32)
+	set(ICONV_DLL_NAMES iconv.dll  libiconv.dll libiconv2.dll)
+	find_file(ICONV_DLL   
+					NAMES ${ICONV_DLL_NAMES}
+					PATHS ENV PATH
+					NO_DEFAULT_PATH)
+	find_file(ICONV_DLL_HELP   
+					NAMES ${ICONV_DLL_NAMES}
+					PATHS ENV PATH
+					${ICONV_INCLUDE_DIR}/../bin)
+	if(ICONV_FIND_REQUIRED)
+		if(NOT ICONV_DLL AND NOT ICONV_DLL_HELP)
+			message(FATAL_ERROR "Could not find iconv.dll, please add correct your PATH environment variable")
+		endif()
+		if(NOT ICONV_DLL AND ICONV_DLL_HELP)
+			get_filename_component(ICONV_DLL_HELP ${ICONV_DLL_HELP} PATH)
+			message(STATUS)
+			message(STATUS "Could not find iconv.dll in standard search path, please add ")
+			message(STATUS "${ICONV_DLL_HELP}")
+			message(STATUS "to your PATH environment variable.")
+			message(STATUS)
+			message(FATAL_ERROR "exit cmake")
+		endif()
+	endif()
+	if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY AND ICONV_DLL)
+   		set(ICONV_FOUND TRUE)
+	endif()
+else()
+	check_function_exists(iconv HAVE_ICONV_IN_LIBC)
+	if(ICONV_INCLUDE_DIR AND HAVE_ICONV_IN_LIBC)
+   		set(ICONV_FOUND TRUE)
+		set(ICONV_LIBRARY  CACHE TYPE STRING FORCE)
+	endif()
+	if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
+   		set(ICONV_FOUND TRUE)
+	endif()
+endif()
+
+
+
+if(ICONV_FOUND)
+   if(NOT ICONV_FIND_QUIETLY)
+      message(STATUS "Found iconv library: ${ICONV_LIBRARY}")
+      #message(STATUS "Found iconv   dll  : ${ICONV_DLL}")
+   endif()
+else()
+   if(ICONV_FIND_REQUIRED)
+      message(STATUS "Looked for iconv library named ${POTENTIAL_ICONV_LIBS}.")
+      message(STATUS "Found no acceptable iconv library. This is fatal.")
+      message(STATUS "iconv header: ${ICONV_INCLUDE_DIR}")
+      message(STATUS "iconv lib   : ${ICONV_LIBRARY}")
+      message(FATAL_ERROR "Could NOT find iconv library")
+   endif()
+endif()
+
+mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR)

Added: tuxmath/trunk/cmake-modules/MacroBoolTo01.cmake
===================================================================
--- tuxmath/trunk/cmake-modules/MacroBoolTo01.cmake	                        (rev 0)
+++ tuxmath/trunk/cmake-modules/MacroBoolTo01.cmake	2008-04-24 12:03:11 UTC (rev 468)
@@ -0,0 +1,20 @@
+# MACRO_BOOL_TO_01( VAR RESULT0 ... RESULTN )
+# This macro evaluates its first argument
+# and sets all the given vaiables either to 0 or 1
+# depending on the value of the first one
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf at kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+MACRO(MACRO_BOOL_TO_01 FOUND_VAR )
+   FOREACH (_current_VAR ${ARGN})
+      IF(${FOUND_VAR})
+         SET(${_current_VAR} 1)
+      ELSE(${FOUND_VAR})
+         SET(${_current_VAR} 0)
+      ENDIF(${FOUND_VAR})
+   ENDFOREACH(_current_VAR)
+ENDMACRO(MACRO_BOOL_TO_01)

Modified: tuxmath/trunk/doc/INSTALL.txt
===================================================================
--- tuxmath/trunk/doc/INSTALL.txt	2008-04-23 09:30:51 UTC (rev 467)
+++ tuxmath/trunk/doc/INSTALL.txt	2008-04-24 12:03:11 UTC (rev 468)
@@ -135,6 +135,16 @@
 
 Compiling and Installing TuxMath
 --------------------------------
+
+Note: there are now two ways to build tuxmath from source.  The first
+(and main method) is using autotools ("./configure && make && make
+install").  The second is to use CMake.  CMake is being explored as a
+possible way to better-support MacOSX.  However, the CMake build is
+currently having some troubles with the internationalization code, and
+requires a cheat (running configure, copying a file, and then running
+CMake).  Further details are below.
+
+
   Linux/Unix
   ----------
     Compiling the Program
@@ -149,11 +159,11 @@
 
       The svn repository is located at:
 
-        http://svn.debian.org/wsvn/tux4kids/tuxmath 
+        http://svn.debian.org/wsvn/tux4kids/tuxmath 
 
-        or:
+      or:
 
-        svn://svn.debian.org/tux4kids/tuxmath
+        svn://svn.debian.org/tux4kids/tuxmath
 
       If you are using a source tar.gz package (e.g. tuxmath_w_fonts-1.6.1-tar.gz),
       all you need to do is unpack the archive in a convient location and
@@ -308,3 +318,36 @@
      Currently, internationalization is disabled on MacOSX.
      Anyone who knows how to get the Linux internationalization
      framework working on MacOSX is invited to contribute.
+
+CMake
+-----
+
+There is also a set of scripts to build TuxMath using CMake. CMake has
+some potential advantages in terms of cross-platform support: in
+particular, supporting the SDL Frameworks on Mac OSX and producing a
+viable universal binary .dmg file appears to be easier using XCode or
+CMake than it is using repositories like fink or macports.  Another
+potential advantage (depending on one's perspective) is that CMake can
+produce project files for many different IDEs on many different
+platforms, facilitating development on diverse platforms.
+
+With the exception of internationalization, it was fairly
+straightforward to set up the CMake build.  However,
+internationalization is proving to be very troublesome.  For that
+reason, the CMake build currently requires a cheat: using the config.h
+file produced by autotools.
+
+Starting from tuxmath's trunk directory, do the following:
+mkdir build-cmake
+mkdir build-autotools
+cd build-autotools
+autoreconf --install ../trunk
+cd ../build-cmake
+cmake ../trunk
+cp ../build-autotools/config.h ./src/
+cp ../build-autotools/config.h ./intl/
+make
+
+Then you can do a
+make install
+if you want to install.  A "make dmg" command will appear shortly (I hope).

Modified: tuxmath/trunk/intl/CMakeLists.txt
===================================================================
--- tuxmath/trunk/intl/CMakeLists.txt	2008-04-23 09:30:51 UTC (rev 467)
+++ tuxmath/trunk/intl/CMakeLists.txt	2008-04-24 12:03:11 UTC (rev 468)
@@ -1,5 +1,7 @@
 # Build script for libintl. This was copied, with only slight
-# modifications, from the LyX project---thanks!
+# modifications, from the LyX project---thanks!  See attribution below.
+#
+# Modifications by Timothy E. Holy, 2008
 
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
@@ -7,13 +9,45 @@
 # Copyright (c) 2006, Peter Kümmel, <syntheticpp at gmx.net>
 #
 
-project(intl) 
+# If you're building this as part of a larger package, the following
+# variables can be set upon entry:
+#   INTL_BINARY_DIR
+#   INTL_SOURCE_DIR
+#   LOCALE_DIR
+#   TOP_SRC_DIR  ?
+#   PREFIX    ?
 
-# libgnuintl.h.in => libintl.h
-configure_file(libgnuintl.h ${CMAKE_CURRENT_BINARY_DIR}/libgnuintl.h COPYONLY)
-configure_file(libgnuintl.h ${CMAKE_CURRENT_BINARY_DIR}/libintl.h COPYONLY)
+project(intl)
 
+#set(CMAKE_MODULE_PATH "/home/tim/src/tux4kids/tuxmath/trunk/cmake-modules")
+include(CheckFunctionExists)
 
+# We require the iconv library to be available
+find_package(ICONV REQUIRED)
+add_definitions(-DHAVE_ICONV=1)
+
+# This can either be called in standalone mode, or as part of a larger
+# project.  For that reason, we need to examine whether certain settings
+# have been made before, or not.
+if (NOT CONFIGURECHECKSINTL_DONE)
+  include(ConfigureChecksIntl)
+endif ()
+if (NOT INTL_BINARY_DIR)
+  set(INTL_BINARY_DIR ${CMAKE_BINARY_DIR})
+endif ()
+if (NOT INTL_SOURCE_DIR)
+  set(INTL_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+endif ()
+
+# Generate the appropriate header files
+configure_file(libgnuintl.h.in ${INTL_BINARY_DIR}/libgnuintl.h)
+configure_file(${INTL_BINARY_DIR}/libgnuintl.h ${INTL_BINARY_DIR}/libintl.h COPYONLY)
+# Generate the appropriate config.h file
+#configure_file(intl_config.h.cmake ${INTL_BINARY_DIR}/config.h)
+# For the moment, this doesn't work: you have to run automake's
+# "configure" and then copy config.h into the build directory
+check_include_file(config.h HAVE_CONFIG_H REQUIRED)
+
 add_definitions(
     -DHAVE_CONFIG_H=1
     -DMAKE_INTL_LIB
@@ -28,8 +62,8 @@
     
 if (NOT APPLE)    
 add_definitions(
-		-DLOCALEDIR=\\"${LOACLE_DIR}\\" 
-		-DLOCALE_ALIAS_PATH=\\"${LOACLE_DIR}\\"
+		-DLOCALEDIR=\\"${LOCALE_DIR}\\" 
+		-DLOCALE_ALIAS_PATH=\\"${LOCALE_DIR}\\"
 		-DLIBDIR=\\"${TOP_SRC_DIR}\\"
 		-DINSTALLDIR=\\"${PREFIX}\\" 
 		)
@@ -42,7 +76,7 @@
 		)
 endif (NOT APPLE)
 
-file(GLOB intl_headers ${TOP_SRC_DIR}/intl/*.h)
+file(GLOB intl_headers ${INTL_SOURCE_DIR}/*.h)
 
 set(intl_sources 
       bindtextdom.c
@@ -70,19 +104,19 @@
       intl-compat.c
 )
 
-lyx_add_path(intl_sources ${TOP_SRC_DIR}/intl)
+#lyx_add_path(intl_sources ${TOP_SRC_DIR}/intl)
 
-include_directories(${TOP_SRC_DIR}/intl ${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${INTL_BINARY_DIR} ${INTL_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 
 if(ICONV_FOUND)
-	include_directories(${ICONV_INCLUDE_DIR})
+  include_directories(${ICONV_INCLUDE_DIR})
 endif(ICONV_FOUND)
 
 add_library(intl STATIC ${intl_sources} ${intl_headers})
 
 if(ICONV_FOUND)
-	target_link_libraries(intl ${ICONV_LIBRARY})
+  target_link_libraries(intl ${ICONV_LIBRARY})
 endif(ICONV_FOUND)
 
-project_source_group("${GROUP_CODE}" intl_sources intl_headers)
+#project_source_group("${GROUP_CODE}" intl_sources intl_headers)
 

Modified: tuxmath/trunk/src/CMakeLists.txt
===================================================================
--- tuxmath/trunk/src/CMakeLists.txt	2008-04-23 09:30:51 UTC (rev 467)
+++ tuxmath/trunk/src/CMakeLists.txt	2008-04-24 12:03:11 UTC (rev 468)
@@ -3,7 +3,7 @@
 
 ## Define the source files used for each executable
 # tuxmath
-set (SOURCES_TUXMATH
+set(SOURCES_TUXMATH
   audio.c
   ConvertUTF.c
   credits.c
@@ -23,29 +23,22 @@
   )
 
 # tuxmathadmin
-set (SOURCES_TUXMATHADMIN
+set(SOURCES_TUXMATHADMIN
   tuxmathadmin.c
   )
 
 ## Libraries
-find_package (SDL REQUIRED)
-find_package (SDL_image REQUIRED)
-find_package (SDL_ttf REQUIRED)
-find_package (SDL_mixer REQUIRED)
+find_package(SDL REQUIRED)
+find_package(SDL_image REQUIRED)
+find_package(SDL_ttf REQUIRED)
+find_package(SDL_mixer REQUIRED)
 
 if (NOT SDL_FOUND)
   # Workaround for REQUIRED flag not working with cmake < 2.4.7.
   # Should put other libraries in, too.
-  message (FATAL_ERROR "SDL not found!")
+  message(FATAL_ERROR "SDL not found!")
 endif (NOT SDL_FOUND)
 
-
-# Other library functionality
-check_symbol_exists(scandir dirent.h HAVE_SCANDIR)
-
-include (CheckIncludeFile)
-check_include_file (error.h HAVE_ERROR_H)
-
 link_libraries (
   ${SDL_LIBRARY}
   ${SDLIMAGE_LIBRARY}
@@ -58,7 +51,10 @@
 endif (NOT APPLE)
 
 ## Include files
-configure_file(${tuxmath_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+#configure_file(${TuxMath_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+# For the moment, this doesn't work: you have to run automake's
+# "configure" and then copy config.h into the build directory
+check_include_file(config.h HAVE_CONFIG_H REQUIRED)
 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR} ${EXTRA_INCLUDES})
 
 ## OSX
@@ -83,7 +79,7 @@
 set_target_properties (
   tuxmath
   PROPERTIES COMPILE_FLAGS 
-  "-DDATA_PREFIX=\\\"${DATA_PREFIX}\\\" -DVERSION=\\\"${TUXMATH_VERSION}\\\" -DLOCALEDIR=\\\"${LOCALEDIR}\\\" -DPACKAGE=\\\"tuxmath\\\""
+  "-DDATA_PREFIX=\\\"${DATA_PREFIX}\\\" -DVERSION=\\\"${TUXMATH_VERSION}\\\" -DLOCALEDIR=\\\"${LOCALE_DIR}\\\" -DPACKAGE=\\\"tuxmath\\\""
   )
 
 if (APPLE)
@@ -96,7 +92,7 @@
 set_target_properties (
   tuxmathadmin
   PROPERTIES COMPILE_FLAGS 
-  "-DDATA_PREFIX=\\\"${DATA_PREFIX}\\\" -DVERSION=\\\"${TUXMATHADMIN_VERSION}\\\" -DLOCALEDIR=\\\"${LOCALEDIR}\\\" -DPACKAGE=\\\"tuxmathadmin\\\""
+  "-DDATA_PREFIX=\\\"${DATA_PREFIX}\\\" -DVERSION=\\\"${TUXMATHADMIN_VERSION}\\\" -DLOCALEDIR=\\\"${LOCALE_DIR}\\\" -DPACKAGE=\\\"tuxmathadmin\\\""
   )
 
 ## Installation specifications




More information about the Tux4kids-commits mailing list