2017-02-01 21:48:46 -06:00
# CMakeLists.txt for GnuCash
2010-03-04 11:48:36 -06:00
2019-09-13 11:40:01 -05:00
cmake_minimum_required ( VERSION 3.10 )
2020-05-04 21:47:34 -05:00
if ( CMAKE_VERSION VERSION_GREATER_EQUAL 3.14.0 )
cmake_policy ( SET CMP0082 NEW )
endif ( )
2015-12-07 11:17:08 -06:00
2020-01-17 09:28:56 -06:00
project ( gnucash
2020-07-07 16:46:57 -05:00
V E R S I O N 4 . 9 0 0
2020-01-17 09:28:56 -06:00
)
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_LATEST_STABLE_SERIES 3.x )
set ( PACKAGE_NAME GnuCash )
2018-10-17 23:05:53 -05:00
set ( PACKAGE_BUGREPORT "https://bugs.gnucash.org" )
2020-01-17 09:28:56 -06:00
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PROJECT_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-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 )
2022-12-31 09:31:05 -06:00
include ( GncGenerateGResources )
2018-05-03 16:18:15 -05:00
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 )
2022-10-03 16:24:44 -05:00
option ( WITH_AQBANKING "Build this project with aqbanking (online banking and a variety of file import formats) support" ON )
2018-05-03 16:18:15 -05:00
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 ( 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 )
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
2017-12-05 16:48:45 -06:00
2020-02-17 07:13:18 -06:00
# Support for downstream packagers
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" )
2020-02-17 07:13:18 -06:00
# In addition to the GNUCASH_BUILD_ID environment variable, packagers can overwrite
# gnucash/gnome/gnucash.releases.xml with (package) release details to be included
# in the appdata file. It should follow appdata <release> node conventions.
2023-01-01 10:23:12 -06:00
# Common prefix to use for GLib resources related to GnuCash
set ( GNUCASH_RESOURCE_PREFIX "/org/${PROJECT_NAME}/${PACKAGE_NAME}" )
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 )
2020-01-22 15:05:20 -06:00
if ( NOT ( in_prefix EQUAL 0 ) )
2017-12-05 16:48:45 -06:00
set ( ENABLE_BINRELOC OFF )
Fix various typos
Found via `codespell -q 3 -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./borrowed,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,ba,cas,dragable,gae,iff,iif,mut,nd,numer,parm,parms,startd,stoll`
2022-04-01 08:02:10 -05:00
message ( WARNING "${install_dir} is set outside of the installation 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." )
2017-12-05 16:48:45 -06:00
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 )
2020-05-07 15:02:54 -05:00
if ( NOT DEFINED GNC_DBD_DIR )
set ( GNC_DBD_DIR $ENV{ GNC_DBD_DIR } CACHE PATH "Hint for location of libdbi-drivers." )
endif ( )
2018-05-03 16:18:15 -05:00
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 )
2019-06-03 04:14:17 -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 ( )
2020-02-06 09:16:31 -06:00
endif ( )
2019-06-03 04:14:17 -05:00
# Find a proper bash executable
set ( GNC_SHELL $ENV{ GNC_SHELL } )
if ( GNC_SHELL ) # Replacing this with if ($ENV{GNC_SHELL}) doesn't work.
# Allow shell override by setting the GNC_SHELL environment variable
set ( SHELL ${ GNC_SHELL } )
elseif ( MINGW AND NOT MINGW64 )
# Old mingw's bash is on on the path, so hard-code it for now
2018-05-03 16:18:15 -05:00
set ( SHELL ${ CMAKE_PREFIX_PATH } /mingw/msys/1.0/bin/bash.exe )
2019-06-03 04:14:17 -05:00
else ( )
find_package ( UnixCommands )
if ( BASH )
set ( SHELL ${ BASH } )
else ( )
message ( SEND_ERROR "Can't find a suitable bash executable. Please set GNC_SHELL." )
endif ( )
2018-05-03 16:18:15 -05:00
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 ( )
2019-08-24 09:32:56 -05:00
set ( VCS_INFO_BASE_DIR ${ CMAKE_BINARY_DIR } )
else ( )
set ( VCS_INFO_BASE_DIR ${ CMAKE_SOURCE_DIR } )
2018-05-03 16:18:15 -05:00
endif ( )
2019-08-24 09:32:56 -05:00
# The location of gnc-vcs-info.h depends on whether we build from VCS or not
# And this file is needed in several other build rules, so we define its
# location once here.
set ( VCS_INFO_FILE ${ VCS_INFO_BASE_DIR } /libgnucash/core-utils/gnc-vcs-info.h )
2018-01-30 14:24:22 -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)
2020-04-22 13:34:45 -05:00
#Prevent creating a console window on startup and harden the executable.
set ( CMAKE_EXE_LINKER_FLAGS "-mwindows -Wl,--nxcompat -Wl,--dynamicbase" )
2020-02-06 09:16:31 -06:00
endif ( )
2015-12-07 11:17:08 -06:00
2019-09-14 13:49:12 -05:00
find_package ( Threads REQUIRED )
2018-05-03 16:18:15 -05:00
find_package ( PkgConfig REQUIRED )
2015-12-07 11:17:08 -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" )
2020-02-06 09:16:31 -06:00
endif ( )
2010-03-04 11:48:36 -06:00
# glib et al.
2020-04-24 16:23:56 -05:00
pkg_check_modules ( GLIB2 REQUIRED glib-2.0>=2.56.1 )
2019-09-21 17:28:09 -05:00
pkg_check_modules ( GIO REQUIRED gio-2.0 )
2020-04-24 16:23:56 -05:00
pkg_check_modules ( GOBJECT REQUIRED gobject-2.0 )
pkg_check_modules ( GMODULE REQUIRED gmodule-2.0 )
pkg_check_modules ( GTHREAD REQUIRED gthread-2.0 )
2019-09-21 17:28:09 -05:00
2020-04-24 16:23:56 -05:00
pkg_check_modules ( LIBXML2 REQUIRED libxml-2.0>=2.9.4 )
2019-09-21 17:28:09 -05:00
pkg_check_modules ( LIBXSLT REQUIRED libxslt )
2018-06-07 16:17:49 -05:00
if ( WITH_GNUCASH )
2020-10-23 14:20:01 -05:00
if ( WIN32 )
2019-09-13 11:40:01 -05:00
pkg_check_modules ( WEBKIT REQUIRED IMPORTED_TARGET webkitgtk-3.0 )
2019-09-12 16:45:23 -05:00
set ( WEBKIT1 1 CACHE INTERNAL "WebKitGtk" )
2020-02-06 09:16:31 -06:00
else ( )
2022-10-18 16:46:19 -05:00
pkg_check_modules ( WEBKIT IMPORTED_TARGET webkit2gtk-4.0>=2.14.0 )
if ( NOT WEBKIT_FOUND )
pkg_check_modules ( WEBKIT REQUIRED IMPORTED_TARGET webkit2gtk-4.1 )
endif ( )
2020-04-24 16:22:18 -05:00
set ( WEBKIT2 1 CACHE INTERNAL "WebKit2Gtk4" )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
2020-04-24 16:23:56 -05:00
pkg_check_modules ( GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.22.30 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
2019-09-21 17:28:09 -05:00
pkg_check_modules ( ZLIB REQUIRED zlib )
2018-05-03 16:18:15 -05:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2010-03-04 11:48:36 -06:00
2018-05-03 16:18:15 -05:00
find_path ( LTDL_INCLUDE_PATH NAMES ltdl.h PATHS /usr/include )
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." )
2020-02-06 09:16:31 -06:00
endif ( )
2015-12-07 11:17:08 -06:00
2019-05-14 15:57:24 -05:00
find_path ( REGEX_INCLUDE_PATH NAMES regex.h
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 )
find_library ( REGEX_LIBRARY NAMES regex )
# I18N
2020-02-07 14:56:21 -06:00
# Potfile generation will only be enabled if building from a git worktree
set ( BUILD_GNUCASH_POT ${ BUILDING_FROM_VCS } )
2018-02-27 15:21:00 -06:00
2020-02-06 13:10:42 -06:00
find_package ( Gettext 0.19.6 REQUIRED )
2020-02-07 14:56:21 -06:00
if ( ${ GETTEXT_VERSION_STRING } VERSION_LESS 0.20 )
message ( WARNING "Gettext version 0.20 or more recent is required to translate the 'developer_name' tag in gnucash.appdata.xml. All but that tag will be translated in the generated file." )
if ( BUILD_GNUCASH_POT )
# Only emit warning if potfile generation was enabled otherwise
message ( WARNING "Gettext version 0.20 or more recent is required to extract all translatable strings. Potfile generation will be disabled." )
endif ( )
set ( BUILD_GNUCASH_POT OFF )
2020-02-06 09:16:31 -06:00
endif ( )
2015-12-07 11:17:08 -06:00
2019-05-14 15:57:24 -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 )
2019-05-14 15:57:24 -05:00
find_library ( LIBINTL_LIBRARY NAMES intl )
# HELP
2018-05-03 16:18:15 -05:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2010-03-04 11:48:36 -06:00
# ############################################################
# SWIG
2019-10-04 14:07:15 -05:00
find_package ( SWIG 3.0.12 REQUIRED )
2019-09-21 15:50:43 -05:00
include ( ${ SWIG_USE_FILE } )
string ( REGEX MATCH "^[0-9]+[.]" SWIG_MAJOR ${ SWIG_VERSION } )
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.
2020-07-13 12:00:03 -05:00
# Look for guile versions in this order: 3.0 > 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
2020-07-13 12:00:03 -05:00
pkg_check_modules ( GUILE3 guile-3.0 QUIET )
2020-10-26 19:56:45 -05:00
pkg_check_modules ( GUILE22 guile-2.2 QUIET )
2020-07-13 12:00:03 -05:00
pkg_check_modules ( GUILE2 guile-2.0>=2.0.9 QUIET )
if ( GUILE3_FOUND ) # found guile-3.0
add_definitions ( -DHAVE_GUILE30 )
set ( HAVE_GUILE3 TRUE )
set ( GUILE_EFFECTIVE_VERSION 3.0 )
set ( GUILE_INCLUDE_DIRS ${ GUILE3_INCLUDE_DIRS } )
set ( GUILE_LDFLAGS ${ GUILE3_LDFLAGS } )
find_program ( GUILD_EXECUTABLE NAMES guild3.0 guild )
if ( NOT GUILD_EXECUTABLE )
message ( SEND_ERROR "The guild executable was not found, but is required. Please set GUILD_EXECUTABLE." )
endif ( )
message ( STATUS "Using guile-3.0.x" )
find_program ( GUILE_EXECUTABLE NAMES guile3.0 guile )
elseif ( GUILE22_FOUND ) # found guile-2.2
2019-09-21 17:28:09 -05:00
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." )
2020-02-06 09:16:31 -06:00
endif ( )
2019-09-21 17:28:09 -05:00
message ( STATUS "Using guile-2.2.x" )
find_program ( GUILE_EXECUTABLE NAMES guile2.2 guile )
2020-07-13 12:00:03 -05:00
elseif ( 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." )
2020-02-06 09:16:31 -06:00
endif ( )
2020-07-13 12:00:03 -05:00
message ( STATUS "Using guile-2.0.x" )
find_program ( GUILE_EXECUTABLE NAMES guile2.0 guile )
else ( )
message ( FATAL_ERROR "Neither guile 3.0, 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 pkg-config." )
2020-02-06 09:16:31 -06:00
endif ( )
2019-09-21 17:28:09 -05:00
2018-05-03 16:18:15 -05:00
if ( NOT GUILE_EXECUTABLE )
2019-09-21 17:28:09 -05:00
message ( SEND_ERROR "The guile executable was not found, but is required. Please set GUILE_EXECUTABLE." )
2020-02-06 09:16:31 -06:00
endif ( )
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-02-20 20:06:06 -06:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-07-27 17:15:57 -05:00
2019-06-11 10:47:46 -05:00
# Determine where to install our guile modules libraries.
find_guile_dirs ( )
2015-12-07 11:17:08 -06:00
# ############################################################
2018-05-03 16:18:15 -05:00
if ( WITH_AQBANKING )
2022-12-19 14:11:32 -06:00
pkg_check_modules ( GWENHYWFAR REQUIRED gwenhywfar>=5.6.0 )
pkg_check_modules ( AQBANKING REQUIRED aqbanking>=6.2.0 )
2019-09-21 17:28:09 -05:00
set ( CMAKE_REQUIRED_INCLUDES "${AQBANKING_INCLUDE_DIRS}"
" $ { G W E N H Y W F A R _ I N C L U D E _ D I R S } " )
2019-09-21 17:34:36 -05:00
set ( CMAKE_REQUIRED_LIBRARIES "${AQBANKING_LD_FLAGS}" )
include ( CheckSymbolExists )
2019-09-21 17:28:09 -05:00
check_symbol_exists ( "AB_Banking_RuntimeConfig_SetCharValue"
" a q b a n k i n g / b a n k i n g . h " A Q B _ H A S _ R U N T I M E _ C O N F I G )
set ( CMAKE_REQUIRED_INCLUDES )
set ( CMAKE_REQUIRED_LIBRARIES )
2018-05-03 16:18:15 -05:00
if ( WITH_GNUCASH )
2020-02-24 06:31:02 -06:00
pkg_check_modules ( GWEN_GTK3 REQUIRED gwengui-gtk3 )
2020-02-06 09:16:31 -06:00
endif ( )
endif ( )
2018-05-03 16:18:15 -05:00
if ( WITH_OFX )
2019-09-21 17:28:09 -05:00
pkg_check_modules ( LIBOFX REQUIRED libofx )
2018-05-03 16:18:15 -05:00
include ( CheckCXXSourceRuns )
if ( WIN32 )
set ( CMAKE_REQUIRED_LIBRARIES "-L ${CMAKE_PREFIX_PATH}/libofx/lib -lofx" )
2020-02-06 09:16:31 -06:00
else ( )
2018-05-03 16:18:15 -05:00
set ( CMAKE_REQUIRED_LIBRARIES "-lofx" )
2020-02-06 09:16:31 -06:00
endif ( )
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 } )
2021-02-09 17:09:50 -06:00
if ( LIBOFX_VERSION VERSION_GREATER_EQUAL 0.10.0 )
set ( HAVE_LIBOFX_VERSION_0_10 1 )
endif ( )
2018-05-03 16:18:15 -05:00
set ( CMAKE_REQUIRED_LIBRARIES )
2020-02-06 09:16:31 -06:00
endif ( )
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 )
2019-09-15 14:27:25 -05:00
pkg_check_modules ( GTK_MAC IMPORTED_TARGET gtk-mac-integration-gtk3 )
2018-05-03 16:18:15 -05:00
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 } )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
endif ( )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
# 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." )
2020-02-06 09:16:31 -06:00
endif ( )
2018-01-23 18:04:28 -06:00
if ( ${ LIBXSLT_XSLTPROC_EXECUTABLE } STREQUAL "LIBXSLT_XSLTPROC_EXECUTABLE-NOTFOUND" )
message ( FATAL_ERROR "xsltproc executable not found" )
2020-02-06 09:16:31 -06:00
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 )
2020-05-07 15:02:54 -05:00
find_library ( LIBDBI_DRIVERS
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
2020-05-07 15:02:54 -05:00
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 }
2017-12-10 14:51:24 -06:00
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?" )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( NOT LIBDBI_LIBRARY )
message ( SEND_ERROR "Library libdbi was not found" )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
set ( HAVE_DBI_DBI_H 1 )
2020-05-07 15:02:54 -05:00
if ( NOT LIBDBI_DRIVERS )
2018-05-03 16:18:15 -05:00
message ( SEND_ERROR "No libdbi drivers found, SQL tests will fail." )
else ( )
2020-05-07 15:02:54 -05:00
get_filename_component ( drivers_dir ${ LIBDBI_DRIVERS } DIRECTORY )
2017-12-10 14:51:24 -06:00
set ( LIBDBI_DRIVERS_DIR ${ drivers_dir } CACHE FILEPATH "Directory containing the libdbi driver modules." FORCE )
2018-05-03 16:18:15 -05:00
endif ( )
2020-02-06 09:16:31 -06:00
endif ( )
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
2019-05-13 21:21:55 -05:00
if ( PYTHON_VERSION_STRING VERSION_LESS "3.2.0" )
message ( SEND_ERROR "Found python version ${PYTHON_VERSION_STRING}, but it's too old. Need python >= 3.2.0" )
2018-05-03 16:18:15 -05:00
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." )
2020-02-06 09:16:31 -06:00
endif ( )
2015-12-07 11:17:08 -06:00
2022-09-01 17:46:47 -05:00
execute_process ( COMMAND
$ { P E R L _ E X E C U T A B L E } - M F i n a n c e : : Q u o t e - e " "
E R R O R _ Q U I E T
R E S U L T _ V A R I A B L E h a v e _ f _ q )
if ( ${ have_f_q } EQUAL 0 )
set ( HAVE_F_Q 1 )
endif ( )
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
2019-09-21 17:28:09 -05:00
pkg_check_modules ( ICU4C REQUIRED icu-uc )
pkg_check_modules ( ICU4C_I18N REQUIRED icu-i18n )
2017-03-13 13:55:09 -05:00
2019-09-21 17:28:09 -05:00
pkg_check_modules ( LIBSECRET libsecret-1>=0.18 )
2018-06-13 00:19:48 -05:00
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 ( )
2023-01-08 18:11:58 -06:00
find_package ( Boost 1.67.0 COMPONENTS algorithm asio date_time filesystem iostreams locale process program_options property_tree regex 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 )
2020-02-06 09:16:31 -06:00
else ( )
2020-05-28 15:24:18 -05:00
find_package ( Boost 1.60.0 REQUIRED COMPONENTS date_time regex locale filesystem system program_options )
2019-10-12 18:39:09 -05:00
if ( Boost_FOUND )
include ( CheckIncludeFileCXX )
set ( CMAKE_REQUIRED_FLAGS "-std=c++17" )
set ( CMAKE_REQUIRED_INCLUDES ${ Boost_INCLUDE_DIR } )
check_include_file_cxx ( "boost/locale.hpp" AUTO_PTR )
unset ( CMAKE_REQUIRED_FLAGS )
unset ( CMAKE_REQUIRED_INCLUDES )
if ( AUTO_PTR )
include_directories ( ${ Boost_INCLUDE_DIRS } )
set ( HAVE_BOOST 1 )
endif ( )
endif ( )
endif ( )
if ( NOT HAVE_BOOST )
2020-05-28 15:24:18 -05:00
message ( SEND_ERROR "A suitable Boost is not installed, and is required. GnuCash requires that Boost be compatible and compiled with C++17. Boost 1.67 is the first compatible release but some distributions have patched earlier ones to work with C++17. Please install it and ensure that the following libraries are built: date_time, filesystem, locale, regex, program_options and system." )
2020-02-06 10:01:26 -06:00
endif ( )
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-09-08 15:53:25 -05:00
add_definitions ( -D_GNU_SOURCE )
2015-12-07 11:17:08 -06:00
2020-01-20 13:32:10 -06:00
# Set up the language standards:
2019-10-12 18:39:09 -05:00
set ( CMAKE_CXX_STANDARD 17 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( CMAKE_CXX_EXTENSIONS OFF )
set ( CMAKE_C_STANDARD 11 )
set ( CMAKE_C_STANDARD_REQUIRED ON )
set ( CMAKE_C_EXTENSIONS ON )
2018-05-03 16:18:15 -05:00
if ( UNIX )
set ( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-unused ${CMAKE_C_FLAGS}" )
2019-10-12 18:39:09 -05:00
set ( CMAKE_C_FLAGS "-Wno-error=deprecated-declarations -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-12-27 15:25:18 -06:00
set ( CMAKE_CXX_FLAGS "-Wno-error=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}" )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( MINGW )
2019-10-12 18:39:09 -05:00
set ( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wno-unused -Wno-error=deprecated-declarations ${CMAKE_C_FLAGS}" )
2018-05-03 16:18:15 -05:00
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
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( APPLE AND WITH_GNUCASH )
set ( CMAKE_MACOSX_RPATH ON )
set ( CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
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.
Fix typos for gnuchash/ doc/ bindings/ and misc.
Typos found via `codespell -q 3 -D ~/Projects/codespell/codespell_lib/data/dictionary.txt -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,cas,dragable,gae,iff,iif,mut,nd,numer,startd,stoll`
2019-09-13 19:26:03 -05:00
# For the handful that are installed to lib, we override the properties below
2017-02-01 21:48:46 -06:00
# (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
2019-03-30 16:43:02 -05:00
C h a n g e L o g . 2 0 1 8
2020-03-28 13:34:03 -05:00
C h a n g e L o g . 2 0 1 9
2021-03-27 17:03:16 -05:00
C h a n g e L o g . 2 0 2 0
2022-03-26 17:21:24 -05:00
C h a n g e L o g . 2 0 2 1
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
if ( WIN32 )
2021-09-26 15:58:08 -05:00
if ( MINGW )
set ( HAVE_SCANF_LLD 1 )
else ( )
set ( HAVE_SCANF_I64D 1 )
endif ( )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-09-08 15:53:25 -05:00
2018-05-03 16:18:15 -05:00
if ( NOT DISABLE_NLS )
set ( ENABLE_NLS 1 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( ENABLE_BINRELOC )
if ( UNIX OR MINGW )
set ( BR_PTHREAD 1 )
2020-02-06 09:16:31 -06:00
endif ( )
endif ( )
2018-05-03 16:18:15 -05:00
if ( UNIX OR MINGW )
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( WIN32 )
set ( GNC_PLATFORM_WINDOWS 1 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
if ( DISABLE_DEPRECATED_GNOME )
set ( GNOME_DISABLE_DEPRECATED 1 )
2020-02-06 09:16:31 -06:00
endif ( )
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 )
2020-02-06 09:16:31 -06:00
endif ( )
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 )
2020-02-06 09:16:31 -06:00
endif ( )
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
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 )
2021-03-23 09:25:08 -05:00
# Note: po should be processed before gnucash - it provides LINGUAS, used to generate desktop and appdata files
2018-05-03 16:18:15 -05:00
add_subdirectory ( po )
add_subdirectory ( common )
add_subdirectory ( libgnucash )
if ( WITH_GNUCASH )
add_subdirectory ( gnucash )
2020-02-06 09:16:31 -06:00
endif ( )
2018-05-03 16:18:15 -05:00
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
2022-03-26 17:21:24 -05:00
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 2 2 - 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
2018-01-28 10:45:49 -06:00
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
2020-01-17 09:28:56 -06:00
set ( PACKAGE_PREFIX "${PROJECT_NAME}-${PROJECT_VERSION}" )
2021-03-14 16:47:22 -05:00
if ( PROJECT_DESCRIPTION )
string ( APPEND PACKAGE_PREFIX "-${PROJECT_DESCRIPTION}" )
endif ( )
2018-05-03 16:18:15 -05:00
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 }
2023-01-09 16:32:52 -06: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 } I n f o . p l 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 }
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 )
2019-11-26 14:30:28 -06:00
set ( _MODULES gnc-core-utils gnc-engine gnc-app-utils gnc-module gnc-locale-tax gnc-backend-xml-utils gnucash-guile )
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 )
2020-02-06 09:16:31 -06:00
endif ( )
2017-12-02 17:59:40 -06:00
2018-05-03 16:18:15 -05:00
if ( WITH_GNUCASH )
2020-04-18 11:16:13 -05:00
list ( APPEND _MODULES gnc-gnome gnc-html )
2020-02-06 09:16:31 -06:00
endif ( )
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 )
2019-06-14 02:58:00 -05:00
set_target_properties ( gncmod-backend-xml 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 )
2020-04-22 13:34:45 -05:00
find_file ( LIBSTDC++ libstdc++-6.dll )
if ( NOT LIBSTDC++ )
message ( FATAL_ERROR "libstdc++ not found." )
endif ( )
find_file ( LIBDW2 libgcc_s_dw2-1.dll )
if ( NOT LIBDW2 )
message ( FATAL_ERROR "libgcc_s_dw2-l not found." )
endif ( )
2018-05-03 16:18:15 -05:00
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
if ( UNIX )
set ( CPACK_GENERATOR "TGZ" )
2020-02-06 09:16:31 -06:00
endif ( )
2010-04-12 14:21:14 -05:00
2018-05-03 16:18:15 -05:00
include ( CPack )