mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 10:20:18 -06:00
Finish cmake build system for the C++ experiment.
To build this: mkdir build-cpp cd build-cpp cmake .. make ./src/gnc/cutecash git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18815 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6087cfd688
commit
dffacfefc7
81
CMakeLists.txt
Normal file
81
CMakeLists.txt
Normal file
@ -0,0 +1,81 @@
|
||||
# CMakeLists.txt for the cutecash sub-project of gnucash
|
||||
|
||||
# This is very EXPERIMENTAL! We will see how far this project will
|
||||
# get.
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
|
||||
PROJECT (cutecash)
|
||||
|
||||
# Extra cmake macros
|
||||
SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/src/cmake_modules;${CMAKE_MODULE_PATH}")
|
||||
INCLUDE (MacroAppendForeach)
|
||||
INCLUDE (MacroAddSourceFileCompileFlags)
|
||||
INCLUDE (GncAddSwigCommand)
|
||||
|
||||
# ############################################################
|
||||
|
||||
# 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 et al.
|
||||
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 (MSVC)
|
||||
MESSAGE (STATUS "Hint: To create the import libraries for the gnome DLLs (e.g. gconf-2.lib), use the dlltool as follows: pexports bin/libgconf-2-4.dll > lib/libgconf-2.def ; dlltool -d lib/libgconf-2.def -D bin/libgconf-2-4.dll -l lib/gconf-2.lib")
|
||||
ENDIF (MSVC)
|
||||
|
||||
# Libxml2
|
||||
FIND_PACKAGE (LibXml2 REQUIRED)
|
||||
FIND_PACKAGE (ZLIB REQUIRED)
|
||||
|
||||
IF (NOT GLIB2_FOUND)
|
||||
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})
|
||||
|
||||
# guile
|
||||
FIND_PATH (LIBGUILE_INCLUDE_PATH NAMES libguile.h
|
||||
PATHS /usr/include)
|
||||
FIND_LIBRARY (LIBGUILE_LIBRARIES NAMES guile)
|
||||
FIND_PROGRAM (GUILE_EXECUTABLE guile)
|
||||
|
||||
# ############################################################
|
||||
|
||||
# Qt
|
||||
SET (QT_MIN_VERSION "4.5.0")
|
||||
FIND_PACKAGE (Qt4 REQUIRED) # find and setup Qt4 for this project
|
||||
|
||||
# ############################################################
|
||||
|
||||
# Compiler flags
|
||||
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)
|
||||
|
||||
# ############################################################
|
||||
|
||||
# The subdirectories
|
||||
ADD_SUBDIRECTORY (src)
|
@ -1,100 +1,11 @@
|
||||
# CMakeLists.txt for src/
|
||||
|
||||
# EXPERIMENTAL! This is just a trial of how far we can get for a cmake
|
||||
# build system.
|
||||
|
||||
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
|
||||
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 et al.
|
||||
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 (MSVC)
|
||||
MESSAGE (STATUS "To create the import libraries for the gnome DLLs (e.g. gconf-2.lib), use the dlltool as follows: dlltool -D libgconf-2-4.dll -l ../lib/gconf-2.lib")
|
||||
ENDIF (MSVC)
|
||||
|
||||
# Libxml2
|
||||
FIND_PACKAGE (LibXml2 REQUIRED)
|
||||
FIND_PACKAGE (ZLIB REQUIRED)
|
||||
|
||||
IF (NOT GLIB2_FOUND)
|
||||
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})
|
||||
|
||||
# guile
|
||||
FIND_PATH (LIBGUILE_INCLUDE_PATH NAMES libguile.h
|
||||
PATHS /usr/include)
|
||||
FIND_LIBRARY (LIBGUILE_LIBRARIES NAMES guile)
|
||||
FIND_PROGRAM (GUILE_EXECUTABLE guile)
|
||||
|
||||
# ############################################################
|
||||
|
||||
# Qt
|
||||
SET (QT_MIN_VERSION "4.5.0")
|
||||
FIND_PACKAGE (Qt4 REQUIRED) # find and setup Qt4 for this project
|
||||
|
||||
# ############################################################
|
||||
|
||||
# Check for boost
|
||||
FIND_PACKAGE (Boost QUIET)
|
||||
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS})
|
||||
|
||||
# MSVC should not link against boost-regex and boost-date_time.
|
||||
IF (MSVC)
|
||||
ADD_DEFINITIONS( -DBOOST_ALL_NO_LIB )
|
||||
ENDIF (MSVC)
|
||||
IF (WIN32)
|
||||
ADD_DEFINITIONS (-DWIN32_LEAN_AND_MEAN)
|
||||
ENDIF (WIN32)
|
||||
|
||||
# ############################################################
|
||||
|
||||
# Compiler flags
|
||||
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)
|
||||
|
||||
SET (CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/config.h.tmp)
|
||||
SET (CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
FILE (WRITE ${CONFIG_H} "#define PACKAGE \"gnucash\"\n")
|
||||
|
||||
FILE (APPEND ${CONFIG_H} "
|
||||
@ -216,7 +127,7 @@ IF (UNIX)
|
||||
ENDIF (UNIX)
|
||||
|
||||
# Let cmake copy the created file only on changes.
|
||||
CONFIGURE_FILE (${CONFIG_H} ${CMAKE_CURRENT_BINARY_DIR}/config.h COPYONLY)
|
||||
#CONFIGURE_FILE (${CONFIG_H} ${CMAKE_CURRENT_BINARY_DIR}/config.h COPYONLY)
|
||||
|
||||
# ############################################################
|
||||
|
||||
@ -226,7 +137,7 @@ ADD_SUBDIRECTORY (core-utils)
|
||||
ADD_SUBDIRECTORY (gnc-module)
|
||||
ADD_SUBDIRECTORY (engine)
|
||||
ADD_SUBDIRECTORY (backend/xml)
|
||||
ADD_SUBDIRECTORY (test-core)
|
||||
|
||||
ADD_SUBDIRECTORY (gnc)
|
||||
|
||||
ADD_SUBDIRECTORY (test-core)
|
||||
|
@ -8,13 +8,13 @@ INCLUDE_DIRECTORIES (${LIBGUILE_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${LIBXML2_INCLUDE_DIR})
|
||||
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_SOURCE_DIR}/../lib/libc) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/libqof/qof)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/core-utils)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/gnc-module)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/engine)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # when building swig-gnc-module.c
|
||||
|
||||
# Command to generate the swig-engine.c wrapper file
|
||||
|
@ -8,8 +8,8 @@ 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}
|
||||
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/src/base-typemaps.i ${ARGN}
|
||||
COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/src/libqof/qof -I${CMAKE_SOURCE_DIR}/src -o ${_target} ${_input}
|
||||
)
|
||||
|
||||
ENDMACRO (GNC_ADD_SWIG_COMMAND)
|
||||
|
@ -7,8 +7,8 @@ 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_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/..) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # when building swig-core-utils.c
|
||||
|
||||
# Command to generate the swig-engine.c wrapper file
|
||||
|
@ -6,11 +6,11 @@ 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_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/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
|
||||
|
||||
@ -129,7 +129,7 @@ SET (libgncmod_engine_SOURCES
|
||||
)
|
||||
|
||||
# Add dependency on config.h
|
||||
SET_SOURCE_FILES_PROPERTIES (${libgncmod_engine_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
||||
#SET_SOURCE_FILES_PROPERTIES (${libgncmod_engine_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
||||
|
||||
ADD_LIBRARY (engine
|
||||
${libgncmod_engine_SOURCES}
|
||||
|
@ -6,8 +6,8 @@ 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_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # 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
|
||||
|
@ -23,7 +23,6 @@ SET (gnc_QOBJECT_HEADERS
|
||||
SET (gnc_HEADERS ${gnc_QOBJECT_HEADERS}
|
||||
Account.hpp
|
||||
Book.hpp
|
||||
ScopedPointer.hpp
|
||||
Session.hpp
|
||||
WeakPointer.hpp
|
||||
)
|
||||
@ -48,19 +47,19 @@ 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_SOURCE_DIR}/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/engine) # for swig-runtime.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for ui_mainwindow.h
|
||||
|
||||
INCLUDE_DIRECTORIES (${QT_INCLUDES})
|
||||
|
||||
ADD_EXECUTABLE (cpp-main
|
||||
ADD_EXECUTABLE (cutecash
|
||||
${gnc_FORMS_HEADERS}
|
||||
${gnc_HEADERS}
|
||||
${gnc_MOC_SOURCES}
|
||||
@ -68,14 +67,14 @@ ADD_EXECUTABLE (cpp-main
|
||||
${gnc_SOURCES}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES (cpp-main gnc-backend-xml engine gnc-module core-utils qof)
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${GCONF2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${GTHREAD_LIBRARIES} ${GOBJECT_LIBRARIES} ${GMODULE_LIBRARIES} ${GLIB2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${LIBGUILE_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${LIBXML2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${ZLIB_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash gnc-backend-xml engine gnc-module core-utils qof)
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GCONF2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${GTHREAD_LIBRARIES} ${GOBJECT_LIBRARIES} ${GMODULE_LIBRARIES} ${GLIB2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBGUILE_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBXML2_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${ZLIB_LIBRARIES})
|
||||
IF (WIN32)
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${LIBINTL_LIBRARY} ${REGEX_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${LIBINTL_LIBRARY} ${REGEX_LIBRARY})
|
||||
ENDIF (WIN32)
|
||||
|
||||
TARGET_LINK_LIBRARIES (cpp-main ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES (cutecash ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef GNC_SCOPEDPOINTER_HPP
|
||||
#define GNC_SCOPEDPOINTER_HPP
|
||||
|
||||
#error "This file requires the Boost library because the boost::shared_ptr is nice and has non-trivial features. However, in the current build this file isn't used anyway, so it should not be used within this project so far."
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace gnc
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "gnc/Book.hpp"
|
||||
|
||||
// Explicit instantiation to check for compiler errors in the template
|
||||
template class gnc::ScopedPointer< QofSession >;
|
||||
template class gnc::WeakPointer< QofSession >;
|
||||
|
||||
|
||||
|
@ -10,8 +10,7 @@ extern "C"
|
||||
#include "engine/gnc-hooks.h"
|
||||
}
|
||||
|
||||
#include "gnc/ScopedPointer.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include "gnc/WeakPointer.hpp"
|
||||
#include <QString>
|
||||
|
||||
namespace gnc
|
||||
@ -22,33 +21,20 @@ class Book;
|
||||
/** ScopedPointer object around a QofSession object, which also owns the
|
||||
* QofSession object.
|
||||
*/
|
||||
class Session : public ScopedPointer< ::QofSession >
|
||||
, boost::noncopyable
|
||||
class Session : public WeakPointer< ::QofSession >
|
||||
{
|
||||
public:
|
||||
typedef ScopedPointer< ::QofSession > base_class;
|
||||
typedef WeakPointer< ::QofSession > base_class;
|
||||
|
||||
Session()
|
||||
: base_class()
|
||||
Session(element_type *ptr = 0)
|
||||
: base_class(ptr)
|
||||
{}
|
||||
Session(element_type *ptr)
|
||||
: base_class(ptr, qof_session_destroy)
|
||||
{}
|
||||
void reset(element_type *ptr)
|
||||
{
|
||||
base_class::reset(ptr, qof_session_destroy);
|
||||
}
|
||||
using base_class::reset;
|
||||
static element_type* newInstance()
|
||||
{
|
||||
return qof_session_new();
|
||||
}
|
||||
|
||||
// Now the actual functions on the object
|
||||
|
||||
void begin(const std::string& book_id, bool ignore_lock, bool create_if_nonexistent)
|
||||
void begin(const QString& book_id, bool ignore_lock, bool create_if_nonexistent)
|
||||
{
|
||||
qof_session_begin(get(), book_id.c_str(), ignore_lock, create_if_nonexistent);
|
||||
qof_session_begin(get(), book_id.toUtf8(), ignore_lock, create_if_nonexistent);
|
||||
}
|
||||
void load (QofPercentageFunc percentage_func)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define GNC_WEAKPOINTER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace gnc
|
||||
{
|
||||
|
@ -61,6 +61,11 @@ MainWindow::MainWindow()
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (m_session.get())
|
||||
{
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
@ -223,6 +228,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
qof_session_call_close_hooks(m_session.get());
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.get());
|
||||
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
|
||||
qof_event_resume ();
|
||||
@ -244,7 +250,7 @@ void MainWindow::newFile()
|
||||
if (maybeSave())
|
||||
{
|
||||
|
||||
if (m_session.get())
|
||||
if (m_session)
|
||||
{
|
||||
/* close any ongoing file sessions, and free the accounts.
|
||||
* disable events so we don't get spammed by redraws. */
|
||||
@ -253,12 +259,13 @@ void MainWindow::newFile()
|
||||
m_session.call_close_hooks();
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.get());
|
||||
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
qof_event_resume ();
|
||||
}
|
||||
|
||||
/* start a new book */
|
||||
m_session.reset(Session::newInstance());
|
||||
m_session.reset(qof_session_new());
|
||||
|
||||
gnc_hook_run(HOOK_NEW_BOOK, NULL);
|
||||
|
||||
@ -290,6 +297,7 @@ void MainWindow::loadFile(const QString &fileName)
|
||||
/* -- this code is almost identical in FileOpen and FileSaveAs -- */
|
||||
m_session.call_close_hooks();
|
||||
gnc_hook_run(HOOK_BOOK_CLOSED, m_session.get());
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
|
||||
/* load the accounts from the users datafile */
|
||||
@ -394,6 +402,11 @@ void MainWindow::loadFile(const QString &fileName)
|
||||
|
||||
/* if we got to here, then we've successfully gotten a new session */
|
||||
/* close up the old file session (if any) */
|
||||
if (m_session.get())
|
||||
{
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
}
|
||||
m_session.reset(new_session);
|
||||
|
||||
qof_event_resume ();
|
||||
@ -503,6 +516,7 @@ bool MainWindow::saveFile(const QString &fileName)
|
||||
/* if we got to here, then we've successfully gotten a new session */
|
||||
/* close up the old file session (if any) */
|
||||
qof_session_swap_data (session, new_session);
|
||||
qof_session_destroy(m_session.get());
|
||||
m_session.reset();
|
||||
session = NULL;
|
||||
|
||||
|
@ -5,8 +5,8 @@ ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"qof\")
|
||||
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}/../lib/libc) # for strptime.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}/.. ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for strptime.h
|
||||
|
||||
|
||||
# Workaround to create a very simple gncla-dir.h file
|
||||
|
@ -16,14 +16,14 @@ 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_SOURCE_DIR}/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/engine) # for swig-runtime.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine) # for gnc-glib-utils.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/xml)
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
|
||||
|
||||
TARGET_LINK_LIBRARIES (test-main gnc-backend-xml engine gnc-module core-utils qof)
|
||||
TARGET_LINK_LIBRARIES (test-main ${GCONF2_LIBRARIES})
|
||||
|
Loading…
Reference in New Issue
Block a user