[CMake] working with, and installing, data files

2009-11-06 Thread Crni Gorac
I'm using CMake as build system for a program that is in turn reading
some data files in run-time.  Obviously, program has to be able to
find data files both when installed, and when I'm developing it (and
I'd like to skip having to do "make install" each time when I change
data files while doing the development).  I looked into how some other
CMake based projects (CMake included) are handling this, but still I'd
appreciate any kind of advice on how to do it "properly".  At the
moment, I'm thinking about having an environment variable to point to
data directory, that I could define during the development to point to
the data directory in my source tree.  If that variable not defined,
then the program would check pre-defined data directory location, that
would be #define-d in compile time, so that correct path could be put
there with regards to the installation prefix; any suggestions for
better arrangement here? If I understood it properly, CMake is doing
something similar itself...

Thanks.
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] scripting ctest

2009-11-06 Thread th . tom
Hi again,

I am doing something wrong here, but what:

-- snip script.cmake ---
  SET ( CTEST_PROJECT_NAME ${PROJECT_NAME} )
  SET ( CTEST_BINARY_DIRECTORY ${SOURCE_DIR}/build )
  SET ( CTEST_SOURCE_DIRECTORY ${SOURCE_DIR} )

  SET ( CTEST_CMAKE_GENERATOR "Unix Makefiles" )

  SET ( CTEST_ENVIRONMENT "CC=cc" "CXX=CC" )
  SET ( CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE )

  CTEST_START ( Experimental )
  CTEST_CONFIGURE ( BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res )
  CTEST_BUILD ( BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res )
  CTEST_SUBMIT( RETURN_VALUE res )


The environment variables are ignored, and gcc is used instead of cc.
Additional the binary directory is not cleaned.

Is there something that I have to do extra?

-tom
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] CMakeFindFrameworks.cmake and FindPythonLibs.cmake broken on Mac OS X

2009-11-06 Thread Michael Wild

Hi all

while trying to compile some program which links agains the Python  
libraries on my Mac OS X 10.6 box for 10.5, I noticed that there's  
something wrong with both CMakeFindFrameworks.cmake and  
FindPythonLibs.cmake.


CMakeFindFrameworks.cmake does not search the SDK root in  
CMAKE_OS_SYSROOT, it should be patched as follows:


--- Modules/CMakeFindFrameworks.cmake.orig	2009-10-26  
12:58:16.0 +0100
+++ Modules/CMakeFindFrameworks.cmake	2009-10-26 12:58:24.0  
+0100

@@ -21,6 +21,8 @@
   FOREACH(dir
   ~/Library/Frameworks/${fwk}.framework
   /Library/Frameworks/${fwk}.framework
+  ${CMAKE_OSX_SYSROOT}/Library/Frameworks/${fwk}.framework
+  ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/$ 
{fwk}.framework

   /System/Library/Frameworks/${fwk}.framework
   /Network/Library/Frameworks/${fwk}.framework)
 IF(EXISTS ${dir})



FindPythonLibs.cmake is trickier. The problem is, that it does the  
following (in pseudo-code)


foreach version in [2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5]
  foreach dir in ${framework_dirs}
include_dir = "${dir}/Versions/${version}/Headers"
if exists(include_dir)
  break
endif
  endforeach
endforeach

Now, what happens is the following:
- CMakeFindFrameworks.cmake finds
  * /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/ 
Python.framework

  * /System/Library/Frameworks/Python.framework
- For each of those frameworks, FindPythonLibs.cmake cycles through  
the various Python version numbers and checks whether the sub- 
directory Versions/${version}/Headers exists. If such a directory  
exists in any of the found Python frameworks, the search is stopped.


Unfortunately, Python-2.6 is present on OS X 10.6, but NOT in the 10.5  
SDK. Since the search starts with version 2.6, it will find it in / 
System/Library/Frameworks, and not in the SDK which only contains the  
2.5 version as the newest Python library. This then results in an  
include path which is not consistent with the framework version that  
will be linked.


So, I think the search loops should be turned inside-out (in pseudo- 
code):


foreach dir in ${framework_dirs}
  foreach version in [2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5]
include_dir = "${dir}/Versions/${version}/Headers"
if exists(include_dir)
  break
endif
  endforeach
endforeach

IMHO this can't be done with the current structure of the find-module  
and probably needs to be split into two sections conditional on APPLE.


Do you agree with this assessment?

Michael


___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] string(RANDOM) bug?

2009-11-06 Thread Marcel Loose
Hi David,

I submitted a bug report: http://www.cmake.org/Bug/view.php?id=9851

Best regards,
Marcel Loose.

On Thu, 2009-11-05 at 11:14 -0500, David Cole wrote:
> The problem is that srand is called *each* time that STRING(RANDOM is
> invoked... And it is based on the current time stamp to the nearest
> second. (Not exactly random if it's exactly correlated to what second
> it currently is...)
> 
> I agree, this is a bug.
> 
> Would you submit a bug report in the bug tracker?
> 
> Would anyone object to changing this to call srand only on the very
> first call to STRING(RANDOM in a given invocation of cmake? (Or does
> somebody have a better suggestion? Perhaps passing the seed value in
> as an optional parameter...?)
> 
> 
> Thx,
> David
> 
> 
> On Thu, Nov 5, 2009 at 8:41 AM, Marcel Loose  wrote:
> Hi all,
> 
> I expected that string(RANDOM...) would produce a different
> string each
> time it is invoked. Turns out that this string is only
> different between
> different cmake runs. This is not what I expected. IMHO this
> is a bug,
> either in the code, or in the documentation.
> 
> $ cat ../CMakeLists.txt
> project(Dummy NONE)
> cmake_minimum_required(VERSION 2.6)
> string(RANDOM a)
> string(RANDOM b)
> message(STATUS "a=${a}")
> message(STATUS "b=${b}")
> 
> $ cmake ..
> -- a=PgDGb
> -- b=PgDGb
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /tmp/loose/cmake/build
> 
> 
> ___
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Generated files and subdirectories

2009-11-06 Thread Micha Renner
In the F&Q Setction there is a excellent example how to handle generated
files in a subdirectory.

The structure is:
mainDirectory (CMakeLists.txt)
+ ADD_SUBDIRECTORY(src1) (generates the file)
|
+ Process the file

This works also for this structure
mainDirectory (CMakeLists.txt)
+ generate the file
|
+ ADD_SUBDIRECTORY(src1) process the file

>From this I concluded the following structure should be possible

mainDirectory(CMakeLists.txt)
+ ADD_SUBDIRETCORY(src2) generate the file
|
+ ADD_SUBDIRECTORY(src1) process the file

Unfortunatelly this generates the make error message:
"There is no rule to generate the target: Name of the generated
file" (Here tm18.c see below)

So really logical is this not.

Greetings
Micha


--
The CMakeLists.txt files

In mainDirectory I have the following CMakeLists.txt file

PROJECT(MainProj)

ADD_SUBDIRECTORY(src2)
ADD_SUBDIRECTORY(src)

In src2 the CMakeLists.txt file looks like this:

PROJECT(T)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
CMAKE_POLICY(VERSION 2.6)

ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/tm18.c
COMMAND ${CMAKE_BINARY_DIR}/generator tm18
DEPENDS ${CMAKE_SOURCE_DIR}/src/tm
COMMENT "...run")
ADD_CUSTOM_TARGET(targetAdd ALL DEPENDS ${CMAKE_BINARY_DIR}/tm18.c)

and in src2 I have the following CMakeLists.txt file

PROJECT(Tm2)
SET(_targetname ULS)
SET(_src CTest.c ${CMAKE_BINARY_DIR}/tm18.c)

ADD_EXECUTABLE(${_targetname} ${_src})

SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/tm18.c PROPERTIES
GENERATED 1)

TARGET_LINK_LIBRARIES(${_targetname} ${GLIB_LIBRARY})
ADD_DEPENDENCIES(${_targetname} targetAdd)



___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake