gnucash/src/core-utils/CMakeLists.txt

202 lines
5.9 KiB
CMake
Raw Normal View History

# CMakeLists.txt for src/core-utils
ADD_SUBDIRECTORY(test)
IF (BUILDING_FROM_VCS)
SET (SWIG_CORE_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-guile.c)
GNC_ADD_SWIG_COMMAND (swig-core-utils-guile-c ${SWIG_CORE_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
SET (SWIG_CORE_UTILS_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-python.c)
GNC_ADD_SWIG_PYTHON_COMMAND (swig-core-utils-python ${SWIG_CORE_UTILS_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
ELSE()
SET(SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c)
SET(SWIG_CORE_UTILS_PYTHON_C swig-core-utils-python.c)
ENDIF()
SET (core_utils_SOURCES
binreloc.c
gnc-prefs.c
gnc-environment.c
gnc-filepath-utils.c
gnc-gkeyfile-utils.c
gnc-glib-utils.c
gnc-guile-utils.c
gnc-jalali.c
gnc-locale-utils.c
gnc-path.c
)
# Add dependency on config.h
SET_SOURCE_FILES_PROPERTIES (${core_utils_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
IF (BUILDING_FROM_VCS)
# Command to generate the swig-runtime.h header
ADD_CUSTOM_COMMAND (
OUTPUT ${SWIG_RUNTIME_H}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H}
)
ENDIF()
ADD_CUSTOM_TARGET(swig-runtime-h DEPENDS ${SWIG_RUNTIME_H})
# Add dependency on swig-runtime.h
SET_SOURCE_FILES_PROPERTIES (gnc-guile-utils.c PROPERTIES OBJECT_DEPENDS ${SWIG_RUNTIME_H})
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(datadir ${DATADIR})
SET(bindir ${BINDIR})
SET(libdir ${LIBDIR})
SET(sysconfdir ${SYSCONFDIR})
GNC_CONFIGURE(gncla-dir.h.in gncla-dir.h)
### Create gnc-version.h ###
SET (GNC_VERSION_H_IN
"/* Autogenerated. Do not change. */
#ifndef GNC_VERSION_H
#define GNC_VERSION_H
#define GNUCASH_SCM \"git\"
#define GNUCASH_BUILD_DATE \"@GNUCASH_BUILD_DATE@\"
#include \"gnc-vcs-info.h\"
#endif
")
STRING(TIMESTAMP GNUCASH_BUILD_DATE "%Y-%m-%d")
STRING(CONFIGURE ${GNC_VERSION_H_IN} GNC_VERSION_H_CONTENT)
FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-version.h ${GNC_VERSION_H_CONTENT})
### Create gnc-vcs-info.h
# The meta-cmake gymnastics here come from https://cmake.org/pipermail/cmake/2010-July/038015.html
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
"/* Autogenerated. Do not change. */\n#define GNUCASH_SCM_REV \"@GNUCASH_SCM_REV@\"\n"
)
SET(SCM_REV_COMMAND "${CMAKE_SOURCE_DIR}/util/gnc-vcs-info -r")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
"EXECUTE_PROCESS(
COMMAND ${SHELL} ${SCM_REV_COMMAND} ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GNUCASH_SCM_REV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
CONFIGURE_FILE(\${SRC} \${DST} @ONLY)
")
IF (${CMAKE_VERSION} VERSION_GREATER "3.1")
ADD_CUSTOM_TARGET(gnc-vcs-info ALL
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
-P ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
)
ELSE()
# BYPRODUCTS keyword not supported below 3.2
ADD_CUSTOM_TARGET(gnc-vcs-info ALL
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
-P ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
)
ENDIF()
### Compile library
SET(core_utils_noinst_HEADERS
binreloc.h
gnc-prefs.h
gnc-prefs-p.h
gnc-environment.h
gnc-filepath-utils.h
gnc-gkeyfile-utils.h
gnc-glib-utils.h
gnc-guile-utils.h
gnc-jalali.h
gnc-locale-utils.h
gnc-path.h
)
SET(core_utils_ALL_SOURCES ${core_utils_SOURCES} ${core_utils_noinst_HEADERS})
SET(core_utils_ALL_LIBRARIES ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GOBJECT_LDFLAGS} ${GTK_MAC_LDFLAGS})
SET(core_utils_ALL_INCLUDES
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
${GTK_MAC_INCLUDE_DIRS})
SET_LOCAL_DIST(core_utils_DIST_local ${core_utils_ALL_SOURCES} CMakeLists.txt Makefile.am core-utils.i core-utils.scm gncla-dir.h.in)
SET(core_utils_DIST ${core_utils_DIST_local} ${test_core_utils_DIST} PARENT_SCOPE)
IF (MAC_INTEGRATION)
LIST(APPEND core_utils_ALL_LIBRARIES ${OSX_EXTRA_LIBRARIES})
ENDIF()
ADD_LIBRARY (gnc-core-utils ${core_utils_ALL_SOURCES} ${SWIG_CORE_UTILS_GUILE_C})
ADD_DEPENDENCIES(gnc-core-utils gnc-vcs-info)
TARGET_LINK_LIBRARIES(gnc-core-utils ${core_utils_ALL_LIBRARIES})
TARGET_COMPILE_DEFINITIONS(gnc-core-utils
PRIVATE -DG_LOG_DOMAIN=\"gnc.core-utils\" ${GTK_MAC_CFLAGS_OTHER})
TARGET_INCLUDE_DIRECTORIES(gnc-core-utils PUBLIC ${core_utils_ALL_INCLUDES})
IF (MAC_INTEGRATION)
TARGET_COMPILE_OPTIONS(gnc-core-utils PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
ENDIF(MAC_INTEGRATION)
INSTALL(TARGETS gnc-core-utils
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
IF (WITH_PYTHON)
ADD_LIBRARY (gnc-core-utils-python ${core_utils_ALL_SOURCES} ${SWIG_CORE_UTILS_PYTHON_C})
ADD_DEPENDENCIES(gnc-core-utils-python gnc-vcs-info)
TARGET_LINK_LIBRARIES(gnc-core-utils-python ${core_utils_ALL_LIBRARIES} ${PYTHON_LIBRARIES})
TARGET_COMPILE_DEFINITIONS(gnc-core-utils-python
PRIVATE -DG_LOG_DOMAIN=\"gnc.core-utils\" ${GTK_MAC_CFLAGS_OTHER}
)
TARGET_INCLUDE_DIRECTORIES(gnc-core-utils-python PUBLIC ${core_utils_ALL_INCLUDES} ${PYTHON_INCLUDE_DIRS})
IF (MAC_INTEGRATION)
TARGET_COMPILE_OPTIONS(gnc-core-utils-python PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
ENDIF(MAC_INTEGRATION)
INSTALL(TARGETS gnc-core-utils-python
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
ENDIF()
# No headers to install
# Scheme
SET (core_utils_SCHEME core-utils.scm)
SET(GUILE_OUTPUT_DIR gnucash)
SET(GUILE_MODULES "")
SET(GUILE_LOAD_DIRS src/core-utils)
SET(GUILE_LIBRARY_DIRS src/core-utils)
SET(GUILE_DEPENDS gnc-core-utils)
GNC_ADD_SCHEME_TARGETS(scm-core-utils
"${core_utils_SCHEME}"
${GUILE_OUTPUT_DIR}
"${GUILE_MODULES}"
"${GUILE_LOAD_DIRS}"
"${GUILE_LIBRARY_DIRS}"
"${GUILE_DEPENDS}"
FALSE
)