2017-02-01 21:48:46 -06:00
# CMakeLists.txt for GnuCash
2010-03-04 11:48:36 -06:00
2018-05-03 16:18:15 -05:00
if ( WIN32 OR APPLE )
cmake_minimum_required ( VERSION 3.3.2 )
else ( )
cmake_minimum_required ( VERSION 3.0 )
endif ( )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
project ( gnucash )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
enable_testing ( )
2016-01-18 10:33:34 -06:00
2015-12-07 11:17:08 -06:00
# Version number of gnucash
2018-05-03 16:18:15 -05:00
set ( GNUCASH_MAJOR_VERSION 3 )
2018-09-29 18:49:35 -05:00
set ( GNUCASH_MINOR_VERSION 900 )
2018-05-03 16:18:15 -05:00
set ( VERSION "${GNUCASH_MAJOR_VERSION}.${GNUCASH_MINOR_VERSION}" )
set ( GNUCASH_LATEST_STABLE_SERIES 3.x )
set ( PACKAGE gnucash )
set ( PACKAGE_NAME GnuCash )
2018-09-29 18:49:35 -05:00
set ( PACKAGE_VERSION 3.900 )
2018-10-17 23:05:53 -05:00
set ( PACKAGE_BUGREPORT "https://bugs.gnucash.org" )
2018-05-03 16:18:15 -05:00
set ( PACKAGE_TARNAME ${ PACKAGE } )
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" )
2018-10-17 23:05:53 -05:00
set ( PACKAGE_URL "https://www.gnucash.org/" )
2010-05-06 06:40:55 -05:00
2011-01-30 04:25:07 -06:00
# Change this in development versions when changing anything that
# affects stored data structures. Reset to zero when bumping version.
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
set ( GNUCASH_RESAVE_VERSION "19920" )
2011-01-30 04:25:07 -06:00
2018-05-03 16:18:15 -05:00
set ( GETTEXT_PACKAGE "gnucash" )
2015-12-07 11:17:08 -06:00
2018-01-28 10:45:49 -06:00
# Clear cache variables that will be filled later during the cmake run
unset ( dist_generated CACHE )
unset ( dist_generated_depends CACHE )
2010-03-04 11:48:36 -06:00
# Extra cmake macros
2018-05-03 16:18:15 -05:00
set ( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/common/cmake_modules;${CMAKE_MODULE_PATH}" )
2017-06-15 17:39:04 -05:00
# CMake does a non-recursive build that puts the final build product directories in the build root. Some code needs to know this.
2018-05-03 16:18:15 -05:00
include ( MacroAppendForeach )
include ( MacroAddSourceFileCompileFlags )
include ( GncAddSwigCommand )
include ( CheckIncludeFiles )
include ( GncAddSchemeTargets )
include ( GncAddGSchemaTargets )
include ( GncAddTest )
include ( MakeDistFiles )
include ( GNUInstallDirs )
2018-09-08 15:53:25 -05:00
include ( TestBigEndian )
2010-03-04 11:48:36 -06:00
2015-12-07 11:17:08 -06:00
# ############################################################
# These options are settable from the CMake command line. For example, to disable
# SQL, put -D WITH_SQL=OFF on the command line.
2018-05-03 16:18:15 -05:00
option ( WITH_SQL "Build this project with SQL (libdbi) support" ON )
option ( WITH_AQBANKING "Build this project with aqbanking (online banking) support" ON )
option ( WITH_GNUCASH "Build all of GnuCash, not just the library" ON )
option ( WITH_OFX "compile with ofx support (needs LibOFX)" ON )
option ( WITH_PYTHON "enable python plugin and bindings" OFF )
option ( ENABLE_BINRELOC "compile with binary relocation support" ON )
option ( ENABLE_REGISTER2 "compile with register2 enabled" OFF )
option ( DISABLE_NLS "do not use Native Language Support" OFF )
option ( DISABLE_DEPRECATED_GLIB "don't use deprecated glib functions" OFF )
option ( DISABLE_DEPRECATED_GTK "don't use deprecated gtk, gdk or gdk-pixbuf functions" OFF )
option ( DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF )
option ( ALLOW_OLD_GETTEXT "allow to configure build with a gettext version older than 0.19.6. Some files will not be translated!" OFF )
2010-03-04 11:48:36 -06:00
# ############################################################
2015-12-07 11:17:08 -06:00
# These are also settable from the command line in a similar way.
2010-03-27 15:27:10 -05:00
2018-03-17 19:25:39 -05:00
# Use gsettings-desktop-schemas for a better integration with GNOME
2018-05-03 16:18:15 -05:00
set ( COMPILE_GSCHEMAS ON CACHE BOOL "Compile the GSettings schema" )
2018-03-17 19:25:39 -05:00
2018-05-03 16:18:15 -05:00
set ( GNUCASH_BUILD_ID "" CACHE STRING "Overrides the GnuCash build identification (Build ID) which defaults to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package management based version number instead" )
2018-01-31 09:16:59 -06:00
# GENERATE_SWIG_WRAPPERS - Controls whether to generate the swig wrappers for guile and python. If not set the wrappers will only be generated when building from a git worktree, commented out here, but will be evaluated later on in this file
2017-12-05 16:48:45 -06:00
# Check that all of the absolute install paths are inside
# ${CMAKE_INSTALL_PREFIX}. If they're not, disable binreloc as it
# won't be able to find paths that aren't relative to the location of
# the executable.
foreach ( install_dir ${ CMAKE_INSTALL_FULL_BINDIR }
$ { C M A K E _ I N S T A L L _ F U L L _ S Y S C O N F D I R } $ { C M A K E _ I N S T A L L _ F U L L _ D A T A R O O T D I R }
$ { C M A K E _ I N S T A L L _ F U L L _ D A T A D I R } $ { C M A K E _ I N S T A L L _ F U L L _ L I B D I R } )
string ( FIND ${ install_dir } ${ CMAKE_INSTALL_PREFIX } in_prefix )
if ( in_prefix EQUAL -1 )
set ( ENABLE_BINRELOC OFF )
message ( WARNING "${install_dir} is set outside of the intallation prefix ${CMAKE_INSTALL_PREFIX}. That will break relocation so ENABLE_BINRELOC is set to off. With relocation disabled GnuCash will run only in its configured install location. You must set GNC_UNINSTALLED=1 and GNC_BUILDDIR=/path/to/builddir to run from the build directory. GnuCash will not run from a DESTDIR." )
break ( )
endif ( )
endforeach ( )
# GnuCash installs two files in ${CMAKE_INSTALL_SYSCONFDIR}
2018-05-03 16:18:15 -05:00
set ( BINDIR ${ CMAKE_INSTALL_BINDIR } CACHE STRING "user executables" )
set ( SYSCONFDIR ${ CMAKE_INSTALL_SYSCONFDIR } CACHE STRING "read-only single-machine data" )
set ( DATAROOTDIR ${ CMAKE_INSTALL_DATAROOTDIR } CACHE STRING "read-only arch.-independent data root" )
set ( DATADIR ${ CMAKE_INSTALL_DATADIR } CACHE STRING "read-only architecture-independent data" )
set ( LIBDIR ${ CMAKE_INSTALL_LIBDIR } CACHE STRING "object code libraries" )
set ( LOCALEDIR ${ DATAROOTDIR } /locale CACHE STRING "locale-dependent data" )
set ( GNC_HELPDIR ${ DATADIR } CACHE STRING "where to store help files" )
set ( DATADIRNAME share )
set ( GNC_SYSTEM_XDG_DATA_DIRS /usr/local/share /usr/share )
set ( GNC_DBD_DIR ${ CMAKE_PREFIX_LIBDIR } /dbd CACHE PATH "specify location of libdbi drivers" )
set ( PKGLIBDIR ${ CMAKE_INSTALL_LIBDIR } /gnucash )
set ( TEST_MYSQL_URL "" CACHE STRING "MySQL database URL for testing" )
set ( TEST_PGSQL_URL "" CACHE STRING "PgSQL database URL for testing" )
set ( DATADIR_BUILD ${ CMAKE_BINARY_DIR } / ${ DATADIRNAME } )
string ( REPLACE ${ CMAKE_INSTALL_PREFIX } "" LIBDIR_BUILD ${ LIBDIR } )
set ( LIBDIR_BUILD ${ CMAKE_BINARY_DIR } / ${ LIBDIR_BUILD } )
set ( SYSCONFDIR_BUILD ${ CMAKE_BINARY_DIR } /etc )
set ( LIBEXECDIR_BUILD ${ CMAKE_BINARY_DIR } /libexec )
set ( BINDIR_BUILD ${ CMAKE_BINARY_DIR } /bin )
set ( SHELL_FROM_ENV $ENV{ SHELL } )
set ( SHELL /bin/bash )
2017-07-22 15:28:01 -05:00
#We need to distinguish between MinGW.org and MinGW-w64:
2018-05-03 16:18:15 -05:00
if ( MINGW )
string ( FIND ${ CMAKE_C_COMPILER } "msys2" IS_MSYS2 )
if ( ${ IS_MSYS2 } GREATER_EQUAL 0 )
set ( MINGW64 ON )
endif ( )
endif ( MINGW )
if ( MINGW AND NOT MINGW64 ) # /bin/bash will work fine on MinGW
set ( SHELL ${ CMAKE_PREFIX_PATH } /mingw/msys/1.0/bin/bash.exe )
endif ( )
if ( SHELL_FROM_ENV ) # Replacing this with if ($ENV{SHELL}) doesn't work.
set ( SHELL ${ SHELL_FROM_ENV } )
endif ( )
2015-12-07 11:17:08 -06:00
2016-08-26 13:59:33 -05:00
# Determine whether we are building from a VCS or from a tarball
2018-05-03 16:18:15 -05:00
execute_process (
2016-08-26 13:59:33 -05:00
C O M M A N D $ { S H E L L } $ { C M A K E _ S O U R C E _ D I R } / u t i l / g n c - v c s - i n f o - t $ { C M A K E _ S O U R C E _ D I R }
R E S U L T _ V A R I A B L E G N C _ V C S _ I N F O _ R E S U L T
O U T P U T _ V A R I A B L E G N C _ V C S _ I N F O _ O U T P U T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
2018-05-03 16:18:15 -05:00
set ( BUILDING_FROM_VCS "NO" )
if ( GNC_VCS_INFO_RESULT EQUAL 0 )
set ( BUILDING_FROM_VCS "YES" )
# if building from VCS, we need git
2018-01-30 14:24:22 -06:00
find_package ( Git )
2018-05-03 16:18:15 -05:00
if ( NOT GIT_FOUND )
message ( SEND_ERROR "Looks like we're building from version control, but can't find git executable. Please set GIT_EXECUTABLE." )
endif ( )
endif ( )
2018-01-30 14:24:22 -06:00
2018-01-31 09:16:59 -06:00
# Determine whether to generate the swig wrappers.
# By default they will only be generated when building from a git worktree
set ( GENERATE_SWIG_WRAPPERS ${ BUILDING_FROM_VCS } CACHE BOOL "Controls whether to generate the swig wrappers for guile and python. If not set the wrappers will only be generated when building from a git worktree" )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
if ( WIN32 )
2015-12-07 11:17:08 -06:00
# Help Windows find the various dependencies. We assume here that the standard advice for building
# GnuCash has been followed and that these dependencies live underneath something like C:/GCDEV, which
# should be provided as CMAKE_PREFIX_PATH on the CMake command line:
# cmake -D CMAKE_PREFIX_PATH=c/gcdev -G "MSYS Makefiles" path/to/gnucash/sources
#
2018-05-03 16:18:15 -05:00
set ( CMAKE_C_IMPLICIT_LINK_LIBRARIES "" )
set ( CMAKE_FRAMEWORK_PATH_TMP ${ CMAKE_PREFIX_PATH } )
set ( DEV_SUBDIRS aqbanking gnome guile gwenhywfar libgsf libofx libsoup libxslt webkit )
foreach ( subdir ${ DEV_SUBDIRS } )
list ( APPEND CMAKE_FRAMEWORK_PATH_TMP ${ CMAKE_PREFIX_PATH } / ${ subdir } )
endforeach ( )
2015-12-07 11:17:08 -06:00
# Setting CMAKE_FRAMEWORK_PATH, which is intended for OS X, is a terrible hack here. But I don't
# want to mess with CMAKE_PREFIX_PATH.
2018-05-03 16:18:15 -05:00
set ( CMAKE_FRAMEWORK_PATH "${CMAKE_FRAMEWORK_PATH_TMP}" )
#set(PKG_CONFIG_EXECUTABLE ${CMAKE_PREFIX_PATH}/gnome/bin/pkg-config.exe)
set ( SWIG_EXECUTABLE swig )
#set(SWIG_EXECUTABLE ${CMAKE_PREFIX_PATH}/swig/swig.exe)
find_path ( REGEX_INCLUDE_PATH regex.h )
find_path ( REGEX_LIB_PATH libregex.dll.a )
set ( REGEX_LDFLAGS "-L${REGEX_LIB_PATH} -lregex" )
#set(LIBXSLT_INCLUDE_DIR ${CMAKE_PREFIX_PATH}/libxslt/include)
#set(LIBXSLT_XSLTPROC_EXECUTABLE ${CMAKE_PREFIX_PATH}/libxslt/bin/xsltproc)
2016-08-20 15:14:34 -05:00
#Prevent creating a console window on startup.
2018-05-03 16:18:15 -05:00
set ( CMAKE_EXE_LINKER_FLAGS -mwindows )
endif ( WIN32 )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
find_package ( PkgConfig REQUIRED )
2015-12-07 11:17:08 -06:00
# The default FindPkgConfig.make code has a bug in how the setting of PKG_CONFIG_PATH is handled.
2017-08-10 06:56:00 -05:00
# The common/cmake_modules/GncFindPkgConfig.cmake file overrides a couple of macros in FindPkgConfig to fix.
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
include ( GncFindPkgConfig )
2010-03-04 11:48:36 -06:00
2018-05-03 16:18:15 -05:00
if ( NOT PKG_CONFIG_FOUND )
message ( SEND_ERROR "pkg-config not found, but is required" )
endif ( NOT PKG_CONFIG_FOUND )
2010-03-04 11:48:36 -06:00
# glib et al.
2018-05-03 16:18:15 -05:00
gnc_pkg_check_modules ( GLIB2 REQUIRED glib-2.0>=2.40 )
gnc_pkg_check_modules ( GIO REQUIRED gio-2.0 )
gnc_pkg_check_modules ( GOBJECT REQUIRED gobject-2.0>=2.20 )
gnc_pkg_check_modules ( GMODULE REQUIRED gmodule-2.0>=2.20 )
gnc_pkg_check_modules ( GTHREAD REQUIRED gthread-2.0>=2.20 )
gnc_pkg_check_modules ( LIBXML2 REQUIRED libxml-2.0>=2.7.0 )
gnc_pkg_check_modules ( LIBXSLT REQUIRED libxslt )
2018-06-07 16:17:49 -05:00
if ( WITH_GNUCASH )
if ( WIN32 OR APPLE )
gnc_pkg_check_modules ( WEBKIT1 REQUIRED webkitgtk-3.0 )
set ( WEBKIT1 1 )
2018-05-03 16:18:15 -05:00
set ( WEBKIT_CFLAGS ${ WEBKIT2_CFLAGS } )
set ( WEBKIT_INCLUDE_DIRS ${ WEBKIT1_INCLUDE_DIRS } )
set ( WEBKIT_LDFLAGS ${ WEBKIT1_LDFLAGS } )
set ( WEBKIT_LIBRARIES ${ WEBKIT1_LIBRARIES } )
2018-06-07 16:17:49 -05:00
else ( WIN32 OR APPLE )
gnc_pkg_check_modules ( WEBKIT2_4 webkit2gtk-4.0 )
if ( NOT WEBKIT2_4_FOUND )
gnc_pkg_check_modules ( WEBKIT2_3 REQUIRED webkit2gtk-3.0 )
set ( WEBKIT2_3 1 )
set ( WEBKIT_CFLAGS ${ WEBKIT2_3_CFLAGS } )
set ( WEBKIT_INCLUDE_DIRS ${ WEBKIT2_3_INCLUDE_DIRS } )
set ( WEBKIT_LDFLAGS ${ WEBKIT2_3_LDFLAGS } )
set ( WEBKIT_LIBRARIES ${ WEBKIT2_3_LIBRARIES } )
else ( NOT WEBKIT2_4_FOUND )
set ( WEBKIT2_4 1 )
set ( WEBKIT_CFLAGS ${ WEBKIT2_4_CFLAGS } )
set ( WEBKIT_INCLUDE_DIRS ${ WEBKIT2_4_INCLUDE_DIRS } )
set ( WEBKIT_LDFLAGS ${ WEBKIT2_4_LDFLAGS } )
set ( WEBKIT_LIBRARIES ${ WEBKIT2_4_LIBRARIES } )
endif ( NOT WEBKIT2_4_FOUND )
endif ( WIN32 OR APPLE )
2018-05-03 16:18:15 -05:00
gnc_pkg_check_modules ( GTK3 REQUIRED gtk+-3.0>=3.10.0 )
endif ( WITH_GNUCASH )
gnc_pkg_check_modules ( ZLIB REQUIRED zlib )
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" )
2010-03-11 15:59:45 -06:00
# Disable the obnoxious min/max macros in MSVC - we want to use the
# function versions of them.
2018-05-03 16:18:15 -05:00
add_definitions ( -DNOMINMAX )
endif ( MSVC )
2010-03-04 11:48:36 -06:00
2018-05-03 16:18:15 -05:00
find_path ( LIBINTL_INCLUDE_PATH NAMES libintl.h
2010-03-04 11:48:36 -06:00
P A T H S / u s r / i n c l u d e / o p t / g n o m e / i n c l u d e )
2018-05-03 16:18:15 -05:00
find_library ( LIBINTL_LIBRARY NAMES intl )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
find_path ( LTDL_INCLUDE_PATH NAMES ltdl.h PATHS /usr/include )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
if ( NOT LTDL_INCLUDE_PATH-NOTFOUND )
set ( HAVE_LTDL_H 1 )
endif ( )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
find_program ( GLIB_COMPILE_SCHEMAS glib-compile-schemas HINTS ${ CMAKE_PREFIX_PATH } /gnome/bin )
if ( NOT GLIB_COMPILE_SCHEMAS )
message ( SEND_ERROR "Can't find glib-compile-schemas program. Please set GLIB_COMPILE_SCHEMAS." )
endif ( NOT GLIB_COMPILE_SCHEMAS )
2015-12-07 11:17:08 -06:00
2018-02-27 15:21:00 -06:00
if ( ALLOW_OLD_GETTEXT )
find_package ( Gettext REQUIRED )
else ( ALLOW_OLD_GETTEXT )
find_package ( Gettext 0.19.6 )
if ( NOT GETTEXT_FOUND )
2018-02-28 09:48:49 -06:00
message ( FATAL_ERROR " Note the build can be configured with an older version of gettext by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated:
2018-02-27 15:21:00 -06:00
- g n u c a s h . desktop ( requires at least gettext 0.19 )
- g n u c a s h . a p p d a t a . xml ( requires at least gettext 0.19.6 ) " )
endif ( NOT GETTEXT_FOUND )
endif ( ALLOW_OLD_GETTEXT )
if ( ${ GETTEXT_VERSION_STRING } VERSION_LESS 0.19 )
message ( WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19 in order to handle translation of the gnucash.desktop file. The build will be configured with an untranslated gnucash.desktop file." )
endif ( )
if ( ${ GETTEXT_VERSION_STRING } VERSION_LESS 0.19.6 )
message ( WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19.6 in order to handle translation of the gnucash.appdata file. The build will be configured with an untranslated gnucash.appdata file." )
endif ( )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
find_path ( REGEX_INCLUDE_PATH NAMES regex.h
2010-03-04 11:48:36 -06:00
P A T H S / u s r / i n c l u d e / o p t / g n o m e / i n c l u d e )
2018-05-03 16:18:15 -05:00
find_library ( REGEX_LIBRARY NAMES regex )
if ( WIN32 )
2017-08-27 19:27:58 -05:00
message ( STATUS "Looking for htmlhelp.h and htmlhelp.a" )
2018-05-03 16:18:15 -05:00
find_path ( HTMLHELP_INCLUDE_PATH NAMES htmlhelp.h )
find_library ( HTMLHELP_LIBRARY htmlhelp )
endif ( WIN32 )
2010-03-04 11:48:36 -06:00
# ############################################################
# SWIG
2018-05-03 16:18:15 -05:00
if ( GENERATE_SWIG_WRAPPERS )
2018-08-10 14:57:46 -05:00
find_package ( SWIG 2.0.10 REQUIRED )
2018-05-03 16:18:15 -05:00
include ( ${ SWIG_USE_FILE } )
2018-11-30 01:40:35 -06:00
string ( REGEX MATCH "^[0-9]+[.]" SWIG_MAJOR ${ SWIG_VERSION } )
2018-05-03 16:18:15 -05:00
endif ( )
2010-03-04 11:48:36 -06:00
2015-12-07 11:17:08 -06:00
# Find Guile and determine which version we are using.
2017-12-19 16:13:01 -06:00
# Look for guile versions in this order: 2.2 > 2.0
2015-12-07 11:17:08 -06:00
2010-03-06 05:00:54 -06:00
# guile library and include dir
2018-05-03 16:18:15 -05:00
gnc_pkg_check_modules ( GUILE22 guile-2.2 QUIET )
if ( GUILE22_FOUND ) # found guile-2.2
add_definitions ( -DHAVE_GUILE22 )
set ( HAVE_GUILE2 TRUE )
set ( GUILE_EFFECTIVE_VERSION 2.2 )
set ( GUILE_INCLUDE_DIRS ${ GUILE22_INCLUDE_DIRS } )
set ( GUILE_LDFLAGS ${ GUILE22_LDFLAGS } )
find_program ( GUILD_EXECUTABLE NAMES guild2.2 guild )
if ( NOT GUILD_EXECUTABLE )
message ( SEND_ERROR "The guild executable was not found, but is required. Please set GUILD_EXECUTABLE." )
endif ( NOT GUILD_EXECUTABLE )
message ( STATUS "Using guile-2.2.x" )
find_program ( GUILE_EXECUTABLE NAMES guile2.2 guile )
else ( GUILE22_FOUND )
gnc_pkg_check_modules ( GUILE2 guile-2.0>=2.0.9 QUIET )
if ( GUILE2_FOUND ) # found guile-2.0
add_definitions ( -DHAVE_GUILE20 )
set ( HAVE_GUILE2 TRUE )
set ( GUILE_EFFECTIVE_VERSION 2.0 )
set ( GUILE_INCLUDE_DIRS ${ GUILE2_INCLUDE_DIRS } )
set ( GUILE_LDFLAGS ${ GUILE2_LDFLAGS } )
find_program ( GUILD_EXECUTABLE NAMES guild2.0 guild )
if ( NOT GUILD_EXECUTABLE )
message ( SEND_ERROR "The guild executable was not found, but is required. Please set GUILD_EXECUTABLE." )
endif ( NOT GUILD_EXECUTABLE )
message ( STATUS "Using guile-2.0.x" )
find_program ( GUILE_EXECUTABLE NAMES guile2.0 guile )
else ( GUILE2_FOUND )
message ( FATAL_ERROR "Neither guile 2.2 nor guile 2.0 were found GnuCash can't run without one of them. Ensure that one is installed and can be found with pgk-config." )
endif ( GUILE2_FOUND )
endif ( GUILE22_FOUND )
if ( NOT GUILE_EXECUTABLE )
message ( SEND_ERROR "The guile executable was not found, but is required. Please set GUILE_EXECUTABLE." )
endif ( NOT GUILE_EXECUTABLE )
2016-01-27 14:50:51 -06:00
2018-02-20 20:06:06 -06:00
# Test that guile has SRFI-64. This is required for some unit tests.
execute_process ( COMMAND ${ GUILE_EXECUTABLE } -c "(use-modules (srfi srfi-64))"
R E S U L T _ V A R I A B L E G N C _ S R F I 6 4 _ R E S U L T
E R R O R _ Q U I E T
)
if ( GNC_SRFI64_RESULT EQUAL 0 )
message ( STATUS "Using guile SRFI-64" )
set ( HAVE_SRFI64 TRUE )
endif ( )
2018-07-27 17:15:57 -05:00
# Test that guile has textual-ports. This is required for the stress test.
execute_process ( COMMAND ${ GUILE_EXECUTABLE } -c "(use-modules (ice-9 textual-ports))"
R E S U L T _ V A R I A B L E G N C _ T E X T _ P O R T S _ R E S U L T
E R R O R _ Q U I E T
)
if ( GNC_TEXT_PORTS_RESULT EQUAL 0 )
message ( STATUS "Using guile textual-ports" )
set ( HAVE_TEXT_PORTS TRUE )
endif ( )
2015-12-07 11:17:08 -06:00
# ############################################################
2018-05-03 16:18:15 -05:00
if ( WITH_AQBANKING )
gnc_pkg_check_modules ( GWENHYWFAR REQUIRED gwenhywfar )
gnc_pkg_check_modules ( AQBANKING REQUIRED aqbanking )
if ( WITH_GNUCASH )
gnc_pkg_check_modules ( KTOBLZCHECK ktoblzcheck )
if ( KTOBLZCHECK_FOUND )
set ( HAVE_KTOBLZCHECK_H 1 )
endif ( KTOBLZCHECK_FOUND )
gnc_pkg_check_modules ( GWEN_GTK3 gwengui-gtk3 )
if ( GWEN_GTK3_FOUND AND GWEN_GTK3_VERSION VERSION_GREATER "4.20.0" )
set ( HAVE_GWEN_GTK3 1 CACHE BOOL "True if gwen-gtk3.pc exists" )
endif ( )
endif ( WITH_GNUCASH )
endif ( WITH_AQBANKING )
if ( WITH_OFX )
gnc_pkg_check_modules ( LIBOFX REQUIRED libofx )
include ( CheckCXXSourceRuns )
if ( WIN32 )
set ( CMAKE_REQUIRED_LIBRARIES "-L ${CMAKE_PREFIX_PATH}/libofx/lib -lofx" )
else ( WIN32 )
set ( CMAKE_REQUIRED_LIBRARIES "-lofx" )
endif ( WIN32 )
2016-10-20 12:40:18 -05:00
CHECK_CXX_SOURCE_RUNS ( "
2016-09-11 16:48:24 -05:00
#include <time.h>
#include <stdlib.h>
#include <string>
e x t e r n t i m e _ t ofxdate_to_time_t ( const std::string ofxdate ) ;
i n t main ( int argc, char** argv )
{
c o n s t s t d : : s t r i n g t i m e s t r = \ " 2 0 1 6 0 3 1 9 0 0 0 0 0 0 \ " ;
s t r u c t t m t s ;
t s . t m _ y e a r = 1 1 6 ;
t s . t m _ m o n = 2 ;
t s . t m _ m d a y = 1 9 ;
2016-10-20 12:40:18 -05:00
#ifdef _WIN32
putenv ( \"TZ=PST-8PDT-7,M 4.1.0/0,M 10.6.0/0\ " ) ;
#else
setenv ( \"TZ\", \"PST 08P DT 07 M 4.1.0, M 10.6.0\ " , 1 ) ;
#endif
2016-09-11 16:48:24 -05:00
t i m e _ t t = ofxdate_to_time_t ( timestr ) ;
if ( t == mktime(&ts ) )
exit ( 1 ) ;
exit ( 0 ) ;
}
" H A V E _ O F X _ B U G _ 3 9 )
2018-05-03 16:18:15 -05:00
set ( HAVE_OFX_BUG_39 ${ HAVE_OFX_BUG_39 } )
set ( CMAKE_REQUIRED_LIBRARIES )
endif ( WITH_OFX )
2015-12-07 11:17:08 -06:00
# ############################################################
2018-05-03 16:18:15 -05:00
if ( APPLE )
execute_process (
2017-07-31 01:29:42 -05:00
C O M M A N D $ { P K G _ C O N F I G _ E X E C U T A B L E } - - v a r i a b l e = t a r g e t s g d k - 3 . 0
2015-12-07 11:17:08 -06:00
O U T P U T _ V A R I A B L E T A R G E T _ R E S U L T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
2018-05-03 16:18:15 -05:00
if ( TARGET_RESULT STREQUAL "quartz" )
set ( GNC_PLATFORM_COCOA 1 )
set ( GDK_QUARTZ 1 )
gnc_pkg_check_modules ( GTK_MAC gtk-mac-integration-gtk3 )
if ( GTK_MAC_FOUND )
set ( MAC_INTEGRATION 1 )
find_library ( COCOA_LIBRARY Cocoa )
find_library ( SECURITY_LIBRARY Security )
find_library ( CARBON_LIBRARY Carbon )
set ( OSX_EXTRA_COMPILE_FLAGS $< $<COMPILE_LANGUAGE:C > :-xobjective-c> $< $<COMPILE_LANGUAGE:CXX > :-xobjective-c++> )
set ( OSX_EXTRA_LIBRARIES objc ${ COCOA_LIBRARY } ${ SECURITY_LIBRARY } ${ CARBON_LIBRARY } )
endif ( GTK_MAC_FOUND )
endif ( )
endif ( APPLE )
# find_package(LibXslt) eats PKG_CONFIG_EXECUTABLE, so preserve it.
set ( GNC_PKG_CONFIG_EXE ${ PKG_CONFIG_EXECUTABLE } )
2010-03-04 11:48:36 -06:00
# ############################################################
2015-04-22 15:33:58 -05:00
# xsltproc
2018-05-03 16:18:15 -05:00
find_package ( LibXslt )
2015-04-22 15:33:58 -05:00
2018-05-03 16:18:15 -05:00
if ( NOT LIBXSLT_FOUND )
message ( FATAL_ERROR "libxslt library not found." )
endif ( NOT LIBXSLT_FOUND )
2018-01-23 18:04:28 -06:00
if ( ${ LIBXSLT_XSLTPROC_EXECUTABLE } STREQUAL "LIBXSLT_XSLTPROC_EXECUTABLE-NOTFOUND" )
message ( FATAL_ERROR "xsltproc executable not found" )
endif ( )
2015-04-22 15:33:58 -05:00
# ############################################################
2018-05-03 16:18:15 -05:00
set ( PKG_CONFIG_EXECUTABLE ${ GNC_PKG_CONFIG_EXE } )
2015-04-22 15:33:58 -05:00
2010-03-27 15:27:10 -05:00
# libdbi
2018-05-03 16:18:15 -05:00
find_path ( LIBDBI_INCLUDE_PATH dbi/dbi.h )
find_library ( LIBDBI_LIBRARY dbi )
find_library ( LIBDBI_DRIVERS_DIR
2017-12-10 14:51:24 -06:00
N A M E S d b d m y s q l d b d p g s q l d b d s q l i t e 3 N A M E S _ P E R _ D I R
P A T H _ S U F F I X E S d b d l i b d b i - d r i v e r s / d b d
H I N T S L I B D B I _ L I B R A R Y
P A T H S G N C _ D B D _ D I R
D O C " L i b d b i D r i v e r s D i r e c t o r y " )
2018-05-03 16:18:15 -05:00
if ( WITH_SQL )
if ( NOT LIBDBI_INCLUDE_PATH )
message ( SEND_ERROR "Include file <dbi/dbi.h> was not found - did you install libdbi0-dev or libdbi-dev?" )
endif ( NOT LIBDBI_INCLUDE_PATH )
if ( NOT LIBDBI_LIBRARY )
message ( SEND_ERROR "Library libdbi was not found" )
endif ( NOT LIBDBI_LIBRARY )
set ( HAVE_DBI_DBI_H 1 )
if ( NOT LIBDBI_DRIVERS_DIR )
message ( SEND_ERROR "No libdbi drivers found, SQL tests will fail." )
else ( )
2017-12-10 14:51:24 -06:00
get_filename_component ( drivers_dir ${ LIBDBI_DRIVERS_DIR } DIRECTORY )
set ( LIBDBI_DRIVERS_DIR ${ drivers_dir } CACHE FILEPATH "Directory containing the libdbi driver modules." FORCE )
2018-05-03 16:18:15 -05:00
endif ( )
endif ( WITH_SQL )
2010-03-27 15:27:10 -05:00
# ############################################################
2018-05-03 16:18:15 -05:00
if ( WITH_PYTHON )
find_package ( PythonInterp 3 )
if ( NOT PYTHONINTERP_FOUND )
message ( SEND_ERROR "Python support enabled, but Python interpreter not found." )
endif ( )
2016-08-26 13:59:33 -05:00
2018-05-03 16:18:15 -05:00
if ( PYTHON_VERSION_STRING VERSION_LESS "2.4.0" )
message ( SEND_ERROR "Found python version ${PYTHON_VERSION_STRING}, but it's too old. Need python >= 2.4.0" )
endif ( )
2016-08-26 13:59:33 -05:00
2018-05-03 16:18:15 -05:00
find_package ( PythonLibs 3 )
if ( NOT PYTHONLIBS_FOUND )
message ( SEND_ERROR "Python support enabled, but Python libraries not found." )
endif ( )
2017-09-11 15:44:41 -05:00
# Determine where to install the python libraries.
2018-05-03 16:18:15 -05:00
execute_process (
2018-03-15 03:35:31 -05:00
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } - c " f r o m d i s t u t i l s i m p o r t s y s c o n f i g ; print ( sysconfig.get_python_lib(prefix=' ${ CMAKE_INSTALL_PREFIX } ', plat_specific=True ) ) "
2017-09-11 15:44:41 -05:00
R E S U L T _ V A R I A B L E P Y T H O N _ S Y S C O N F I G _ R E S U L T
O U T P U T _ V A R I A B L E P Y T H O N _ S Y S C O N F I G _ O U T P U T
E R R O R _ V A R I A B L E P Y T H O N _ S Y S C O N F I G _ E R R O R
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
E R R O R _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
2018-05-03 16:18:15 -05:00
if ( PYTHON_SYSCONFIG_RESULT )
message ( SEND_ERROR "Could not determine Python site-package directory:\n${PYTHON_SYSCONFIG_ERROR}" )
endif ( )
string ( REPLACE ${ CMAKE_INSTALL_PREFIX } ${ CMAKE_BINARY_DIR } PYTHON_SYSCONFIG_BUILD ${ PYTHON_SYSCONFIG_OUTPUT } )
endif ( )
2016-08-26 13:59:33 -05:00
2018-05-03 16:18:15 -05:00
find_package ( Perl )
2010-03-04 11:48:36 -06:00
2015-12-07 11:17:08 -06:00
if ( NOT PERL_FOUND )
2018-05-03 16:18:15 -05:00
message ( SEND_ERROR "Perl executable not found. Please set PERL_EXECUTABLE." )
endif ( NOT PERL_FOUND )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
get_filename_component ( PERL_DIR ${ PERL_EXECUTABLE } DIRECTORY )
2016-07-16 14:12:58 -05:00
2018-05-03 16:18:15 -05:00
find_program ( POD2MAN_EXECUTABLE pod2man HINTS ${ PERL_DIR } )
2015-12-07 11:17:08 -06:00
2017-03-13 13:55:09 -05:00
#ICU
2018-05-03 16:18:15 -05:00
gnc_pkg_check_modules ( ICU4C REQUIRED icu-uc )
gnc_pkg_check_modules ( ICU4C_I18N REQUIRED icu-i18n )
2017-03-13 13:55:09 -05:00
2018-06-13 00:19:48 -05:00
GNC_PKG_CHECK_MODULES ( LIBSECRET libsecret-1>=0.18 )
IF ( LIBSECRET_FOUND )
SET ( HAVE_LIBSECRET ON )
ENDIF ( LIBSECRET_FOUND )
2015-12-07 11:17:08 -06:00
#BOOST
2018-05-03 16:18:15 -05:00
set ( Boost_USE_MULTITHREADED ON )
set ( Boost_FIND_QUIETLY ON )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
if ( NOT DEFINED ${ BOOST_ROOT } )
set ( BOOST_ROOT $ENV{ BOOST_ROOT } )
endif ( )
find_package ( Boost 1.54.0 REQUIRED COMPONENTS date_time regex locale filesystem system )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
if ( Boost_FOUND )
2015-12-07 11:17:08 -06:00
include_directories ( ${ Boost_INCLUDE_DIRS } )
2018-05-03 16:18:15 -05:00
set ( HAVE_BOOST 1 )
else ( Boost_FOUND )
message ( SEND_ERROR "Boost 1.54.0 or later is not installed, and is required. Please install it and ensure that the following libraries are built: chrono, date_time, filesystem, log, program_options, regex, signals, system, and test." )
endif ( Boost_FOUND )
2011-05-03 15:08:34 -05:00
2010-03-04 11:48:36 -06:00
# Compiler flags
2015-12-07 11:17:08 -06:00
2018-05-09 10:20:13 -05:00
include ( CheckCCompilerFlag )
2018-10-27 18:19:40 -05:00
include ( CheckCXXCompilerFlag )
2018-05-09 10:20:13 -05:00
check_c_compiler_flag ( -Wstringop-truncation have_stringop_truncation )
if ( have_stringop_truncation )
set ( HAVE_STRINGOP_TRUNCATION TRUE )
endif ( )
2018-11-30 01:11:42 -06:00
if ( SWIG_MAJOR LESS 3 )
2018-10-27 18:19:40 -05:00
check_cxx_compiler_flag ( -Wno-register have_no_register )
if ( have_no_register )
set ( REGISTER_CXXFLAG -Wno-register )
else ( )
check_cxx_compiler_flag ( -Wno-deprecated-register have_no_dep_register )
if ( have_no_dep_register )
set ( REGISTER_CXXFLAG -Wno-deprecated-register )
2018-02-03 09:54:37 -06:00
endif ( )
2018-10-27 18:19:40 -05:00
endif ( )
2018-11-30 01:11:42 -06:00
endif ( )
2018-09-08 15:53:25 -05:00
add_definitions ( -D_GNU_SOURCE )
2015-12-07 11:17:08 -06:00
# Also, set the C++ version to c++11
2018-05-03 16:18:15 -05:00
set ( CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}" ) # FIXME: should be -std=c++11
if ( UNIX )
set ( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-unused ${CMAKE_C_FLAGS}" )
2018-05-09 10:39:29 -05:00
set ( CMAKE_C_FLAGS "-Wno-deprecated-declarations -std=gnu11 -Wno-error=parentheses ${CMAKE_C_FLAGS}" )
2018-09-01 04:43:04 -05:00
set ( CMAKE_CXX_FLAGS "-Werror -Wall -Wmissing-declarations -Wno-unused -Wno-error=parentheses ${CMAKE_CXX_FLAGS}" )
2018-10-27 18:19:40 -05:00
set ( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations ${REGISTER_CXXFLAG} ${CMAKE_CXX_FLAGS}" )
2018-05-03 16:18:15 -05:00
set ( CMAKE_C_FLAGS_RELEASE "-O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${CMAKE_C_FLAGS}" )
endif ( UNIX )
if ( MINGW )
set ( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wno-unused -Wno-error=deprecated-declarations -std=gnu11 ${CMAKE_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "-DWINVER=0x0500 -D_EMULATE_GLIBC=0 ${CMAKE_CXX_FLAGS}" ) # Workaround for bug in gtest on mingw, see https://github.com/google/googletest/issues/893 and https://github.com/google/googletest/issues/920
endif ( MINGW )
if ( APPLE AND WITH_GNUCASH )
set ( CMAKE_MACOSX_RPATH ON )
set ( CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" )
endif ( APPLE AND WITH_GNUCASH )
if ( UNIX )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}:${CMAKE_INSTALL_FULL_LIBDIR}/gnucash" )
endif ( )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
set ( BUILD_SHARED_LIBS ON )
2015-12-07 11:17:08 -06:00
2017-02-01 21:48:46 -06:00
# Most libraries are installed to lib/gnucash, so set that as the default.
# For the handful that are installed to lib, we override the properies below
# (after the targets have been read in).
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ LIBDIR_BUILD } /gnucash )
if ( XCODE_VERSION )
2017-02-01 21:48:46 -06:00
# FIXME: These settings break the ability to manipulate different configurations (Debug,
# FIXME: Release, etc.) in Xcode. We'll need to change the module loading C code if
# we want to support multi config.
2018-05-03 16:18:15 -05:00
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${ LIBDIR_BUILD } /gnucash )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${ LIBDIR_BUILD } /gnucash )
endif ( )
2010-03-04 11:48:36 -06:00
2017-02-01 21:48:46 -06:00
# For binarines
2018-05-03 16:18:15 -05:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /bin )
if ( XCODE_VERSION )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${ CMAKE_BINARY_DIR } /bin )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${ CMAKE_BINARY_DIR } /bin )
endif ( )
2017-02-01 21:48:46 -06:00
# ############################################################
2016-01-18 10:33:34 -06:00
2018-05-03 16:18:15 -05:00
gnc_gtest_configure ( )
2016-01-18 10:33:34 -06:00
# There are targets that need to build before tests will run
2018-05-03 16:18:15 -05:00
add_custom_target ( check
2016-01-26 09:00:54 -06:00
C O M M A N D $ { C M A K E _ C T E S T _ C O M M A N D }
)
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
set ( gnucash_DOCS
2015-12-07 11:17:08 -06:00
A U T H O R S
2015-12-26 10:55:15 -06:00
C h a n g e L o g . 1 9 9 9
C h a n g e L o g . 2 0 0 0
C h a n g e L o g . 2 0 0 1
C h a n g e L o g . 2 0 0 2
2015-12-07 11:17:08 -06:00
C h a n g e L o g . 2 0 0 3
C h a n g e L o g . 2 0 0 4
C h a n g e L o g . 2 0 0 5
C h a n g e L o g . 2 0 0 6
C h a n g e L o g . 2 0 0 7
C h a n g e L o g . 2 0 0 8
C h a n g e L o g . 2 0 0 9
C h a n g e L o g . 2 0 1 0
C h a n g e L o g . 2 0 1 1
C h a n g e L o g . 2 0 1 2
C h a n g e L o g . 2 0 1 3
C h a n g e L o g . 2 0 1 4
2017-09-06 13:43:43 -05:00
C h a n g e L o g . 2 0 1 5
C h a n g e L o g . 2 0 1 6
2017-12-31 10:51:21 -06:00
C h a n g e L o g . 2 0 1 7
2015-12-07 11:17:08 -06:00
D O C U M E N T E R S
H A C K I N G
L I C E N S E
N E W S
R E A D M E . d e p e n d e n c i e s
)
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
install ( FILES ${ gnucash_DOCS } DESTINATION ${ CMAKE_INSTALL_DOCDIR } )
2015-12-07 11:17:08 -06:00
2017-08-09 10:30:59 -05:00
# ############################################################
# Create config.h
2018-05-03 16:18:15 -05:00
set ( GETTEXT_PACKAGE "gnucash" )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
if ( WIN32 )
if ( MINGW )
set ( HAVE_SCANF_LLD 1 )
else ( )
set ( HAVE_SCANF_I64D 1 )
endif ( )
set ( HAVE_HTMLHELPW 1 )
endif ( WIN32 )
check_include_files ( dirent.h HAVE_DIRENT_H )
check_include_files ( dlfcn.h HAVE_DLFCN_H )
check_include_files ( glob.h HAVE_GLOB_H )
check_include_files ( inttypes.h HAVE_INTTYPES_H )
check_include_files ( limits.h HAVE_LIMITS_H )
check_include_files ( locale.h HAVE_LOCALE_H )
check_include_files ( memory.h HAVE_MEMORY_H )
check_include_files ( stdint.h HAVE_STDINT_H )
check_include_files ( stdlib.h HAVE_STDLIB_H )
check_include_files ( string.h HAVE_STRING_H )
check_include_files ( strings.h HAVE_STRINGS_H )
check_include_files ( sys/stat.h HAVE_SYS_STAT_H )
check_include_files ( sys/time.h HAVE_SYS_TIME_H )
check_include_files ( sys/times.h HAVE_SYS_TIMES_H )
check_include_files ( sys/types.h HAVE_SYS_TYPES_H )
check_include_files ( sys/wait.h HAVE_SYS_WAIT_H )
check_include_files ( unistd.h HAVE_UNISTD_H )
check_include_files ( utmp.h HAVE_UTMP_H )
check_include_files ( wctype.h HAVE_WCTYPE_H )
2018-09-08 15:53:25 -05:00
test_big_endian ( IS_BIGENDIAN )
if ( IS_BIGENDIAN )
set ( WORDS_BIGENDIAN )
endif ( IS_BIGENDIAN )
2018-05-03 16:18:15 -05:00
if ( NOT DISABLE_NLS )
set ( ENABLE_NLS 1 )
endif ( NOT DISABLE_NLS )
if ( ENABLE_BINRELOC )
if ( UNIX OR MINGW )
set ( BR_PTHREAD 1 )
endif ( UNIX OR MINGW )
endif ( ENABLE_BINRELOC )
if ( UNIX OR MINGW )
set ( HAVE_BIND_TEXTDOMAIN_CODESET 1 )
set ( HAVE_DCGETTEXT 1 )
set ( HAVE_GETTEXT 1 )
set ( HAVE_GETTIMEOFDAY 1 )
set ( HAVE_GUILE 1 )
set ( HAVE_LIBM 1 )
set ( HAVE_MEMCPY 1 )
set ( STDC_HEADERS 1 )
set ( _ALL_SOURCE 1 )
set ( _GNU_SOURCE 1 )
set ( _POSIX_PTHREAD_SEMANTICS 1 )
set ( _TANDEM_SOURCE 1 )
set ( __EXTENSIONS__ 1 )
endif ( UNIX OR MINGW )
if ( UNIX )
set ( HAVE_CHOWN 1 )
set ( HAVE_DLERROR 1 )
set ( HAVE_DLSYM 1 )
set ( HAVE_GETHOSTID 1 )
set ( HAVE_GETHOSTNAME 1 )
set ( HAVE_GETPPID 1 )
set ( HAVE_GETUID 1 )
set ( HAVE_GMTIME_R 1 )
set ( HAVE_LANGINFO_D_FMT 1 )
set ( HAVE_LC_MESSAGES 1 )
set ( HAVE_LIBPTHREAD 1 )
set ( HAVE_LINK 1 )
set ( HAVE_LOCALTIME_R 1 )
set ( HAVE_PTHREAD_MUTEX_INIT 1 )
set ( HAVE_PTHREAD_PRIO_INHERIT 1 )
set ( HAVE_SCANF_LLD 1 )
set ( HAVE_SETENV 1 )
set ( HAVE_STPCPY 1 )
set ( HAVE_STRPTIME 1 )
set ( HAVE_STRUCT_TM_GMTOFF 1 )
set ( HAVE_TIMEGM 1 )
set ( HAVE_TOWUPPER 1 )
set ( GNC_PLATFORM_POSIX 1 )
endif ( UNIX )
if ( WIN32 )
set ( GNC_PLATFORM_WINDOWS 1 )
endif ( WIN32 )
if ( APPLE )
# FIXME: HANDLE gtk-mac-integration-gtk2
set ( GNC_PLATFORM_DARWIN 1 )
set ( GNC_PLATFORM_OSX 1 )
set ( PLATFORM_OSX 1 )
set ( HAVE_OSX_KEYCHAIN 1 )
endif ( APPLE )
if ( GLIB2_VERSION VERSION_GREATER 2.46.0 OR GLIB2_VERSION VERSION_EQUAL 2.46.0 )
set ( HAVE_GLIB_2_46 1 )
endif ( )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
if ( DISABLE_DEPRECATED_GNOME )
set ( GNOME_DISABLE_DEPRECATED 1 )
endif ( DISABLE_DEPRECATED_GNOME )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
if ( DISABLE_DEPRECATED_GTK )
set ( GTK_DISABLE_DEPRECATED 1 )
set ( GDK_DISABLE_DEPRECATED 1 )
set ( GDK_PIXMAP_DISABLE_DEPRECATED 1 )
endif ( DISABLE_DEPRECATED_GTK )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
if ( DISABLE_DEPRECATED_GLIB )
set ( G_DISABLE_DEPRECATED 1 )
endif ( DISABLE_DEPRECATED_GLIB )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
add_definitions ( -DHAVE_CONFIG_H )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
set ( CONFIG_H ${ CMAKE_CURRENT_BINARY_DIR } /common/config.h )
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /common/config.h.cmake.in ${ CONFIG_H } )
2017-08-09 10:30:59 -05:00
2018-05-03 16:18:15 -05:00
set ( SCHEME_INSTALLED_SOURCE_DIR ${ CMAKE_INSTALL_DATADIR } /gnucash/scm )
set ( SCHEME_INSTALLED_CACHE_DIR ${ PKGLIBDIR } /scm/ccache/ ${ GUILE_EFFECTIVE_VERSION } )
2017-08-09 10:30:59 -05:00
2017-02-01 21:48:46 -06:00
# The subdirectories
2018-05-03 16:18:15 -05:00
add_subdirectory ( borrowed )
add_subdirectory ( data )
add_subdirectory ( doc )
add_subdirectory ( po )
add_subdirectory ( common )
add_subdirectory ( libgnucash )
if ( WITH_GNUCASH )
add_subdirectory ( gnucash )
endif ( WITH_GNUCASH )
add_subdirectory ( bindings )
add_subdirectory ( test-templates )
add_subdirectory ( util )
2017-02-01 21:48:46 -06:00
# This cmake subdir must be the last add_subdirectory() call because
# it contains post-install actions to execute.
2018-05-03 16:18:15 -05:00
add_subdirectory ( cmake )
2017-02-01 21:48:46 -06:00
2018-01-28 10:45:49 -06:00
# Generate the ChangeLog
2017-02-01 21:48:46 -06:00
2018-01-28 10:45:49 -06:00
if ( BUILDING_FROM_VCS )
add_custom_target ( ChangeLog ALL
C O M M A N D $ { G I T _ E X E C U T A B L E } l o g - - f o r m a t = \ " % a d % a N % n % n % x 0 9 * % s % d % n \ " - - d a t e = s h o r t - - s i n c e = 2 0 1 8 - 0 1 - 0 1 > $ { C M A K E _ B I N A R Y _ D I R } / C h a n g e L o g
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
)
install ( FILES ${ CMAKE_BINARY_DIR } /ChangeLog DESTINATION ${ CMAKE_INSTALL_DOCDIR } )
else ( )
install ( FILES ${ CMAKE_SOURCE_DIR } /ChangeLog DESTINATION ${ CMAKE_INSTALL_DOCDIR } )
endif ( )
2018-01-31 09:16:59 -06:00
dist_add_generated ( ${ BUILDING_FROM_VCS } ChangeLog )
2017-02-01 21:48:46 -06:00
2018-01-28 10:45:49 -06:00
############################ BEGIN MAKE DIST #################
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
set ( PACKAGE_PREFIX "${PACKAGE}-${PACKAGE_VERSION}" )
set ( DIST_FILE "${PACKAGE_PREFIX}.tar" )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
set ( toplvl_DIST_local ${ gnucash_DOCS }
2018-01-27 10:04:41 -06:00
C M a k e L i s t s . t x t R E A D M E )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
set_local_dist ( toplvl_DIST ${ toplvl_DIST_local } )
2017-02-01 21:48:46 -06:00
# Each subdirectory is responsible for reporting its list of distribution files to its parent, up to here.
#
2018-05-03 16:18:15 -05:00
# Leaf directories use the set_dist_list() function to report their distribution files. See
2017-08-10 06:56:00 -05:00
# the bottom of libgnucash/app-utils/test/CMakeLists.txt for an example.
2017-02-01 21:48:46 -06:00
#
2018-05-03 16:18:15 -05:00
# A non leaf directories uses the set_local_dist() function to specify its distribution files local that dir,
# then uses a (set ${foo_DIST} ${locals....} PARENT_SCOPE) command to report up. See the bottom of
2017-08-10 06:56:00 -05:00
# libgnucash/app-utils/CMakeLists.txt for an example of this.
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
set ( ALL_DIST ${ bindings_DIST } ${ borrowed_DIST } ${ cmake_DIST } ${ common_DIST } ${ data_DIST }
2017-12-02 19:50:14 -06:00
$ { d o c _ D I S T } $ { g n u c a s h _ D I S T } $ { l i b g n u c a s h _ D I S T } $ { p a c k a g i n g _ D I S T }
2017-08-10 06:56:00 -05:00
$ { p o _ D I S T } $ { t e s t _ t e m p l a t e s _ D I S T } $ { t o p l v l _ D I S T } $ { u t i l _ D I S T } )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
if ( BUILDING_FROM_VCS )
set ( BUILD_SOURCE_DIR ${ CMAKE_BINARY_DIR } )
else ( )
set ( BUILD_SOURCE_DIR ${ CMAKE_SOURCE_DIR } )
endif ( )
2017-02-01 21:48:46 -06:00
# Write a dist manifest
2018-05-03 16:18:15 -05:00
string ( REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}" )
file ( WRITE ${ CMAKE_BINARY_DIR } /dist_manifest.txt ${ ALL_DIST_LINES } )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
add_custom_command ( OUTPUT ${ DIST_FILE } .gz ${ DIST_FILE } .bz2
2017-02-01 21:48:46 -06:00
C O M M A N D $ { C M A K E _ C O M M A N D }
2017-08-10 06:56:00 -05:00
- D C M A K E _ M O D U L E _ P A T H = $ { C M A K E _ S O U R C E _ D I R } / c o m m o n / c m a k e _ m o d u l e s
2017-02-01 21:48:46 -06:00
- D P A C K A G E _ P R E F I X = $ { P A C K A G E _ P R E F I X }
- D G N U C A S H _ S O U R C E _ D I R = $ { C M A K E _ S O U R C E _ D I R }
- D B U I L D _ S O U R C E _ D I R = $ { B U I L D _ S O U R C E _ D I R }
- D B U I L D I N G _ F R O M _ V C S = $ { B U I L D I N G _ F R O M _ V C S }
- D S H E L L = $ { S H E L L }
2017-12-02 17:59:40 -06:00
- D W I T H _ G N U C A S H = $ { W I T H _ G N U C A S H }
2018-01-28 10:45:49 -06:00
" - D d i s t _ g e n e r a t e d = \ " $ { d i s t _ g e n e r a t e d } \ " "
2017-08-10 06:56:00 -05:00
- P $ { C M A K E _ S O U R C E _ D I R } / c o m m o n / c m a k e _ m o d u l e s / M a k e D i s t . c m a k e
2017-02-01 21:48:46 -06:00
D E P E N D S
2018-01-28 10:45:49 -06:00
$ { A L L _ D I S T } $ { d i s t _ g e n e r a t e d _ d e p e n d s }
2017-02-01 21:48:46 -06:00
)
2018-05-03 16:18:15 -05:00
add_custom_target ( dist DEPENDS ${ DIST_FILE } .gz ${ DIST_FILE } .bz2 )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
add_custom_target ( distcheck DEPENDS dist
2017-02-01 21:48:46 -06:00
C O M M A N D $ { C M A K E _ C O M M A N D }
2017-08-10 06:56:00 -05:00
- D C M A K E _ M O D U L E _ P A T H = $ { C M A K E _ S O U R C E _ D I R } / c o m m o n / c m a k e _ m o d u l e s
2017-02-01 21:48:46 -06:00
- D C M A K E _ P R E F I X _ P A T H = $ { C M A K E _ P R E F I X _ P A T H }
- D P A C K A G E _ P R E F I X = $ { P A C K A G E _ P R E F I X }
- D C M A K E _ C _ F L A G S = $ { C M A K E _ C _ F L A G S }
- D C M A K E _ C X X _ F L A G S = $ { C M A K E _ C X X _ F L A G S }
2018-03-11 12:38:05 -05:00
- D G T E S T _ R O O T = $ { G T E S T _ R O O T }
- D G M O C K _ R O O T = $ { G M O C K _ R O O T }
2017-08-10 06:56:00 -05:00
- P $ { C M A K E _ S O U R C E _ D I R } / c o m m o n / c m a k e _ m o d u l e s / M a k e D i s t C h e c k . c m a k e
2017-02-01 21:48:46 -06:00
)
############################# END MAKE DIST #################
# uninstall target
configure_file (
" $ { C M A K E _ S O U R C E _ D I R } / c m a k e / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
@ O N L Y )
add_custom_target ( uninstall
C O M M A N D $ { C M A K E _ C O M M A N D } - P $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e )
2018-05-03 16:18:15 -05:00
set ( _MODULES gnc-core-utils gnc-module gnc-backend-xml-utils )
2017-12-02 17:59:40 -06:00
2018-05-03 16:18:15 -05:00
if ( WITH_SQL )
list ( APPEND _MODULES gnc-backend-sql )
endif ( WITH_SQL )
2017-12-02 17:59:40 -06:00
2018-05-03 16:18:15 -05:00
if ( WITH_GNUCASH )
list ( APPEND _MODULES gnc-gnome )
endif ( WITH_GNUCASH )
2017-12-02 17:59:40 -06:00
2018-05-03 16:18:15 -05:00
set_target_properties ( ${ _MODULES } PROPERTIES
2017-12-01 12:53:17 -06:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y $ { L I B D I R _ B U I L D }
2018-05-03 16:18:15 -05:00
if ( XCODE_VERSION )
2017-12-01 12:53:17 -06:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y _ D E B U G $ { L I B D I R _ B U I L D }
L I B R A R Y _ O U T P U T _ D I R E C T O R Y _ R E L E A S E $ { L I B D I R _ B U I L D }
2018-05-03 16:18:15 -05:00
endif ( )
2017-02-01 21:48:46 -06:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R } / b i n
2018-05-03 16:18:15 -05:00
if ( XCODE_VERSION )
2017-02-01 21:48:46 -06:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y _ D E B U G $ { C M A K E _ B I N A R Y _ D I R } / b i n
R U N T I M E _ O U T P U T _ D I R E C T O R Y _ R E L E A S E $ { C M A K E _ B I N A R Y _ D I R } / b i n
2018-05-03 16:18:15 -05:00
endif ( )
2017-02-01 21:48:46 -06:00
)
2018-05-03 16:18:15 -05:00
if ( WIN32 )
set_target_properties ( gncmod-backend-xml gncmod-stylesheets PROPERTIES
2017-02-01 21:48:46 -06:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R } / b i n
)
2018-05-03 16:18:15 -05:00
endif ( )
2017-02-01 21:48:46 -06:00
2016-01-15 12:38:23 -06:00
#Link LICENSE to COPYING so that people expecting to find it,
#will. COPYING is normally linked by autogen.sh to the latest
#automake-provided version.
2018-05-03 16:18:15 -05:00
set ( _CMD create_symlink )
if ( WIN32 )
set ( _CMD copy )
endif ( )
2016-01-15 09:03:40 -06:00
2018-05-03 16:18:15 -05:00
install ( CODE
" execute_process (
2016-01-15 09:03:40 -06:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E $ { _ C M D } L I C E N S E C O P Y I N G
2017-11-28 16:25:35 -06:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ I N S T A L L _ D O C D I R }
2016-01-15 09:03:40 -06:00
) "
)
2015-12-07 11:17:08 -06:00
#For windows, copy in some DLLs from Mingw
2010-04-12 14:21:14 -05:00
2018-05-03 16:18:15 -05:00
if ( WIN32 )
find_library ( LIBSTDC++ libstdc++-6.dll )
find_library ( LIBDW2 libgcc_s_dw2-1.dll )
set ( MINGW_DLLS ${ LIBSTDC++ } ${ LIBDW2 } )
install ( PROGRAMS ${ MINGW_DLLS } DESTINATION ${ CMAKE_INSTALL_BINDIR } )
file ( COPY ${ MINGW_DLLS } DESTINATION ${ BINDIR_BUILD }
2017-02-01 21:48:46 -06:00
# Do permissions matter for windows?
F I L E _ P E R M I S S I O N S O W N E R _ R E A D O W N E R _ W R I T E O W N E R _ E X E C U T E G R O U P _ R E A D G R O U P _ E X E C U T E W O R L D _ R E A D W O R L D _ E X E C U T E
)
2018-05-03 16:18:15 -05:00
endif ( )
2010-04-12 14:21:14 -05:00
# ############################################################
# Package creation rules
2018-05-03 16:18:15 -05:00
set ( CPACK_PACKAGE_VERSION_MAJOR "${GNUCASH_MAJOR_VERSION}" )
set ( CPACK_PACKAGE_VERSION_MINOR "${GNUCASH_MINOR_VERSION}" )
set ( CPACK_PACKAGE_VERSION "${VERSION}" )
2018-03-05 09:38:41 -06:00
2018-05-03 16:18:15 -05:00
if ( UNIX )
set ( CPACK_GENERATOR "TGZ" )
endif ( UNIX )
2010-04-12 14:21:14 -05:00
2018-05-03 16:18:15 -05:00
include ( CPack )