Adjust GncAddSchemeTargets.cmake to build with Guile2.2 on MinGS64.

This commit is contained in:
John Ralls 2019-04-22 10:04:48 -07:00
parent 7e9463db1b
commit b1fdf781ec

View File

@ -27,7 +27,7 @@ function(make_unix_path_list PATH)
endfunction() endfunction()
function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
MAKE_LINKS) MAKE_LINKS)
set(__DEBUG FALSE) set(__DEBUG FALSE)
if (__DEBUG) if (__DEBUG)
message("Parameters to COMPILE_SCHEME for target ${_TARGET}") message("Parameters to COMPILE_SCHEME for target ${_TARGET}")
@ -44,7 +44,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
set(build_bindir ${BINDIR_BUILD}) set(build_bindir ${BINDIR_BUILD})
set(build_libdir ${LIBDIR_BUILD}) set(build_libdir ${LIBDIR_BUILD})
set(build_datadir ${DATADIR_BUILD}) set(build_datadir ${DATADIR_BUILD})
if(MINGW64) if(MINGW64 AND ${GUILE_EFFECTIVE_VERSION} VERSION_LESS 2.2)
make_unix_path(build_bindir) make_unix_path(build_bindir)
make_unix_path(build_libdir) make_unix_path(build_libdir)
make_unix_path(build_datadir) make_unix_path(build_datadir)
@ -52,7 +52,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
make_unix_path(current_srcdir) make_unix_path(current_srcdir)
make_unix_path(CMAKE_BINARY_DIR) make_unix_path(CMAKE_BINARY_DIR)
make_unix_path(CMAKE_SOURCE_DIR) make_unix_path(CMAKE_SOURCE_DIR)
endif(MINGW64) endif()
# If links are requested, we simple link (or copy, for Windows) each source file to the dest directory # If links are requested, we simple link (or copy, for Windows) each source file to the dest directory
if(MAKE_LINKS) if(MAKE_LINKS)
@ -78,17 +78,20 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
endif(MAKE_LINKS) endif(MAKE_LINKS)
# Construct the guile source and compiled load paths # Construct the guile source and compiled load paths
set(_GUILE_LOAD_PATH "${current_srcdir}" set(_GUILE_LOAD_PATH "${current_srcdir}"
"${current_bindir}" "${CMAKE_BINARY_DIR}/libgnucash/scm") # to pick up generated build-config.scm "${current_bindir}" "${CMAKE_BINARY_DIR}/libgnucash/scm") # to pick up generated build-config.scm
set(_GUILE_LOAD_COMPILED_PATH "${current_bindir}") set(_GUILE_LOAD_COMPILED_PATH "${current_bindir}")
if(MINGW64 AND ${GUILE_EFFECTIVE_VERSION} VERSION_GREATER_EQUAL 2.2)
file(TO_CMAKE_PATH $ENV{GUILE_LOAD_PATH} guile_load_path)
file(TO_CMAKE_PATH $ENV{GUILE_LOAD_COMPILED_PATH} guile_load_compiled_path)
list(APPEND _GUILE_LOAD_PATH ${guile_load_path})
list(APPEND _GUILE_LOAD_COMPILED_PATH ${guile_load_compiled_path})
endif()
set(_GUILE_CACHE_DIR ${LIBDIR_BUILD}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION}) set(_GUILE_CACHE_DIR ${LIBDIR_BUILD}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION})
set(_GUILE_LOAD_PATH "${current_srcdir}")
if (MAKE_LINKS) if (MAKE_LINKS)
list(APPEND _GUILE_LOAD_PATH "${build_datadir}/gnucash/scm") list(APPEND _GUILE_LOAD_PATH "${build_datadir}/gnucash/scm")
endif() endif()
set(_GUILE_LOAD_COMPILED_PATH ${build_libdir}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION}) list(APPEND _GUILE_LOAD_COMPILED_PATH ${build_libdir}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION})
set(_TARGET_FILES "") set(_TARGET_FILES "")
@ -117,11 +120,8 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
endif() endif()
if (MINGW64) if (MINGW64)
set(fpath "") set(fpath "")
foreach(dir $ENV{PATH}) file(TO_CMAKE_PATH "$ENV{PATH}" fpath)
make_unix_path(dir) set(LIBRARY_PATH "PATH=\"${BINDIR_BUILD};${fpath}\"")
set(fpath "${fpath}${dir}:")
endforeach(dir)
set(LIBRARY_PATH "PATH=\"${build_bindir}:${fpath}\"")
else (MINGW64) else (MINGW64)
set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:${_GUILE_LD_LIBRARY_PATH}") set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:${_GUILE_LD_LIBRARY_PATH}")
endif (MINGW64) endif (MINGW64)
@ -134,9 +134,10 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
else(MINGW64) else(MINGW64)
set(_GNC_MODULE_PATH "${LIBDIR_BUILD}" "${LIBDIR_BUILD}/gnucash" "${GNC_MODULE_PATH}") set(_GNC_MODULE_PATH "${LIBDIR_BUILD}" "${LIBDIR_BUILD}/gnucash" "${GNC_MODULE_PATH}")
endif(MINGW64) endif(MINGW64)
make_unix_path_list(_GUILE_LOAD_PATH) if(NOT MINGW64 OR ${GUILE_EFFECTIVE_VERSION} VERSION_LESS 2.2)
make_unix_path_list(_GUILE_LOAD_COMPILED_PATH) make_unix_path_list(_GUILE_LOAD_PATH)
make_unix_path_list(_GUILE_LD_LIBRARY_PATH) make_unix_path_list(_GUILE_LOAD_COMPILED_PATH)
endif()
make_unix_path_list(_GNC_MODULE_PATH) make_unix_path_list(_GNC_MODULE_PATH)
if (__DEBUG) if (__DEBUG)
message(" ") message(" ")
@ -145,15 +146,16 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
message(" GUILE_LOAD_COMPILED_PATH: ${_GUILE_LOAD_COMPILED_PATH}") message(" GUILE_LOAD_COMPILED_PATH: ${_GUILE_LOAD_COMPILED_PATH}")
message(" GNC_MODULE_PATH: ${_GNC_MODULE_PATH}") message(" GNC_MODULE_PATH: ${_GNC_MODULE_PATH}")
endif(__DEBUG) endif(__DEBUG)
#We quote the arguments to stop CMake stripping the path separators.
add_custom_command( add_custom_command(
OUTPUT ${output_file} OUTPUT ${output_file}
COMMAND ${CMAKE_COMMAND_TMP} COMMAND ${CMAKE_COMMAND_TMP}
${LIBRARY_PATH} "${LIBRARY_PATH}"
GNC_UNINSTALLED=YES "GNC_UNINSTALLED=YES"
GNC_BUILDDIR=${CMAKE_BINARY_DIR} "GNC_BUILDDIR=\"${CMAKE_BINARY_DIR}\""
GUILE_LOAD_PATH=${_GUILE_LOAD_PATH} "GUILE_LOAD_PATH=\"${_GUILE_LOAD_PATH}\""
GUILE_LOAD_COMPILED_PATH=${_GUILE_LOAD_COMPILED_PATH} "GUILE_LOAD_COMPILED_PATH=\"${_GUILE_LOAD_COMPILED_PATH}\""
GNC_MODULE_PATH=${_GNC_MODULE_PATH} "GNC_MODULE_PATH=\"${_GNC_MODULE_PATH}\""
${GUILE_EXECUTABLE} -e '\(@@ \(guild\) main\)' -s ${GUILD_EXECUTABLE} compile -o ${output_file} ${source_file_abs_path} ${GUILE_EXECUTABLE} -e '\(@@ \(guild\) main\)' -s ${GUILD_EXECUTABLE} compile -o ${output_file} ${source_file_abs_path}
DEPENDS ${guile_depends} DEPENDS ${guile_depends}
MAIN_DEPENDENCY ${source_file_abs_path} MAIN_DEPENDENCY ${source_file_abs_path}