r18737 - gnucash/trunk/src - Make CMake system more complete so that it builds on win32/mingw.

Christian Stimming cstim at code.gnucash.org
Thu Feb 25 12:42:21 EST 2010


Author: cstim
Date: 2010-02-25 12:42:21 -0500 (Thu, 25 Feb 2010)
New Revision: 18737
Trac: http://svn.gnucash.org/trac/changeset/18737

Added:
   gnucash/trunk/src/test-core/CMakeLists.txt
   gnucash/trunk/src/test-core/test-main.c
Modified:
   gnucash/trunk/src/CMakeLists.txt
   gnucash/trunk/src/core-utils/CMakeLists.txt
   gnucash/trunk/src/engine/CMakeLists.txt
   gnucash/trunk/src/gnc-module/CMakeLists.txt
   gnucash/trunk/src/libqof/CMakeLists.txt
Log:
Make CMake system more complete so that it builds on win32/mingw.

Also, add a test executable to check that we got all the
library dependencies.

Modified: gnucash/trunk/src/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/CMakeLists.txt	2010-02-25 17:42:00 UTC (rev 18736)
+++ gnucash/trunk/src/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -17,37 +17,40 @@
 # Find pkg-config
 FIND_PACKAGE (PkgConfig REQUIRED)
 
+IF (NOT PKG_CONFIG_FOUND)
+   MESSAGE (SEND_ERROR "pkg-config not found, but is required")
+ENDIF (NOT PKG_CONFIG_FOUND)
+
 # glib
-PKG_CHECK_MODULES (GLIB2 glib-2.0>=2.12.0)
+PKG_CHECK_MODULES (GLIB2 glib-2.0>=2.20.0)
 PKG_CHECK_MODULES (GCONF2 gconf-2.0>=2.0)
+PKG_CHECK_MODULES (GOBJECT gobject-2.0>=2.20.0)
+PKG_CHECK_MODULES (GMODULE gmodule-2.0>=2.20.0)
+PKG_CHECK_MODULES (GTHREAD gthread-2.0>=2.20.0)
 
 IF (NOT GLIB2_FOUND)
-   MESSAGE (SEND_ERROR "Gtk not found, but is required")
+   MESSAGE (SEND_ERROR "Glib2 not found, but is required")
 ENDIF (NOT GLIB2_FOUND)
 
 FIND_PATH (LIBINTL_INCLUDE_PATH NAMES libintl.h
 		  PATHS /usr/include /opt/gnome/include)
+FIND_LIBRARY (LIBINTL_LIBRARY NAMES intl)
 FIND_PATH (REGEX_INCLUDE_PATH NAMES regex.h
 		  PATHS /usr/include /opt/gnome/include)
+FIND_LIBRARY (REGEX_LIBRARY NAMES regex)
 
 # ############################################################
 
+# SWIG
 FIND_PACKAGE (SWIG REQUIRED)
 INCLUDE (${SWIG_USE_FILE})
 
-#FIND_PACKAGE (GUILE REQUIRED)
+# guile
+FIND_PATH (LIBGUILE_INCLUDE_PATH NAMES libguile.h
+		  PATHS /usr/include)
+FIND_LIBRARY (LIBGUILE_LIBRARIES NAMES guile)
+FIND_PROGRAM (GUILE_EXECUTABLE guile)
 
-# Command to generate the swig-runtime.h header
-SET (SWIG_RUNTIME_H ${CMAKE_BINARY_DIR}/swig-runtime.h)
-ADD_CUSTOM_COMMAND (
-  OUTPUT ${SWIG_RUNTIME_H}
-  DEPENDS ${CMAKE_SOURCE_DIR}/CMakeLists.txt
-  COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H}
-)
-
-# Add a custom target to drive the custom command.
-ADD_CUSTOM_TARGET (swig-runtime-h ALL DEPENDS ${SWIG_RUNTIME_H})
-
 # ############################################################
 
 #SET (QT_MIN_VERSION "4.5.0") # We need at least 4.5.0 (because only this is LGPL)
@@ -57,75 +60,71 @@
 IF (UNIX)
   SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wdeclaration-after-statement -Wno-pointer-sign -D_FORTIFY_SOURCE=2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -Wno-unused")
 ENDIF (UNIX)
+IF (MINGW)
+  SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wdeclaration-after-statement -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -Wno-unused")
+ENDIF (MINGW)
 
 # ############################################################
 
+# Create config.h
 ADD_DEFINITIONS (-DHAVE_CONFIG_H)
 
-# Create config.h
-SET (CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+SET (CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/config.h.tmp)
 FILE (WRITE ${CONFIG_H} "#define PACKAGE \"gnucash\"\n")
+
+FILE (APPEND ${CONFIG_H} "
+#define GNUCASH_MAJOR_VERSION 2
+#define GNUCASH_MICRO_VERSION 10
+#define GNUCASH_MINOR_VERSION 3
+#define VERSION "2.3.10"
+
+/* Definitions for all OS */
+#define HAVE_LIBQOF /**/
+#define QOF_DISABLE_DEPRECATED 1
+")
+
 IF (WIN32)
-  FILE (APPEND ${CONFIG_H} "#define HAVE_SCANF_I64D 1\n")
+  FILE (APPEND ${CONFIG_H} "
+#define HAVE_SCANF_I64D 1
+#define HAVE_HTMLHELPW 1
+#define OS_WIN32 1
+")
 ENDIF (WIN32)
-IF (UNIX)
-  FILE (APPEND ${CONFIG_H} "#define HAVE_SCANF_LLD 1\n")
-ENDIF (UNIX)
-IF (UNIX OR MINGW)
-  FILE (APPEND ${CONFIG_H} "#define HAVE_SYS_TIME_H 1\n")
-  FILE (APPEND ${CONFIG_H} "#define HAVE_UNISTD_H 1\n")
-  FILE (APPEND ${CONFIG_H} "#define HAVE_DIRENT_H 1\n")
-ENDIF (UNIX OR MINGW)
 
-IF (UNIX)
+IF (MINGW)
   FILE (APPEND ${CONFIG_H} "
+#define HAVE_PUTENV 1
+")
+ENDIF (MINGW)
+
+IF (UNIX OR MINGW)
+  FILE (APPEND ${CONFIG_H} "
+#define GETTEXT_PACKAGE \"gnucash\"
 #define HAVE_BIND_TEXTDOMAIN_CODESET 1
-#define HAVE_CHOWN 1
+#define HAVE_DIRENT_H 1
 #define HAVE_DCGETTEXT 1
-#define HAVE_DLERROR 1
-#define HAVE_DLFCN_H 1
-#define HAVE_GETHOSTID 1
-#define HAVE_GETHOSTNAME 1
-#define HAVE_GETPPID 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_UNISTD_H 1
 #define HAVE_GETTEXT 1
 #define HAVE_GETTIMEOFDAY 1
-#define HAVE_GETUID 1
-#define HAVE_GMTIME_R 1
+#define HAVE_GUILE 1
 #define HAVE_INTTYPES_H 1
-#define HAVE_LANGINFO_D_FMT 1
-#define HAVE_LC_MESSAGES 1
 #define HAVE_LIBM 1
-#define HAVE_LIBPTHREAD 1
-#define HAVE_LIBQOF /**/
 #define HAVE_LIMITS_H 1
-#define HAVE_LINK 1
 #define HAVE_LOCALE_H 1
-#define HAVE_LOCALTIME_R 1
 #define HAVE_MEMCPY 1
 #define HAVE_MEMORY_H 1
-#define HAVE_PTHREAD_MUTEX_INIT 1
-#define HAVE_SETENV 1
 #define HAVE_STDINT_H 1
 #define HAVE_STDLIB_H 1
-#define HAVE_STPCPY 1
 #define HAVE_STRINGS_H 1
 #define HAVE_STRING_H 1
-#define HAVE_STRPTIME 1
-#define HAVE_STRUCT_TM_GMTOFF 1
 #define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIMES_H 1
 #define HAVE_SYS_TIME_H 1
 #define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_WAIT_H 1
-#define HAVE_TIMEGM 1
 #define HAVE_TOWUPPER 1
 #define HAVE_UNISTD_H 1
-#define HAVE_UTMP_H 1
 #define HAVE_WCTYPE_H 1
-#define HAVE_X11_XLIB_H 1
 
-/* Don't use deprecated qof functions */
-#define QOF_DISABLE_DEPRECATED 1
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
@@ -150,11 +149,6 @@
 # define __EXTENSIONS__ 1
 #endif
 
-/* Version number of package */
-#define VERSION "2.3.10"
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel). */
 #if defined AC_APPLE_UNIVERSAL_BUILD
 # if defined __BIG_ENDIAN__
 #  define WORDS_BIGENDIAN 1
@@ -165,25 +159,46 @@
 # endif
 #endif
 ")
+ENDIF (UNIX OR MINGW)
+
+IF (UNIX)
+  FILE (APPEND ${CONFIG_H} "
+#define HAVE_CHOWN 1
+#define HAVE_DLERROR 1
+#define HAVE_DLFCN_H 1
+#define HAVE_GETHOSTID 1
+#define HAVE_GETHOSTNAME 1
+#define HAVE_GETPPID 1
+#define HAVE_GETUID 1
+#define HAVE_GMTIME_R 1
+#define HAVE_LANGINFO_D_FMT 1
+#define HAVE_LC_MESSAGES 1
+#define HAVE_LIBPTHREAD 1
+#define HAVE_LINK 1
+#define HAVE_LOCALTIME_R 1
+#define HAVE_PTHREAD_MUTEX_INIT 1
+#define HAVE_SCANF_LLD 1
+#define HAVE_SETENV 1
+#define HAVE_STPCPY 1
+#define HAVE_STRPTIME 1
+#define HAVE_STRUCT_TM_GMTOFF 1
+#define HAVE_SYS_TIMES_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_TIMEGM 1
+#define HAVE_UTMP_H 1
+#define HAVE_X11_XLIB_H 1
+")
 ENDIF (UNIX)
 
+# Let cmake copy the created file only on changes.
+CONFIGURE_FILE (${CONFIG_H} ${CMAKE_CURRENT_BINARY_DIR}/config.h COPYONLY)
 
-FILE (APPEND ${CONFIG_H} "
-/* GnuCash Major version number */
-#define GNUCASH_MAJOR_VERSION 2
-
-/* GnuCash Micro version number */
-#define GNUCASH_MICRO_VERSION 10
-
-/* GnuCash Minor version number */
-#define GNUCASH_MINOR_VERSION 3
-")
-
 # ############################################################
 
 # The subdirectories
-#ADD_SUBDIRECTORY (libqof)
+ADD_SUBDIRECTORY (libqof)
 ADD_SUBDIRECTORY (core-utils)
 ADD_SUBDIRECTORY (gnc-module)
 ADD_SUBDIRECTORY (engine)
 
+ADD_SUBDIRECTORY (test-core)

Modified: gnucash/trunk/src/core-utils/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/core-utils/CMakeLists.txt	2010-02-25 17:42:00 UTC (rev 18736)
+++ gnucash/trunk/src/core-utils/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -1,14 +1,12 @@
 # CMakeLists.txt for src/core-utils
 
-# EXPERIMENTAL! This is just a trial of how far we can get for a cmake
-# build system.
-
 ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.core-utils\")
 
 INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES (${GCONF2_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${LIBGUILE_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR} ) # for config.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}) # for gnc-ui.h
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # when building swig-core-utils.c
@@ -18,19 +16,19 @@
 GNC_ADD_SWIG_COMMAND (${SWIG_CORE_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
 
 SET (libgnc_core_utils_SOURCES
-  gnc-main.c 
-  gnc-gconf-utils.c 
-  gnc-gdate-utils.c 
-  gnc-gkeyfile-utils.c 
-  gnc-glib-utils.c 
+  gnc-main.c
+  gnc-gconf-utils.c
+  gnc-gdate-utils.c
+  gnc-gkeyfile-utils.c
+  gnc-glib-utils.c
   ${SWIG_CORE_UTILS_C}
 )
 
 SET (libgnc_core_utils_HEADERS
-  gnc-main.h 
-  gnc-gconf-utils.h 
-  gnc-gdate-utils.h 
-  gnc-gkeyfile-utils.h 
+  gnc-main.h
+  gnc-gconf-utils.h
+  gnc-gdate-utils.h
+  gnc-gkeyfile-utils.h
   gnc-glib-utils.h
 )
 
@@ -38,4 +36,3 @@
   ${libgnc_core_utils_SOURCES}
   ${libgnc_core_utils_HEADERS}
   )
-

Modified: gnucash/trunk/src/engine/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/engine/CMakeLists.txt	2010-02-25 17:42:00 UTC (rev 18736)
+++ gnucash/trunk/src/engine/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -1,13 +1,11 @@
-# CMakeLists.txt for src/libqof
+# CMakeLists.txt for src/engine
 
-# EXPERIMENTAL! This is just a trial of how far we can get for a cmake
-# build system.
-
 ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.engine\")
 
 INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${LIBGUILE_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR} ) # for config.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}) # for gnc-ui.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/libqof/qof) # for qof.h
@@ -17,43 +15,43 @@
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for gncla-dir.h
 
 SET (libgncmod_engine_HEADERS
-  Account.h 
-  FreqSpec.h 
-  Recurrence.h 
-  GNCId.h 
-  Period.h 
-  SchedXaction.h 
-  SX-book.h 
-  SX-ttinfo.h 
-  Query.h 
-  QueryNew.h 
-  QueryObject.h 
-  QueryCore.h 
-  Scrub.h 
-  Scrub2.h 
-  Scrub3.h 
-  Split.h 
-  TransLog.h 
-  Transaction.h 
-  binreloc.h 
-  cap-gains.h 
-  cashobjects.h 
-  engine-helpers.h 
-  glib-helpers.h 
-  gnc-associate-account.h 
-  gnc-book.h 
-  gnc-budget.h 
-  gnc-commodity.h 
-  gnc-engine.h 
-  gnc-event.h 
-  gnc-filepath-utils.h 
-  gnc-hooks.h 
-  gnc-path.h 
-  gnc-pricedb.h 
-  gnc-session.h 
-  gnc-session-scm.h 
-  gncObject.h 
-  kvp-scm.h 
+  Account.h
+  FreqSpec.h
+  Recurrence.h
+  GNCId.h
+  Period.h
+  SchedXaction.h
+  SX-book.h
+  SX-ttinfo.h
+  Query.h
+  QueryNew.h
+  QueryObject.h
+  QueryCore.h
+  Scrub.h
+  Scrub2.h
+  Scrub3.h
+  Split.h
+  TransLog.h
+  Transaction.h
+  binreloc.h
+  cap-gains.h
+  cashobjects.h
+  engine-helpers.h
+  glib-helpers.h
+  gnc-associate-account.h
+  gnc-book.h
+  gnc-budget.h
+  gnc-commodity.h
+  gnc-engine.h
+  gnc-event.h
+  gnc-filepath-utils.h
+  gnc-hooks.h
+  gnc-path.h
+  gnc-pricedb.h
+  gnc-session.h
+  gnc-session-scm.h
+  gncObject.h
+  kvp-scm.h
   policy.h
 )
 
@@ -62,46 +60,71 @@
 GNC_ADD_SWIG_COMMAND (${SWIG_ENGINE_C} ${CMAKE_CURRENT_SOURCE_DIR}/engine.i)
 
 # Workaround to create a very simple gncla-dir.h file
-FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gncla-dir.h "
+FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gncla-dir.h.tmp "
 #define PREFIX \"${CMAKE_INSTALL_PREFIX}\"
 #define DATADIR \"${CMAKE_INSTALL_PREFIX}/share\"
 #define SYSCONFDIR \"${CMAKE_INSTALL_PREFIX}/etc\"
 #define LIBDIR \"${CMAKE_INSTALL_PREFIX}/lib\"
 #define LOCALE_DATADIRNAME \"share\"
 ")
+# Let cmake copy the created file only on changes.
+CONFIGURE_FILE (${CMAKE_CURRENT_BINARY_DIR}/gncla-dir.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/gncla-dir.h COPYONLY)
 
+# Command to generate the iso-4217-currencies.c file
+SET (ISO_4217_C ${CMAKE_CURRENT_BINARY_DIR}/iso-4217-currencies.c)
+ADD_CUSTOM_COMMAND (
+  OUTPUT ${ISO_4217_C}
+  DEPENDS iso-4217-currencies.scm iso-currencies-to-c
+  COMMAND
+    GUILE_LOAD_PATH=@GNC_SRFI_LOAD_PATH@:${GUILE_LOAD_PATH}
+	srcdir=${CMAKE_CURRENT_SOURCE_DIR}
+	${GUILE_EXECUTABLE} -s ${CMAKE_CURRENT_SOURCE_DIR}/iso-currencies-to-c
+)
+# Add dependency on iso-4217-currencies.c
+SET_SOURCE_FILES_PROPERTIES (gnc-commodity.c PROPERTIES OBJECT_DEPENDS ${ISO_4217_C})
+
+# Command to generate the swig-runtime.h header
+SET (SWIG_RUNTIME_H ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h)
+ADD_CUSTOM_COMMAND (
+  OUTPUT ${SWIG_RUNTIME_H}
+  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
+  COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H}
+)
+# Add dependency on swig-runtime.h
+SET_SOURCE_FILES_PROPERTIES (gnc-hooks.c engine-helpers.c kvp-scm.c glib-helpers.c PROPERTIES OBJECT_DEPENDS ${SWIG_RUNTIME_H})
+
 SET (libgncmod_engine_SOURCES
-  Account.c 
-  Recurrence.c 
-  Period.c 
-  Query.c 
-  SchedXaction.c 
-  SX-book.c 
-  SX-ttinfo.c 
-  Scrub.c 
-  Scrub2.c 
-  Scrub3.c 
-  Split.c 
-  TransLog.c 
-  Transaction.c 
-  binreloc.c 
-  cap-gains.c 
-  cashobjects.c 
-  gnc-associate-account.c 
-  gnc-budget.c 
-#  gnc-commodity.c 
-  gnc-engine.c 
-  gnc-filepath-utils.c 
-  gnc-hooks.c 
-  gnc-lot.c 
-  gnc-path.c 
-  gnc-pricedb.c 
-  gnc-session.c 
-  gnc-session-scm.c 
-  gncmod-engine.c 
-  kvp-scm.c 
-  engine-helpers.c 
-  glib-helpers.c  
+  Account.c
+  Recurrence.c
+  Period.c
+  Query.c
+  SchedXaction.c
+  SX-book.c
+  SX-ttinfo.c
+  Scrub.c
+  Scrub2.c
+  Scrub3.c
+  Split.c
+  TransLog.c
+  Transaction.c
+  binreloc.c
+  cap-gains.c
+  cashobjects.c
+  gnc-associate-account.c
+  gnc-budget.c
+  gnc-commodity.c
+  gnc-engine.c
+  gnc-filepath-utils.c
+  gnc-hooks.c
+  gnc-lot.c
+  gnc-path.c
+  gnc-pricedb.c
+  gnc-session.c
+  gnc-session-scm.c
+  gncmod-engine.c
+  kvp-scm.c
+  engine-helpers.c
+  glib-helpers.c
   policy.c
   ${SWIG_ENGINE_C}
 )
@@ -110,6 +133,3 @@
   ${libgncmod_engine_SOURCES}
   ${libgncmod_engine_HEADERS}
   )
-
-# We depend on the swig-runtime-h target
-ADD_DEPENDENCIES (engine swig-runtime-h)

Modified: gnucash/trunk/src/gnc-module/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/gnc-module/CMakeLists.txt	2010-02-25 17:42:00 UTC (rev 18736)
+++ gnucash/trunk/src/gnc-module/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -5,6 +5,7 @@
 INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${LIBGUILE_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR} ) # for config.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}) # for gnc-ui.h
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # when building swig-gnc-module.c

Modified: gnucash/trunk/src/libqof/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/libqof/CMakeLists.txt	2010-02-25 17:42:00 UTC (rev 18736)
+++ gnucash/trunk/src/libqof/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -1,8 +1,5 @@
 # CMakeLists.txt for src/libqof
 
-# EXPERIMENTAL! This is just a trial of how far we can get for a cmake
-# build system.
-
 ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"qof\")
 
 INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
@@ -13,95 +10,80 @@
 
 
 # Workaround to create a very simple gncla-dir.h file
-FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h "
+FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h.tmp "
 #define QOF_LIB_DIR \"${CMAKE_INSTALL_PREFIX}/lib/gnucash\"
 ")
+# Let cmake copy the created file only on changes.
+CONFIGURE_FILE (${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h COPYONLY)
+
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for qofla-dir.h
 
 SET (libgnc_qof_SOURCES
-   qof/gnc-date.c        
-   qof/gnc-numeric.c     
-   qof/guid.c            
-   qof/kvp_frame.c       
-   qof/kvp-util.c        
-   qof/md5.c             
-   qof/qofbackend.c      
-   qof/qofclass.c        
-   qof/qofchoice.c       
-   qof/qofid.c           
-   qof/qofinstance.c     
-   qof/qofquery.c        
-   qof/qofbook.c         
-   qof/qofevent.c        
-   qof/qoflog.c          
-   qof/qofobject.c       
-   qof/qofquerycore.c    
-   qof/qofreference.c    
-   qof/qofutil.c         
-   qof/qofsession.c      
+   qof/gnc-date.c
+   qof/gnc-numeric.c
+   qof/guid.c
+   qof/kvp_frame.c
+   qof/kvp-util.c
+   qof/md5.c
+   qof/qofbackend.c
+   qof/qofclass.c
+   qof/qofchoice.c
+   qof/qofid.c
+   qof/qofinstance.c
+   qof/qofquery.c
+   qof/qofbook.c
+   qof/qofevent.c
+   qof/qoflog.c
+   qof/qofobject.c
+   qof/qofquerycore.c
+   qof/qofreference.c
+   qof/qofutil.c
+   qof/qofsession.c
    qof/qofbookmerge.c
 )
 IF (WIN32)
-  SET (libgnc_qof_SOURCES ${libgnc_qof_SOURCES} qof/qof-win32.c)
+  SET (libgnc_qof_SOURCES ${libgnc_qof_SOURCES}
+    qof/qof-win32.c
+	../../lib/libc/strptime.c
+	../../lib/libc/localtime_r.c
+	../../lib/libc/gmtime_r.c
+  )
 ENDIF (WIN32)
 
-SET (qofinclude_HEADERS
-   qof/gnc-date.h        
-   qof/gnc-date-p.h      
-   qof/gnc-numeric.h     
-   qof/guid.h            
-   qof/kvp_frame.h       
-   qof/kvp-util.h        
-   qof/kvp-util-p.h      
-   qof/qof.h             
-   qof/qofbackend.h      
-   qof/qofbackend-p.h    
-   qof/qofclass.h        
-   qof/qofchoice.h       
-   qof/qofevent.h        
-   qof/qofgobj.h         
-   qof/qofid.h           
-   qof/qofid-p.h         
-   qof/qofinstance-p.h   
-   qof/qofinstance.h     
-   qof/qofquery.h        
-   qof/qofbook.h         
-   qof/qofbookslots.h    
-   qof/qoflog.h          
-   qof/qofobject.h       
-   qof/qofquerycore.h    
-   qof/qofreference.h    
-   qof/qofsession.h      
-   qof/qofsql.h          
-   qof/qofutil.h         
-   qof/qofbookmerge.h    
+SET (libgnc_qof_HEADERS
+   qof/gnc-date.h
+   qof/gnc-date-p.h
+   qof/gnc-numeric.h
+   qof/guid.h
+   qof/kvp_frame.h
+   qof/kvp-util.h
+   qof/kvp-util-p.h
+   qof/qof.h
+   qof/qofbackend.h
+   qof/qofbackend-p.h
+   qof/qofclass.h
+   qof/qofchoice.h
+   qof/qofevent.h
+   qof/qofgobj.h
+   qof/qofid.h
+   qof/qofid-p.h
+   qof/qofinstance-p.h
+   qof/qofinstance.h
+   qof/qofquery.h
+   qof/qofbook.h
+   qof/qofbookslots.h
+   qof/qoflog.h
+   qof/qofobject.h
+   qof/qofquerycore.h
+   qof/qofreference.h
+   qof/qofsession.h
+   qof/qofsql.h
+   qof/qofutil.h
+   qof/qofbookmerge.h
    qof/qof-gobject.h
 )
 
 ADD_LIBRARY	(qof
   ${libgnc_qof_SOURCES}
-  ${qofinclude_HEADERS}
+  ${libgnc_qof_HEADERS}
   )
-
-TARGET_LINK_LIBRARIES (qof ${GTK_LIBRARIES})
-
-# libgnc_qof_la_LIBADD= $(REGEX_LIBS)
-
-#nodist_qofinclude_HEADERS = \
-#   qofla-dir.h     
-
-#noinst_HEADERS = \
-#   md5.h  \
-#   qofclass-p.h  \
-#   qofmath128.h  \
-#   qofquery-p.h  \
-#   qofquery-deserial.h \
-#   qofquery-serialize.h \
-#   qofbook-p.h  \
-#   qofevent-p.h \
-#   qofobject-p.h  \
-#   qofquerycore-p.h \
-#   qofsession-p.h
-
-#EXTRA_DIST = \
-#  qofmath128.c

Added: gnucash/trunk/src/test-core/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/test-core/CMakeLists.txt	                        (rev 0)
+++ gnucash/trunk/src/test-core/CMakeLists.txt	2010-02-25 17:42:21 UTC (rev 18737)
@@ -0,0 +1,33 @@
+# CMakeLists.txt for src/test-core
+
+
+# A test executable
+LINK_DIRECTORIES (${GLIB2_LIBRARY_DIRS}
+  ${GMODULE_LIBRARY_DIRS}
+  ${GOBJECT_LIBRARY_DIRS}
+  ${GTHREAD_LIBRARY_DIRS}
+  ${GCONF2_LIBRARY_DIRS}
+)
+ADD_EXECUTABLE (test-main
+  test-main.c
+)
+
+INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${LIBGUILE_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR} ) # for config.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}) # for gnc-ui.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/libqof/qof) # for qof.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/gnc-module) # for gnc-glib-utils.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/core-utils) # for gnc-glib-utils.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/engine) # for gnc-glib-utils.h
+INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/engine) # for swig-runtime.h
+
+TARGET_LINK_LIBRARIES (test-main engine gnc-module core-utils qof)
+TARGET_LINK_LIBRARIES (test-main ${GCONF_LIBRARIES})
+TARGET_LINK_LIBRARIES (test-main ${GTHREAD_LIBRARIES} ${GOBJECT_LIBRARIES} ${GMODULE_LIBRARIES} ${GLIB2_LIBRARIES})
+TARGET_LINK_LIBRARIES (test-main ${LIBGUILE_LIBRARIES})
+IF (WIN32)
+  TARGET_LINK_LIBRARIES (test-main ${LIBINTL_LIBRARY} ${REGEX_LIBRARY})
+ENDIF (WIN32)

Added: gnucash/trunk/src/test-core/test-main.c
===================================================================
--- gnucash/trunk/src/test-core/test-main.c	                        (rev 0)
+++ gnucash/trunk/src/test-core/test-main.c	2010-02-25 17:42:21 UTC (rev 18737)
@@ -0,0 +1,166 @@
+/*
+ * gnucash-bin.c -- The program entry point for GnuCash
+ *
+ * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <libguile.h>
+#include <glib/gi18n.h>
+#include <glib.h>
+#include "gnc-module.h"
+#include "gnc-path.h"
+#include "binreloc.h"
+/* #include "gnc-version.h" */
+#include "gnc-engine.h"
+#include "gnc-filepath-utils.h"
+#include "gnc-hooks.h"
+#include "gnc-commodity.h"
+#include "gnc-main.h"
+#include "gnc-session.h"
+#include "engine-helpers.h"
+#include "swig-runtime.h"
+
+#ifdef HAVE_GETTEXT
+#  include <libintl.h>
+#  include <locale.h>
+#endif
+
+#define APP_GNUCASH "/apps/gnucash"
+
+/* GNUCASH_SVN is defined whenever we're building from an SVN tree */
+#ifdef GNUCASH_SVN
+static int is_development_version = TRUE;
+#else
+static int is_development_version = FALSE;
+#endif
+
+static gchar **log_flags = NULL;
+static gchar *log_to_filename = NULL;
+
+static void
+gnc_log_init()
+{
+    if (log_to_filename != NULL)
+    {
+        qof_log_init_filename_special(log_to_filename);
+    }
+    else
+    {
+        /* initialize logging to our file. */
+        gchar *tracefilename;
+        tracefilename = g_build_filename(g_get_tmp_dir(), "gnucash.trace",
+                                         (gchar *)NULL);
+        qof_log_init_filename(tracefilename);
+        g_free(tracefilename);
+    }
+
+    // set a reasonable default.
+    qof_log_set_default(QOF_LOG_WARNING);
+
+    gnc_log_default();
+
+    if (gnc_is_debugging())
+    {
+        qof_log_set_level("", QOF_LOG_INFO);
+        qof_log_set_level("qof", QOF_LOG_INFO);
+        qof_log_set_level("gnc", QOF_LOG_INFO);
+    }
+
+    {
+        gchar *log_config_filename;
+        log_config_filename = gnc_build_dotgnucash_path("log.conf");
+        if (g_file_test(log_config_filename, G_FILE_TEST_EXISTS))
+            qof_log_parse_log_config(log_config_filename);
+        g_free(log_config_filename);
+    }
+
+    if (log_flags != NULL)
+    {
+        int i = 0;
+        for (; log_flags[i] != NULL; i++)
+        {
+            QofLogLevel level;
+            gchar **parts = NULL;
+
+            gchar *log_opt = log_flags[i];
+            parts = g_strsplit(log_opt, "=", 2);
+            if (parts == NULL || parts[0] == NULL || parts[1] == NULL)
+            {
+                g_warning("string [%s] not parseable", log_opt);
+                continue;
+            }
+
+            level = qof_log_level_from_string(parts[1]);
+            qof_log_set_level(parts[0], level);
+            g_strfreev(parts);
+        }
+    }
+}
+
+
+int
+main(int argc, char ** argv)
+{
+#if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE)
+#    error "No GLib thread implementation available!"
+#endif
+    g_thread_init(NULL);
+
+#ifdef ENABLE_BINRELOC
+    {
+        GError *binreloc_error = NULL;
+        if (!gbr_init(&binreloc_error))
+        {
+            g_print("main: Error on gbr_init: %s\n", binreloc_error->message);
+            g_error_free(binreloc_error);
+        }
+    }
+#else
+    g_message("main: binreloc relocation support was disabled at configure time.\n");
+#endif
+
+#ifdef HAVE_GETTEXT
+    {
+        gchar *localedir = gnc_path_get_localedir();
+        /* setlocale(LC_ALL, ""); is already called by gtk_set_locale()
+           via gtk_init(). */
+        bindtextdomain(GETTEXT_PACKAGE, localedir);
+        textdomain(GETTEXT_PACKAGE);
+        bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+        g_free(localedir);
+    }
+#endif
+
+    qof_log_init();
+    qof_log_set_default(QOF_LOG_INFO);
+
+    gnc_log_init();
+
+    gnc_module_system_init();
+
+/*     gnc_gnome_init (argc, argv, VERSION); */
+/*     gnc_gui_init(); */
+/*     scm_boot_guile(argc, argv, inner_main, 0); */
+    exit(0); /* never reached */
+}



More information about the gnucash-changes mailing list