Don't generate marshallers in the source tree

This is much cleaner.  I'm unsure of the original motivations,
perhaps I just wanted to have all source files next to each other.
There is no functional issue with the build directory, though.
This commit is contained in:
Přemysl Eric Janouch 2021-11-01 10:08:03 +01:00
parent 79d2fc78ea
commit 8950a533b4
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 13 additions and 31 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
/build /build
/win32-depends /win32-depends
/liblogdiag/ld-marshal.[ch]
/CMakeLists.txt.user /CMakeLists.txt.user

View File

@ -100,7 +100,7 @@ endforeach ()
# Project source files # Project source files
set (liblogdiag_SOURCES set (liblogdiag_SOURCES
liblogdiag/ld-marshal.c ${PROJECT_BINARY_DIR}/ld-marshal.c
liblogdiag/ld-types.c liblogdiag/ld-types.c
liblogdiag/ld-undo-action.c liblogdiag/ld-undo-action.c
liblogdiag/ld-diagram.c liblogdiag/ld-diagram.c
@ -117,9 +117,9 @@ set (liblogdiag_SOURCES
liblogdiag/ld-lua.c liblogdiag/ld-lua.c
liblogdiag/ld-lua-symbol.c) liblogdiag/ld-lua-symbol.c)
set (liblogdiag_HEADERS set (liblogdiag_HEADERS
${PROJECT_BINARY_DIR}/ld-marshal.h
${PROJECT_BINARY_DIR}/config.h ${PROJECT_BINARY_DIR}/config.h
liblogdiag/liblogdiag.h liblogdiag/liblogdiag.h
liblogdiag/ld-marshal.h
liblogdiag/ld-types.h liblogdiag/ld-types.h
liblogdiag/ld-undo-action.h liblogdiag/ld-undo-action.h
liblogdiag/ld-diagram.h liblogdiag/ld-diagram.h
@ -167,36 +167,19 @@ if (NOT GLIB_GENMARSHAL_EXECUTABLE)
message (FATAL_ERROR "glib-genmarshal not found") message (FATAL_ERROR "glib-genmarshal not found")
endif () endif ()
function (glib_genmarshal base prefix) function (glib_genmarshal listfile prefix)
get_filename_component (base_path "${base}" PATH) get_filename_component (basename "${listfile}" NAME_WE)
get_filename_component (base_name "${base}" NAME) set (command_base ${GLIB_GENMARSHAL_EXECUTABLE} --prefix ${prefix}
set (command_base ${GLIB_GENMARSHAL_EXECUTABLE} "${listfile}")
--prefix ${prefix} "${base_name}.list")
# On Windows, the final makefile may contain: add_custom_command (OUTPUT ${basename}.c ${basename}.h
# cd e:\abc && ... COMMAND ${command_base} --body > ${basename}.c
# That won't actually change the directory. We have to do: COMMAND ${command_base} --header > ${basename}.h
# cd e:\abc && e: && ... DEPENDS "${listfile}"
if (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]") COMMENT "Generating marshallers source files" VERBATIM)
string (SUBSTRING "${base_path}" 0 2 base_drive)
set (command_base "${base_drive}" && "${command_base}")
endif ()
# NOTE: VERBATIM would cause problems, so it is not used here
add_custom_command (OUTPUT ${base}.c
COMMAND ${command_base} --body > "${base_name}.c"
DEPENDS "${base}.list"
WORKING_DIRECTORY "${base_path}"
COMMENT "Generating marshallers source file")
add_custom_command (OUTPUT ${base}.h
COMMAND ${command_base} --header > "${base_name}.h"
DEPENDS "${base}.list"
WORKING_DIRECTORY "${base_path}"
COMMENT "Generating marshallers header file")
endfunction () endfunction ()
glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal.list ld_marshal)
ld_marshal)
include_directories (${PROJECT_SOURCE_DIR}) include_directories (${PROJECT_SOURCE_DIR})
include_directories (${GTK3_INCLUDE_DIRS} ${Lua_INCLUDE_DIRS}) include_directories (${GTK3_INCLUDE_DIRS} ${Lua_INCLUDE_DIRS})
@ -427,7 +410,7 @@ set (CPACK_RPM_PACKAGE_LICENSE "ISC")
set (CPACK_RPM_PACKAGE_URL "${project_URL}") set (CPACK_RPM_PACKAGE_URL "${project_URL}")
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP") set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends;/liblogdiag/ld-marshal.[ch]") set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
include (CPack) include (CPack)