[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop-devel
Subject:    Re: Cmake project loading
From:       Nicolás_Alvarez <nicolas.alvarez () gmail ! com>
Date:       2010-06-10 3:32:51
Message-ID: AANLkTinJTUgAxQC9gdr87jAh03D9sPvtep4_-icCUbjd () mail ! gmail ! com
[Download RAW message or body]

On 6/9/10, Benjamin Schindler <bschindler@inf.ethz.ch> wrote:
> Hi
>
> I just recently completely redesigned the (cmake-)build system for my
> project and it seems I've done something which kdevelop really does not
> like at all.
>
> The sample project I attached takes a very long time to load given that
> there are <100 source files listed. It seems to me that kdevelop gets
> hit by some infinite loop when autogenerating the source files from the
> xsd files (the files are generated using the codesynthesis xsd compiler)
>
> Could somebody have a look at this issue?

The problem seems to be caused by lack of proper variable scope in
functions, which I reported last month:

http://bugs.kde.org/show_bug.cgi?id=238455#c2

Many functions in your code are appending elements to variables, and
(correctly) expecting the variable to start empty at the beginning of
the function. In CMake, if you set a variable inside a function (and
don't use parent_scope), it goes away when the function ends. However,
in KDevelop, functions and macros work the same, and variables keep
their value when the function ends and it's later called again. In
other words, there is no such thing as a "local variable".

I think it'd take quite some work to add proper variable scopes.

As a workaround, clear those variables at the beginning of the
function. I searched for all SET calls that added stuff to a variable
with set(foo ${foo} somethingelse), were inside a function, and didn't
use PARENT_SCOPE, and I set them to "" at the beginning of the
function. The project now takes 3 seconds to load. Patch attached.

-- 
Nicolas

["workaround-reset-local-variables.diff" (text/x-patch)]

diff --git a/CMake/Findxsd.cmake b/CMake/Findxsd.cmake
--- a/CMake/Findxsd.cmake
+++ b/CMake/Findxsd.cmake
@@ -45,6 +45,8 @@
 endif(XSD_INCLUDE_DIR)
 
 FUNCTION(XSD_EXTRACT_OPTIONS _xsd_files _xsd_options)
+	SET(_xsd_options_p "")
+	SET(_xsd_files_p "")
 	foreach(current_arg ${ARGN})
 		IF(${current_arg} STREQUAL "OPTIONS")
 			SET(_XSD_DOING_OPTIONS TRUE)
@@ -62,6 +64,7 @@
 
 
 FUNCTION(WRAP_XSD XSD_SRCS XSD_INCLUDES OUT_PATH)
+	SET(_XSD_SRCS "")
 	SET(OUTPUT_DIR  ${CMAKE_CURRENT_BINARY_DIR}/src/xsd)
 	FILE(MAKE_DIRECTORY ${OUTPUT_DIR})
 	SET(${XSD_INCLUDES} ${OUTPUT_DIR} PARENT_SCOPE)
diff --git a/CMake/VisdomUtils.cmake b/CMake/VisdomUtils.cmake
--- a/CMake/VisdomUtils.cmake
+++ b/CMake/VisdomUtils.cmake
@@ -42,6 +42,8 @@
 endmacro(visdom_declare_plugin)
 
 function(visdom_scan_sources sources generated_sources generated_include)
+	set(generated_sources_p "")
+	set(sources_p "")
 	foreach(current_src ${ARGN})
 		string(REGEX REPLACE ".*\\." "" extension "${current_src}" )
 		string(TOLOWER ${extension} lower_case_extension)
@@ -81,6 +83,9 @@
 	SET(first_xsd "1")
 	SET(other_xsd_args ${XSD_ARGS})
 	SET(GENERATE_SOURCE_GROUP "1")
+	SET(sources "")
+	SET(assets "")
+	SET(node_tests "")
 	
 	foreach(current_arg ${ARGN})
 		IF(${current_arg} STREQUAL "SOURCES")


-- 
KDevelop-devel mailing list
KDevelop-devel@kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic