r18736 - gnucash/trunk/src - More CMake work: Build swig wrappers correctly. Build gnc-module.
Christian Stimming
cstim at code.gnucash.org
Thu Feb 25 12:42:00 EST 2010
Author: cstim
Date: 2010-02-25 12:42:00 -0500 (Thu, 25 Feb 2010)
New Revision: 18736
Trac: http://svn.gnucash.org/trac/changeset/18736
Added:
gnucash/trunk/src/cmake_modules/
gnucash/trunk/src/cmake_modules/COPYING-CMAKE-SCRIPTS.txt
gnucash/trunk/src/cmake_modules/GncAddSwigCommand.cmake
gnucash/trunk/src/cmake_modules/MacroAddSourceFileCompileFlags.cmake
gnucash/trunk/src/cmake_modules/MacroAppendForeach.cmake
gnucash/trunk/src/gnc-module/CMakeLists.txt
Modified:
gnucash/trunk/src/CMakeLists.txt
gnucash/trunk/src/core-utils/CMakeLists.txt
gnucash/trunk/src/engine/CMakeLists.txt
gnucash/trunk/src/libqof/CMakeLists.txt
Log:
More CMake work: Build swig wrappers correctly. Build gnc-module.
Modified: gnucash/trunk/src/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/CMakeLists.txt 2010-02-25 15:26:23 UTC (rev 18735)
+++ gnucash/trunk/src/CMakeLists.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -6,6 +6,12 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (gnucash)
+# Extra cmake macros
+SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules;${CMAKE_MODULE_PATH}")
+INCLUDE (MacroAppendForeach)
+INCLUDE (MacroAddSourceFileCompileFlags)
+INCLUDE (GncAddSwigCommand)
+
# ############################################################
# Find pkg-config
@@ -24,14 +30,24 @@
FIND_PATH (REGEX_INCLUDE_PATH NAMES regex.h
PATHS /usr/include /opt/gnome/include)
+# ############################################################
+
FIND_PACKAGE (SWIG REQUIRED)
INCLUDE (${SWIG_USE_FILE})
#FIND_PACKAGE (GUILE REQUIRED)
-# Workaround to create a dummy swig-runtime.h file
-FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h "")
+# 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)
@@ -166,7 +182,8 @@
# ############################################################
# The subdirectories
-ADD_SUBDIRECTORY (libqof)
+#ADD_SUBDIRECTORY (libqof)
ADD_SUBDIRECTORY (core-utils)
+ADD_SUBDIRECTORY (gnc-module)
ADD_SUBDIRECTORY (engine)
Added: gnucash/trunk/src/cmake_modules/COPYING-CMAKE-SCRIPTS.txt
===================================================================
--- gnucash/trunk/src/cmake_modules/COPYING-CMAKE-SCRIPTS.txt (rev 0)
+++ gnucash/trunk/src/cmake_modules/COPYING-CMAKE-SCRIPTS.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -0,0 +1,29 @@
+The copyright notice below applies to all files in the cmake_modules/
+directory. Some of them were published on
+http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules, others on
+http://cmake-modules.googlecode.com/svn/trunk/Modules/.
+
+
+
+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.
Added: gnucash/trunk/src/cmake_modules/GncAddSwigCommand.cmake
===================================================================
--- gnucash/trunk/src/cmake_modules/GncAddSwigCommand.cmake (rev 0)
+++ gnucash/trunk/src/cmake_modules/GncAddSwigCommand.cmake 2010-02-25 17:42:00 UTC (rev 18736)
@@ -0,0 +1,15 @@
+# Copyright (c) 2010, Christian Stimming
+
+
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+MACRO (GNC_ADD_SWIG_COMMAND _target _input)
+
+ADD_CUSTOM_COMMAND (
+ OUTPUT ${_target}
+ DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/base-typemaps.i ${ARGN}
+ COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libqof/qof -I${CMAKE_SOURCE_DIR} -o ${_target} ${_input}
+)
+
+ENDMACRO (GNC_ADD_SWIG_COMMAND)
Added: gnucash/trunk/src/cmake_modules/MacroAddSourceFileCompileFlags.cmake
===================================================================
--- gnucash/trunk/src/cmake_modules/MacroAddSourceFileCompileFlags.cmake (rev 0)
+++ gnucash/trunk/src/cmake_modules/MacroAddSourceFileCompileFlags.cmake 2010-02-25 17:42:00 UTC (rev 18736)
@@ -0,0 +1,19 @@
+# - MACRO_ADD_SOURCE_FILE_COMPILE_FLAGS(<_target> "flags...")
+
+# Copyright (c) 2006, Oswald Buddenhagen, <ossi 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_ADD_SOURCE_FILE_COMPILE_FLAGS _sourcefile _additionalflags)
+
+ GET_SOURCE_FILE_PROPERTY (_flags ${_sourcefile} COMPILE_FLAGS)
+ if (_flags)
+ set(_flags "${_flags} ${_additionalflags}")
+ else (_flags)
+ set(_flags "${_additionalflags}")
+ endif (_flags)
+ SET_SOURCE_FILES_PROPERTIES (${_sourcefile} PROPERTIES COMPILE_FLAGS "${_flags}")
+
+ENDMACRO (MACRO_ADD_SOURCE_FILE_COMPILE_FLAGS)
Added: gnucash/trunk/src/cmake_modules/MacroAppendForeach.cmake
===================================================================
--- gnucash/trunk/src/cmake_modules/MacroAppendForeach.cmake (rev 0)
+++ gnucash/trunk/src/cmake_modules/MacroAppendForeach.cmake 2010-02-25 17:42:00 UTC (rev 18736)
@@ -0,0 +1,20 @@
+# - MACRO_APPEND_FOREACH(<_targetlist> _prefix _suffix <_sourcelist> )
+
+# Copyright (c) 2009, Christian Stimming
+
+# Appends each element of the <_sourcelist> to the <_targetlist>, but
+# with the _prefix prepended and _suffix appended. Note: If no suffix
+# is desired, pass an empty string ("") there.
+
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+MACRO (MACRO_APPEND_FOREACH _target _prefix _suffix)
+
+ FOREACH (_loop_var ${ARGN})
+
+ SET (${_target} ${${_target}} "${_prefix}${_loop_var}${_suffix}")
+
+ ENDFOREACH (_loop_var)
+
+ENDMACRO (MACRO_APPEND_FOREACH)
Modified: gnucash/trunk/src/core-utils/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/core-utils/CMakeLists.txt 2010-02-25 15:26:23 UTC (rev 18735)
+++ gnucash/trunk/src/core-utils/CMakeLists.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -1,4 +1,4 @@
-# CMakeLists.txt for src/libqof
+# CMakeLists.txt for src/core-utils
# EXPERIMENTAL! This is just a trial of how far we can get for a cmake
# build system.
@@ -11,9 +11,11 @@
INCLUDE_DIRECTORIES (${REGEX_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
-# FIXME: I still need to look up SWIG wrapper generation in cmake...
-#SWIG_ADD_MODULE (core_utils c swig-core-utils.i swig-core-utils.c)
+# Command to generate the swig-engine.c wrapper file
+SET (SWIG_CORE_UTILS_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils.c)
+GNC_ADD_SWIG_COMMAND (${SWIG_CORE_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
SET (libgnc_core_utils_SOURCES
gnc-main.c
@@ -21,7 +23,7 @@
gnc-gdate-utils.c
gnc-gkeyfile-utils.c
gnc-glib-utils.c
- ../gnc-module/gnc-module.c
+ ${SWIG_CORE_UTILS_C}
)
SET (libgnc_core_utils_HEADERS
@@ -30,8 +32,6 @@
gnc-gdate-utils.h
gnc-gkeyfile-utils.h
gnc-glib-utils.h
- ../gnc-module/gnc-module.h
- ../gnc-module/gnc-module-api.h
)
ADD_LIBRARY (core-utils
Modified: gnucash/trunk/src/engine/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/engine/CMakeLists.txt 2010-02-25 15:26:23 UTC (rev 18735)
+++ gnucash/trunk/src/engine/CMakeLists.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -15,48 +15,7 @@
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/core-utils) # for gnc-glib-utils.h
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # for <Account.h>
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for gncla-dir.h
-MESSAGE(STATUS "SWIG_DIR=${SWIG_DIR}")
-# FIXME: I still need to look up SWIG wrapper generation in cmake...
-#SWIG_ADD_MODULE (engine guile swig-engine.i swig-engine.c)
-# Workaround to create a dummy gncla-dir.h file
-FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gncla-dir.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
- policy.c
-)
-
SET (libgncmod_engine_HEADERS
Account.h
FreqSpec.h
@@ -98,8 +57,59 @@
policy.h
)
+# Command to generate the swig-engine.c wrapper file
+SET (SWIG_ENGINE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-engine.c)
+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 "
+#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\"
+")
+
+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
+ policy.c
+ ${SWIG_ENGINE_C}
+)
+
ADD_LIBRARY (engine
${libgncmod_engine_SOURCES}
${libgncmod_engine_HEADERS}
)
+# We depend on the swig-runtime-h target
+ADD_DEPENDENCIES (engine swig-runtime-h)
Added: gnucash/trunk/src/gnc-module/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/gnc-module/CMakeLists.txt (rev 0)
+++ gnucash/trunk/src/gnc-module/CMakeLists.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -0,0 +1,29 @@
+# CMakeLists.txt for src/gnc-module
+
+ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.module\")
+
+INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
+INCLUDE_DIRECTORIES (${REGEX_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
+
+# Command to generate the swig-engine.c wrapper file
+SET (SWIG_GNC_MODULE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-module.c)
+GNC_ADD_SWIG_COMMAND (${SWIG_GNC_MODULE_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i)
+
+SET (libgnc_module_SOURCES
+ gnc-module.c
+ ${SWIG_GNC_MODULE_C}
+)
+
+SET (libgnc_module_HEADERS
+ gnc-module.h
+ gnc-module-api.h
+)
+
+ADD_LIBRARY (gnc-module
+ ${libgnc_module_SOURCES}
+ ${libgnc_module_HEADERS}
+ )
Modified: gnucash/trunk/src/libqof/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/libqof/CMakeLists.txt 2010-02-25 15:26:23 UTC (rev 18735)
+++ gnucash/trunk/src/libqof/CMakeLists.txt 2010-02-25 17:42:00 UTC (rev 18736)
@@ -12,8 +12,10 @@
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/../lib/libc) # for strptime.h
-# Workaround to create a qofla-dir.h file
-FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h "#define QOF_LIB_DIR \"foobar\"\n")
+# Workaround to create a very simple gncla-dir.h file
+FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/qofla-dir.h "
+#define QOF_LIB_DIR \"${CMAKE_INSTALL_PREFIX}/lib/gnucash\"
+")
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for qofla-dir.h
SET (libgnc_qof_SOURCES
More information about the gnucash-changes
mailing list