Re: [CMake] FindQt4.cmake returns too much irrelevant information

2009-05-07 Thread Alan W. Irwin

On 2009-05-07 22:45+0200 Christian Ehrlicher wrote:


Alan W. Irwin schrieb:

I have just discovered that for -DCMAKE_BUILD_TYPE=Debug, the
combination of
FindQt4.cmake and UseQt4.cmake inserts the keywords debug, optimized, AND
general into the QT_LIBRARIES list to divide the list into three sections.
But only the debug section of that list is used by target_link_libraries
for
the -DCMAKE_BUILD_TYPE=Debug case.

Could we have a cleaner design that doesn't specify the
target_link_libraries keywords and which simply returns in QT_LIBRARIES
whatever is relevant for the CMAKE_BUILD_TYPE that is specified?





CMAKE_BUILD_TYPE is not set for MSVC and other IDE generators so this
will not work.


I thought that was a good argument at first, but when I looked deeper it
turns out not to be relevant to this particular case since the setting of
the debug and optimized keywords in FindQt4.cmake occurs inside a

IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)

logic block.



This would also mean that you can't change the buildtype
without doing a complete research of the existing libraries.


I think that should be FindQt.cmake's job (i.e., return the correct library
results depending on whether and how CMAKE_BUILD_TYPE is set). I think it
should be straightforward to avoid re-searching the libraries each time.
(Get cached library search results and return what is relevant depending on
CMAKE_BUILD_TYPE.) Or did you mean something else?



And CMAKE_BUILD_TYPE isn't use for some generators + is not set when you
run cmake on a clean builddir without any options.


Actually, I have no complaints about FindQt4.cmake when CMAKE_BUILD_TYPE is
_not_ set.  But I do think it is a good idea to provide clean results when
CMAKE_BUILD_TYPE _is_ specified rather than a messy combination of
everything that _might_ be relevant.

Alan
__
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__

Linux-powered Science
__
___
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] Multiple calls to PROJECT() not diagnosed [was:2.6.4 add_subdirectory with same argument broken?]

2009-05-07 Thread Carsten Neumann

Hello Brad,

Brad King wrote:

Carsten Neumann wrote:
It does so by performing multiple passes over the source tree 

[snip]
This all works fine with cmake 2.6.x (x < 4), but the latest version 
complains in the OSGSETUP pass on the first call to ADD_SUBDIRECTORY 
in that pass (see attachment for more details):

[snip]
Is this intended behavior, should I file a bug report, any ideas how 
to make this or something similar work again?


Adding the same build directory multiple times even from the same
source tree is not allowed, but was not enforced until now.  When you
did this before CMake would generate the build files over and over
again.  It just happened that the last time wrote the files you want.


ok, thanks for the clarification.


I suggest moving the meta-information into a separate file in each
subdirectory which you can load with a normal include() command.  Then
you only need to add each subdirectory once.


yes, I did something along those lines to fix the build. While doing so 
I noticed that when INCLUDEing the per-library files into the top level 
CMakeLists.txt essentially PROJECT() was called more than once for the 
same directory, which generated a broken solution file for VS 2005/8.
I opened feature request 8984 asking for PROJECT() to detect and error 
out in this case.


Thanks and kind regards,
Carsten
___
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] Have "make clean" run a script?

2009-05-07 Thread Bill O'Hara
In addition to deleting files, is it possible to get the generated clean
target to run a script?

I want to do everything make clean does but also insert a call to a sanity
script.

thanks
b.
___
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] FindQt4.cmake returns too much irrelevant information

2009-05-07 Thread Christian Ehrlicher
Alan W. Irwin schrieb:
> I have just discovered that for -DCMAKE_BUILD_TYPE=Debug, the
> combination of
> FindQt4.cmake and UseQt4.cmake inserts the keywords debug, optimized, AND
> general into the QT_LIBRARIES list to divide the list into three sections.
> But only the debug section of that list is used by target_link_libraries
> for
> the -DCMAKE_BUILD_TYPE=Debug case.
> 
> Could we have a cleaner design that doesn't specify the
> target_link_libraries keywords and which simply returns in QT_LIBRARIES
> whatever is relevant for the CMAKE_BUILD_TYPE that is specified?
> 
CMAKE_BUILD_TYPE is not set for MSVC and other IDE generators so this
will not work. This would also mean that you can't change the buildtype
without doing a complete research of the existing libraries.
And CMAKE_BUILD_TYPE isn't use for some generators + is not set when you
run cmake on a clean builddir without any options.


Christian
___
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] Cmake Solaris 10

2009-05-07 Thread Bill Hoffman

Oliver Trebbe wrote:

Hello,

i cant find any workaround for compiling cmake under solaris 10.
I just saw threads or mails to the list regarding my problem compiling 
cmake on solaris 10 where there is the problem with the static linked 
library. (libcmsys.a)

I´d be open for any solution.



The only problem that was reported was if you did an in-source build 
twice it breaks.



So, what is the exact error you are getting?  Also, did you do an out of 
source build?  What version of CMake are you building?


-Bill
___
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] CMake & RPM problems

2009-05-07 Thread Eric Noulard
2009/5/7 Florent Lagaye :

Florent,

Try not to drop CMake ML when answering.

>> Eric Noulard a écrit :
>> Could you explain us (or point the appropriate documentation)
>> on how the "freedesktop file" should work?
>
>
> Freedesktop is The standard used by gnome and kde to specify "desktop
> entries" which in fact are application launchers. That's why when you
> install a KDE app, the menu entry is also present in gnome menus.
>
> http://standards.freedesktop.org/desktop-entry-spec/latest/index.html

OK I'll read this.


>>     - How can I tell CPack to put instruction to create and associate new
>> mime-types ?
>
> For mime-types and icons I got a little further.
>
> The icon is in /share/icons/hicolor/scalable/apps/v4d.svg
>
> I built an xml file according to :
> http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
> The file is in /share/mime/packages/viewer4d.mime.xml
>
> Now I should add in the RPM SPEC file the three commands needed to update
> the desktop database (update-desktop-database as root), the mime
> (update-mime-database) database and the icon database
> (gtk-update-icon-cache) in the %post and %postun sections.
>
> Would CPack allow to use a template SPEC file, which it would fill (much
> more like UseRpmTools), instead of creating a plain new one from scratch
> each time ?

CPackRPM should be able to work with a custom spec file,

SET(CPACK_RPM_USER_BINARY_SPECFILE   your_custom.spec)
The specified file will be
CONFIGURE_FILE( ... @ONLY)
the current state of the feature is "not tested", thus most probably
not working :-)

I should have time tomorrow for working on this, what I'll most
probably be doing
is to offer two ways to do this:

1) Add more CPACK_RPM_XXX specific var such like:
 CPACK_RPM_POST_INSTALL_SCRIPT_FILE
 CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE

 which may be used to specify the corresponding scripts
 that will be embedded in the generated spec file.

2) Effectively support the custom spec file usage.

I'd like to support both because it's not that intuitive to write a
proper spec file
which works with CPack because it's a kind of "short-cutted" one.
Have a look of the spec file currently generated and you'll see.
(no %prep, %build nor %install sections).


-- 
Erk
___
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] FindQt4.cmake returns too much irrelevant information

2009-05-07 Thread Alan W. Irwin

I have just discovered that for -DCMAKE_BUILD_TYPE=Debug, the combination of
FindQt4.cmake and UseQt4.cmake inserts the keywords debug, optimized, AND
general into the QT_LIBRARIES list to divide the list into three sections.
But only the debug section of that list is used by target_link_libraries for
the -DCMAKE_BUILD_TYPE=Debug case.

Could we have a cleaner design that doesn't specify the
target_link_libraries keywords and which simply returns in QT_LIBRARIES
whatever is relevant for the CMAKE_BUILD_TYPE that is specified?

A clean design matters in a practical sense because QT_LIBRARIES has other
uses than just for target_link_libraries.  For example, in PLplot, we use
QT_LIBRARIES to configure a *.pc file containing pkg-config information for
PLplot users. Therefore, I am going to have to write a parsing routine to
dump all the irrelevant information from QT_LIBRARIES for whatever
CMAKE_BUILD_TYPE is specified.  I am stuck with this task regardless since
some of our users still have cmake-2.6.0.  Neverthess, I thought I would
plea for a clean design of the combination of FindQt4.cmake and UseQt4.cmake
here for the ultimate benefit of users of later CMake versions.

Alan
__
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__

Linux-powered Science
__
___
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] Cmake Solaris 10

2009-05-07 Thread Oliver Trebbe

Hello,

i cant find any workaround for compiling cmake under solaris 10.
I just saw threads or mails to the list regarding my problem compiling 
cmake on solaris 10 where there is the problem with the static linked 
library. (libcmsys.a)

I´d be open for any solution.

Regards

Oliver

--
Oliver Trebbe
Department of Neurology
University of Muenster
48129 Muenster, Germany


___
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] Problem with cygwin and CodeSourcery's ARM Toolchain

2009-05-07 Thread Hendrik Sattler
Am Donnerstag 07 Mai 2009 18:15:40 schrieb Thomas Kindler:
> Hendrik Sattler wrote:
> > Zitat von Thomas Kindler :
> >> cmake tries to use cygwin-style absolute "/home/tkindler.." paths,
> >> which arm-none-eabi-gcc doesn't seem to like (being a native win32
> >> program).
> >>
> >> My old makefile used relative paths to invoke the compiler. How can I
> >> do this in cmake generated makefiles?!
> >>
> >> Prepending "c:/cygwin/" to all paths should also solve the problem.
> >
> > If you have a native compiler, use the native compiled cmake. If you
> > have a compiler/tool that depends on cygwin, use the cygwin-compiled
> > cmake. Living in both worlds (native vs. cygwin) is a major pain. Just
> > don't.
>
> Ok.. that part seems to work after installing the native windows cmake.
>
> The resulting binary is still not usable -- cmake inserts an "-fPIC"
> linker flag.
>
>arm-none-eabi-gcc.exe  -fPIC $(stm32test_OBJECTS)  [..]
>
> How can I switch that off?

$ cmake --help-property ENABLE_EXPORTS
[...]
  ENABLE_EXPORTS
   Specify whether an executable exports symbols for loadable modules.

   Normally an executable does not export any symbols because it is the
   final program.  It is possible for an executable to export symbols to
   be used by loadable modules.  When this property is set to true CMake
   will allow other targets to "link" to the executable with the
   TARGET_LINK_LIBRARIES command.  On all platforms a target-level
   dependency on the executable is created for targets that link to it.
   For non-DLL platforms the link rule is simply ignored since the
   dynamic loader will automatically bind symbols when the module is
   loaded.  For DLL platforms an import library will be created for the
   exported symbols and then used for linking.  All Windows-based systems
   including Cygwin are DLL platforms.

I guess that the default is true, contrary to the help message. I think this 
is a bug. Setting it to false should get rid of the -fPIC, maybe.

> I also need to specify a special linker script for my target. In my
> plain old makefile I just added -Tstm32f10x.ld to my linker command line.

Use the LINK_FLAGS/LINK_FLAGS_ target properties. Or actually better, 
this obviously belongs to the toolchain file. Try
SET ( CMAKE_EXE_LINKER_FLAGS_INIT -T/an/absolute/path/to/stm32f10x.ld )

And yes, the path must be absolute.

> What's the official cmake way to add custom linker flags?!
>
> Adding it to target_link_libraries( .. )  seems to work, but feels wrong.
>
> Also: Right now, I have to invoke cmake by this lengthy command:
>
>cmake -DCMAKE_TOOLCHAIN_FILE=CodeSourcery.cmake -G"Unix Makefiles" .
>
> when compiling the project for the first time.  How can I specify a
> default toolchain and generator in the CMakeLists.txt itself?

No. But you can write a small batch file and give it a good name. Good old 
methods never die.

HS

___
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] Automatic libraries stripping

2009-05-07 Thread Adolfo Rodríguez
You can also use the auto-generated install/strip target if you want to
choose at install-time whether you want stripping of shared libs/executables
or not.

Adolfo

On Thu, May 7, 2009 at 4:46 PM,  wrote:

>
> Uh, so simple. Thank you, I didn't know about this option (probably not
> read gcc manpage carefully). Thank you again.
>
> Dan
>
> >
> > > I would like to ask you, if (and how, if so) it is
> > > possible
> > > > to set CMake
> > > to strip (/usr/bin/strip) the generated libraries.
> > >
> > Use -s option for gcc. You don't need to use strip
> > directly.
> >
> > Denis
> >
> >
> >
>
>
> ___
> 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
>



-- 
Adolfo Rodríguez Tsouroukdissian

Robotics engineer
PAL ROBOTICS S.L
http://www.pal-robotics.com
Tel. +34.93.414.53.47
Fax.+34.93.209.11.09
___
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] Problem with cygwin and CodeSourcery's ARM Toolchain

2009-05-07 Thread Thomas Kindler

Hendrik Sattler wrote:

Zitat von Thomas Kindler :

cmake tries to use cygwin-style absolute "/home/tkindler.." paths,
which arm-none-eabi-gcc doesn't seem to like (being a native win32
program).

My old makefile used relative paths to invoke the compiler. How can I
do this in cmake generated makefiles?!

Prepending "c:/cygwin/" to all paths should also solve the problem.


If you have a native compiler, use the native compiled cmake. If you 
have a compiler/tool that depends on cygwin, use the cygwin-compiled cmake.

Living in both worlds (native vs. cygwin) is a major pain. Just don't.


Ok.. that part seems to work after installing the native windows cmake.

The resulting binary is still not usable -- cmake inserts an "-fPIC" 
linker flag.


  arm-none-eabi-gcc.exe  -fPIC $(stm32test_OBJECTS)  [..]

How can I switch that off?

I also need to specify a special linker script for my target. In my 
plain old makefile I just added -Tstm32f10x.ld to my linker command line.


What's the official cmake way to add custom linker flags?!

Adding it to target_link_libraries( .. )  seems to work, but feels wrong.

Also: Right now, I have to invoke cmake by this lengthy command:

  cmake -DCMAKE_TOOLCHAIN_FILE=CodeSourcery.cmake -G"Unix Makefiles" .

when compiling the project for the first time.  How can I specify a 
default toolchain and generator in the CMakeLists.txt itself?


--
Dipl.-Inform. Thomas Kindler 
"Zuse, Zuse" sprach die Tante, als das Rechenzimmer brannte
___
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] find_libary

2009-05-07 Thread Micha Renner
If I use FIND_LIBRARY(_result name1), I have a strange effect, which I
do not understand.

E.g FIND_LIBRARY(_result tiff) works as it should.

FIND_LIBRARY(_result gs) fails. An inspection with nautilus shows
libgs.so is located in /usr/lib.

glib, fontconfig, pango etc. could be found.
graph, gsm, glitz-glx not. (All in /usr/lib)

What is the criteria that FIND_LIBRARY can find a library?

Micha


___
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] How do I generate a preprocessed file?

2009-05-07 Thread Piotr Wyderski
Hello,

my problem is as follow. I have a project composed of
four directories: base, io, rt and vm. The first three of them
are being built in a normal way, but the last one has some
fancy requirements. Namely, in the directory vm I want to
generate a file called inc.cpp, which is composed of all
the header files from base, io and rt, preprocessed
by the C++ compiler. So, in vm/CMakeLists.txt I specify:

ADD_DEFINITIONS(-DCONFIG_BUILDING_VM)
ADD_LIBRARY(vm SHARED inc.cpp)

Next, I indicate that inc.cpp is generated:

SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/inc.cpp
PROPERTIES GENERATED 1)

Then I create a list of all the header files of interest:

FILE(
GLOB
_runtime_header_list
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/base/*.h
${PROJECT_SOURCE_DIR}/io/*.h
${PROJECT_SOURCE_DIR}/rt/*.h)

And specify a command to generate the file:

ADD_CUSTOM_COMMAND(

   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/inc.cpp
   COMMAND YYY >inc.cpp
   DEPENDS ${_runtime_header_list}
)

but what shoud YYY be in order to achieve the following goal:

1. all the entries from _runtime_header_list are enumerated
and a single temporary file t1.cpp is created as follows:

   #include "entry_1"
   #include "entry_2"
   ...
   #include "entry_n"

2. t1 is sent to the C++ compiler (with all its options,
definitions and include paths set as for a normal build),
but for preprocessing stage only (i.e. g++ -E). The resulting
C++ file is my inc.cpp.

How can I achieve that goal using CMake? Of course
it doesn't need to be done the way I specified above,
as I am pretty new to CMake. A functional equivalent
is all what I need, in particular I don't need t1.cpp.

Best regards
Piotr Wyderski
___
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] Problem with cygwin and CodeSourcery's ARM Toolchain

2009-05-07 Thread Hendrik Sattler

Zitat von Thomas Kindler :

cmake tries to use cygwin-style absolute "/home/tkindler.." paths,
which arm-none-eabi-gcc doesn't seem to like (being a native win32
program).

My old makefile used relative paths to invoke the compiler. How can I
do this in cmake generated makefiles?!

Prepending "c:/cygwin/" to all paths should also solve the problem.


If you have a native compiler, use the native compiled cmake. If you  
have a compiler/tool that depends on cygwin, use the cygwin-compiled  
cmake.

Living in both worlds (native vs. cygwin) is a major pain. Just don't.

HS


___
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] Automatic libraries stripping

2009-05-07 Thread rozelak

Uh, so simple. Thank you, I didn't know about this option (probably not
read gcc manpage carefully). Thank you again.

Dan

> 
> > I would like to ask you, if (and how, if so) it is
> > possible
> > > to set CMake
> > to strip (/usr/bin/strip) the generated libraries.
> > 
> Use -s option for gcc. You don't need to use strip
> directly.
> 
> Denis
> 
> 
> 


___
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] Problem with cygwin and CodeSourcery's ARM Toolchain

2009-05-07 Thread Thomas Kindler

Hi!

I'm just playing around with cmake for a new embedded project using a 
STM32 ARM Cortex-M3 processor.


I have installed cmake 2.6.0-patch 2 from the cygwin distribution and 
use a windows gcc toolchain from www.codesourcery.com.


After reading the manual and FAQ, i created a CodeSourcery.cmake file:

  # the name of the target operating system
  #
  set(CMAKE_SYSTEM_NAME  Generic)
  set(CMAKE_SYSTEM_VERSION   1)
  set(CMAKE_SYSTEM_PROCESSOR arm-eabi)

  # which compilers to use for C and C++
  #
  set(CMAKE_C_COMPILER   arm-none-eabi-gcc)
  set(CMAKE_CXX_COMPILER arm-none-eabi-g++)

  # adjust the default behaviour of the FIND_XXX() commands:
  # search headers and libraries in the target environment,
  # search programs in the host environment
  #
  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


and a CMakeLists.txt in my project directory:

  project(STM32 C)
  cmake_minimum_required(VERSION 2.6)

  set(CMAKE_TOOLCHAIN_FILE  CodeSourcery.cmake)

  set(COMPILE_DEFINITIONS_DEBUG-O0 -g3 -DDEBUG)
  set(COMPILE_DEFINITIONS_RELEASE  -O2)

  add_definitions(
-Wall
-Wshadow
-Wcast-qual
-Wwrite-strings
-Winline

-std=gnu99

-DSTM32F10X_HD   # for peripheral library
-DUSE_STDPERIPH_DRIVER
-DGCC_ARMCM3 # for FreeRTOS
  )

  include_directories(
${STM32_SOURCE_DIR}/.
${STM32_SOURCE_DIR}/fwlib
${STM32_SOURCE_DIR}/fwlib/inc
${STM32_SOURCE_DIR}/FreeRTOS/Source/include
  )

  link_directories(
${STM32_BINARY_DIR}/fwlib
  )

  add_executable(stm32test
bigfont.c
bitmap.c
enc28j60.c
graphics.c
lcd7565.c
main.c
syscalls.c
sysfont.c
systick.c
uart.c
  )

  target_link_libraries(stm32test libstm32fw.a)

...


The problem is:  It doesn't work:

$ cmake -DCMAKE_TOOLCHAIN_FILE=CodeSourcery.cmake .
-- The C compiler identification is GNU
-- Check for working C compiler: 
/cygdrive/c/code/sourcery/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: 
/cygdrive/c/code/sourcery/bin/arm-none-eabi-gcc.exe -- broken
CMake Error at 
/usr/share/cmake-2.6.2/Modules/CMakeTestCCompiler.cmake:32 (MESSAGE):
  The C compiler "/cygdrive/c/code/sourcery/bin/arm-none-eabi-gcc.exe" 
is not

  able to compile a simple test program.

  It fails with the following output:

   Change Dir: /home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp

  Run Build Command:/usr/bin/make.exe "cmTryCompileExec/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
  CMakeFiles/cmTryCompileExec.dir/build

  make[1]: Entering directory
  `/home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp'

  /usr/bin/cmake.exe -E cmake_progress_report
  /home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj

  /cygdrive/c/code/sourcery/bin/arm-none-eabi-gcc.exe -o
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj -c
  /home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp/testCCompiler.c

  make[1]: Leaving directory
  `/home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp'

  arm-none-eabi-gcc.exe:
  /home/tkindler/multiturn-stm32/CMakeFiles/CMakeTmp/testCCompiler.c: 
No such

  file or directory

  arm-none-eabi-gcc.exe: no input files

  make[1]: *** [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj] 
Error 1


  make: *** [cmTryCompileExec/fast] Error 2


  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:8 (project)


-- Configuring incomplete, errors occurred!


cmake tries to use cygwin-style absolute "/home/tkindler.." paths, which 
arm-none-eabi-gcc doesn't seem to like (being a native win32 program).


My old makefile used relative paths to invoke the compiler. How can I do 
this in cmake generated makefiles?!


Prepending "c:/cygwin/" to all paths should also solve the problem.


greetings,
--
Thomas Kindler 
___
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] Automatic libraries stripping

2009-05-07 Thread Hendrik Sattler

Zitat von roze...@volny.cz:

I would like to ask you, if (and how, if so) it is possible to set CMake
to strip (/usr/bin/strip) the generated libraries.


Hint: make help | grep strip

HS


___
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] Automatic libraries stripping

2009-05-07 Thread Denis Scherbakov

> I would like to ask you, if (and how, if so) it is possible
> to set CMake
> to strip (/usr/bin/strip) the generated libraries.

Use -s option for gcc. You don't need to use strip directly.

Denis


  
___
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] Automatic libraries stripping

2009-05-07 Thread rozelak
Hallo everybody.

I would like to ask you, if (and how, if so) it is possible to set CMake
to strip (/usr/bin/strip) the generated libraries. Let me note that
build works without problems.

I made the following definition (LIB_NAME is item defined by me):

ADD_CUSTOM_COMMAND(TARGET ${LIB_NAME}
POST_BUILD
COMMAND   ${CMAKE_STRIP} *.so )

and for SWIG generated wrappers (PYTHON_PACKAGE is item defined by me,
similar it is for java):

ADD_CUSTOM_COMMAND( TARGET${SWIG_MODULE_${PYTHON_PACKAGE}_REAL_NAME}
POST_BUILD
COMMAND   ${CMAKE_STRIP} *.so )

There are several problems with it:
- it does not strip .a libraries
- it does not strip .dll/.dll.a libraries generated by mingw toolchain

Well, I can play with the pattern given to strip binary, but I am not
sure which solution is the most robust, taking into account various
forms of library names (see further).

Therefore, I would like to ask, if there is a robust solution, how to
strip the libraries automatically, no matter if they are prefixed by
'lib*' or end by '.so', '.a' or '.dll'.


I know that CPACK_STRIP_FILES can be set to ON, but I do not build packages
(I just have INSTALL() which basically copy the generated stuff into
directory, from where it can be downloaded by other team members).

I also suppose that ADD_LIBRARY() knows exactly the name of library to
generate (for gcc it generates '-o libMyLib.so' in link command, or
'ar ... libMyLib.o' when static lib is built), and it also knows if
${CMAKE_STRIP} is defined. Also, ADD_LIBRARY() knows that there are
more libraries to generate for mingw toolchain (it generates '-o libMyLib.dll
-Wl,--out-implib,libMyLib.dll.a'). It would be cool to have an option
in ADD_LIBRARY() that would switch on the stripping of all libraries
generated. Well, I know that it is not implemented, it is just an idea
...


Nevertheless, I would like to ask you, if you know how to solve it by
means of CMake available at the moment (version 2.6). Is there for example
a variable holding the name of library, or libraries, if more are generated
(see mingw example)? Could it be solved in a robust and toolchain (e.g.
library name) independent way?

Thank you very much,
Dan


P.S. My CMake is version 2.6

___
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] foreach() bug?

2009-05-07 Thread Brad King

alexandre.feb...@thomsonreuters.com wrote:

Ok, thanks for the info.
Can I expect this "IN" mode to be delivered in 2.6.5?


Probably not.  It's currently experimental, and we might
still change how it works.

-Brad
___
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] Specify dependency on externally generated shared library

2009-05-07 Thread Scott Gray


Tyler Roscoe wrote:

On Wed, May 06, 2009 at 03:53:10PM -0400, Scott Gray wrote:
  

My problem is that I need to both generate the DLL and declare it as an
imported library so that other programs can depend upon it.  I think I'm



Maybe I'm missing something, but why do you need to do this? If you are
building the library yourself, why would you need to mark it as
"imported"?
  


You are right, I don't need to import it.  My feeble brain was thinking 
that this would be a good way in which programs that would depend upon 
the generated library, thus they could just to:


add_executable(some_prog some_prog.c)
target_link_libraries(some_prog mylib_intl)

and cmake would just "know" where mylib_intl is located based upon the 
process that was used to generated it.


However, upon your suggestion I got rid of the IMPORT of the library and 
just did:


   link_directories("${LIBRARY_OUTPUT_PATH"})
   add_executable(some_prog some_prog.c)
   target_link_libraries(some_prog mylib_intl)

And it works.



make[2]: *** No rule to make target
`src/util/build/dist/lib/libmylib_intl.so', needed by `src/util/test/myprog'



I think all you need is to create a target with add_custom_target() that
drives the custom_command(), and then add_dependencies(your_library
translation_library_target).
  


Again, you are right. I followed your advice and everything seems to be 
working OK now. Now for the real test, I need to see if I can compile my 
stuff on Windows (ugh).  We'll see how that goes :)


Thanks!
-scott

___
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] Create executable with no dynamic dependency at all

2009-05-07 Thread Denis Scherbakov

James,

I took a look again at our source and notices, that we set
CMAKE_BUILD_TYPE to Custom, so no default options migrate into our
environment.

I think you receive -Wl,-Bdynamic from
cmake/Modules/Platform/Linux.cmake:25:  SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS 
"-Wl,-Bdynamic")

My system is Gentoo Linux. Cmake is 2.6.4.

find /usr/share/cmake/Modules/Platform -type f | xargs grep -n -H 
'\-Wl\,\-Bdynamic'

Denis

> Now the only problem I have is that "-Wl,-Bdynamic
> -Wl,-rpath,/usr/local/lib" is still added to the end
> of the linker
> commandline - which is a bug, since no dynamic libs are
> linked.
> Any ideas how to work-around this or how to track down why
> and where this
> empty "-Wl,-Bdynamic" flag is added?



  
___
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] Create executable with no dynamic dependency at all

2009-05-07 Thread Jean-Pierre Bergamin
> I set -static flag in the top level CMakeLists.txt:
> 
> SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
> before ADD_SUBDIRECTORY.

I now tried:
set_target_properties(ui PROPERTIES LINK_FLAGS "-static")

This helps so that "-static" is used when linking. Good.

Now the only problem I have is that "-Wl,-Bdynamic
-Wl,-rpath,/usr/local/lib" is still added to the end of the linker
commandline - which is a bug, since no dynamic libs are linked.
Any ideas how to work-around this or how to track down why and where this
empty "-Wl,-Bdynamic" flag is added?


Thanks

James



> > May I ask what platform you are using? I just tried the
> > following simplest
> > example on FreeBSD 6 and on Ubuntu 8.10. On both platforms
> > I do not manage
> > to get a non-dyanamic executable. How do I get the
> > "-static" flag set?
> 
> 
> 
> 
> ___
> 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] Implicity CMAKE_CURRENT_BINARY_DIR include_directories

2009-05-07 Thread Mike Arthur
I'm sure I read some time about some option you could set in a CMake project 
that would always implicitly do 
include_directories(${CMAKE_CURRENT_BINARY_DIR}) in child CMakeLists.txt 
without the need to do so manually.

Searched the documentation to no avail. Did I just imagine this option or is 
it there somewhere?

Thanks!
-- 
Cheers,
Mike Arthur
http://mikearthur.co.uk/
___
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] Add Project Group command

2009-05-07 Thread Micha Renner
In Bugtracker http://public.kitware.com/Bug/view.php?id=3796

you could read: Groovounet: "I'm so glade to see this patch coming
out ..."

Does this mean, that this feature is now implemented (2.6.4) and, if so,
exists there an example how to use it?

greetings
Micha


___
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] Create executable with no dynamic dependency at all

2009-05-07 Thread Denis Scherbakov

Jean-Pierre,

I set -static flag in the top level CMakeLists.txt:

SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
before ADD_SUBDIRECTORY.

I didn't find any error in your files, I would do the same with exception to 
-static flag.

Denis

> May I ask what platform you are using? I just tried the
> following simplest
> example on FreeBSD 6 and on Ubuntu 8.10. On both platforms
> I do not manage
> to get a non-dyanamic executable. How do I get the
> "-static" flag set?



  
___
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] foreach() bug?

2009-05-07 Thread Alexandre.Feblot
Ok, thanks for the info.
Can I expect this "IN" mode to be delivered in 2.6.5?

Alexandre

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 


alexandre.feb...@thomsonreuters.com wrote:
> foreach(arg ${list})
[snip]
> The empty element has been discarded by foreach(). Is this the wanted 
> behaviour? If it is, how can I manage empty elements when I need them?

The foreach command never even sees the empty arguments.  By the time
${list} is evaluated the empty elements are gone.  This is for language
consistency.  No one would want

   add_executable(myexe ${srcs})

to try to add "" as a source file if srcs has an empty element.

In CMake HEAD from CVS there is an "IN" mode for foreach that supports
explicitly named lists:

   set(my_list "a;b;;c;d")
   foreach(arg IN LISTS my_list)
 ...
   endforeach()

For now you need to use the list() command.  You can iterate over
a range of the list size with foreach(arg RANGE ...).

-Brad


This email was sent to you by Thomson Reuters, the global news and information 
company.
Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the views of Thomson Reuters.


___
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] Create executable with no dynamic dependency at all

2009-05-07 Thread Jean-Pierre Bergamin
Hello

> > So my question is how to avoid any dynamic linking at all.
> > I found this bug report
> > http://www.vtk.org/Bug/view.php?id=1644 that says
> > that this has been implemented - but how?

> I am not sure, how you get -Wl,-Bstatic and so on. Here is how I get
> static executable:
> 
> $ /usr/bin/c++  -O2 -fomit-frame-pointer -fPIC -s -static \
> CMakeFiles/DispatcherExe.dir/DispatcherMain.cc.o \
> -o DispatcherExe \
> -rdynamic ../../Generic/libGeneric.a \
> ../../CorbaUtil/libCorbaUtil.a -lmico2.3.13 -lmicocoss2.3.13 -lssl -
> lcrypto -lpthread -ldl
> 
> $ ldd DispatcherExe
> not a dynamic executable
> 
> Here is how I link it:
> 
> ADD_LIBRARY(Generic STATIC ${GENERIC_SRCS})
> 
> ADD_LIBRARY(CorbaUtil STATIC ${CORBAUTIL_SRCS})
> TARGET_LINK_LIBRARIES(CorbaUtil  ${MICO_LIBRARY} ${MICO_COSS_LIBRARY}
> ssl crypto pthread dl)
> 
> ADD_EXECUTABLE(DispatcherExe  ${OPERDISPATCHER_SRCS})
> TARGET_LINK_LIBRARIES(DispatcherExe  CorbaUtil Generic)


May I ask what platform you are using? I just tried the following simplest
example on FreeBSD 6 and on Ubuntu 8.10. On both platforms I do not manage
to get a non-dyanamic executable. How do I get the "-static" flag set?


Regards

James


$ cat CMakeLists.txt 
add_library(mylib STATIC mylib.cpp)
add_executable(static static.cpp)
target_link_libraries(static mylib)

$ cat mylib.h
void f();

$ cat mylib.cpp 
#include 
#include "mylib.h"

void f() {
std::cout << "mylib speaking..." << std::endl;
}

$ cat static.cpp 
#include "mylib.h"

int main() {
f();
return 0;
}

$ cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/james/test/cmake

$ make VERBOSE=1
/usr/local/bin/cmake -H/home/james/test/cmake -B/home/james/test/cmake
--check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start
/home/james/test/cmake/CMakeFiles
/home/james/test/cmake/CMakeFiles/progress.make
make -f CMakeFiles/Makefile2 all
make -f CMakeFiles/mylib.dir/build.make CMakeFiles/mylib.dir/depend
cd /home/james/test/cmake && /usr/local/bin/cmake -E cmake_depends "Unix
Makefiles" /home/james/test/cmake /home/james/test/cmake
/home/james/test/cmake /home/james/test/cmake
/home/james/test/cmake/CMakeFiles/mylib.dir/DependInfo.cmake --color=
Dependee "/home/james/test/cmake/CMakeFiles/mylib.dir/DependInfo.cmake" is
newer than depender
"/home/james/test/cmake/CMakeFiles/mylib.dir/depend.internal".
Scanning dependencies of target mylib
make -f CMakeFiles/mylib.dir/build.make CMakeFiles/mylib.dir/build
/usr/local/bin/cmake -E cmake_progress_report
/home/james/test/cmake/CMakeFiles 1
[ 50%] Building CXX object CMakeFiles/mylib.dir/mylib.cpp.o
/usr/bin/c++ -o CMakeFiles/mylib.dir/mylib.cpp.o -c
/home/james/test/cmake/mylib.cpp
Linking CXX static library libmylib.a
/usr/local/bin/cmake -P CMakeFiles/mylib.dir/cmake_clean_target.cmake
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/mylib.dir/link.txt
--verbose=1
/usr/bin/ar cr libmylib.a  CMakeFiles/mylib.dir/mylib.cpp.o
/usr/bin/ranlib libmylib.a
/usr/local/bin/cmake -E cmake_progress_report
/home/james/test/cmake/CMakeFiles  1
[ 50%] Built target mylib
make -f CMakeFiles/static.dir/build.make CMakeFiles/static.dir/depend
cd /home/james/test/cmake && /usr/local/bin/cmake -E cmake_depends "Unix
Makefiles" /home/james/test/cmake /home/james/test/cmake
/home/james/test/cmake /home/james/test/cmake
/home/james/test/cmake/CMakeFiles/static.dir/DependInfo.cmake --color=
Dependee "/home/james/test/cmake/CMakeFiles/static.dir/DependInfo.cmake" is
newer than depender
"/home/james/test/cmake/CMakeFiles/static.dir/depend.internal".
Scanning dependencies of target static
make -f CMakeFiles/static.dir/build.make CMakeFiles/static.dir/build
/usr/local/bin/cmake -E cmake_progress_report
/home/james/test/cmake/CMakeFiles 2
[100%] Building CXX object CMakeFiles/static.dir/static.cpp.o
/usr/bin/c++ -o CMakeFiles/static.dir/static.cpp.o -c
/home/james/test/cmake/static.cpp
Linking CXX executable static
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/static.dir/link.txt
--verbose=1
/usr/bin/c++ -fPIC CMakeFiles/static.dir/static.cpp.o  -o static
libmylib.a 
/usr/local/bin/cmake -E cmake_progress_report
/home/james/test/cmake/CMakeFiles  2
[100%] Built target static
/usr/local/bin/cmake -E cmake_progress_start
/home/james/test/cmake/CMakeFiles 0

$ ldd static
static:
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x2807a000)
libm.so.4 => /lib/libm.so.4 (0x28145000)
libc.so.6 => /lib/libc.so.6 (0x2815b000)

Re: [CMake] Create executable with no dynamic dependency at all

2009-05-07 Thread Denis Scherbakov

Jean-Pierre,

I am not sure, how you get -Wl,-Bstatic and so on. Here is how I get static 
executable:

$ /usr/bin/c++  -O2 -fomit-frame-pointer -fPIC -s -static \
CMakeFiles/DispatcherExe.dir/DispatcherMain.cc.o \
-o DispatcherExe \
-rdynamic ../../Generic/libGeneric.a \
../../CorbaUtil/libCorbaUtil.a -lmico2.3.13 -lmicocoss2.3.13 -lssl -lcrypto 
-lpthread -ldl

$ ldd DispatcherExe
not a dynamic executable

Here is how I link it:

ADD_LIBRARY(Generic STATIC ${GENERIC_SRCS})

ADD_LIBRARY(CorbaUtil STATIC ${CORBAUTIL_SRCS})
TARGET_LINK_LIBRARIES(CorbaUtil  ${MICO_LIBRARY} ${MICO_COSS_LIBRARY} ssl 
crypto pthread dl)

ADD_EXECUTABLE(DispatcherExe  ${OPERDISPATCHER_SRCS})
TARGET_LINK_LIBRARIES(DispatcherExe  CorbaUtil Generic)

Denis

--- On Wed, 5/6/09, Jean-Pierre Bergamin  wrote:

> From: Jean-Pierre Bergamin 
> Subject: [CMake] Create executable with no dynamic dependency at all
> To: cmake@cmake.org
> Date: Wednesday, May 6, 2009, 11:59 PM
> Hello CMake users
> 

> So my question is how to avoid any dynamic linking at all.
> I found this bug report
> http://www.vtk.org/Bug/view.php?id=1644 that says
> that this has been implemented - but how?



  
___
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] Create executable with no dynamic dependency at all

2009-05-07 Thread Jean-Pierre Bergamin
Hello CMake users

We are building a CGI for a chrooted web environment. The resulting binary
must not use any dynamic libs, but link everything statically (also libc and
libstdc++ etc.).

We currently build this binary with:
  LDFLAGS = -static -lboost_regex -lz ../libs/bla.a

And the resulting gcc command line is:
  g++ -o ui foo.o -L/usr/local/lib -static -lboost_regex -lz ../libs/bla.a

The resulting binary has no dynamic dependencies at all (which is good):
# ldd ui
ldd: ui: not a dynamic ELF executable

First shot with CMake 2.6.3:
  set(Boost_USE_STATIC_LIBS ON)
  find_package(Boost 1.34.1 COMPONENTS regex)
  target_link_libraries(ui bla-static libz.a ${Boost_LIBRARIES} libthr.a)

The resulting gcc command line is:
  /usr/bin/c++ -fPIC CMakeFiles/ui.dir/foo.cpp.o -o ui  -L/usr/local/lib
libbla-static.a ../libs/bla.a -Wl,-Bstatic -lz -Wl,-Bdynamic
/usr/local/lib/libboost_regex.a -Wl,-Bstatic -lthr -Wl,-Bdynamic
-Wl,-rpath,/usr/local/lib

The first error is that the static boost lib is linked with the dynamic
flag, but anyway.

Next try:
  target_link_libraries(ui bla-static libz.a libboost_regex.a libthr.a)

Resulting gcc line:
  /usr/bin/c++ -fPIC CMakeFiles/ui.dir/foo.cpp.o -o ui -L/usr/local/lib
libbla-static.a ../libs/bla.a -Wl,-Bstatic -lz -lboost_regex -Wl,-Bdynamic
-Wl,-rpath,/usr/local/lib

The boost lib is now linked statically, but the flag "-Wl,-Bdynamic" at the
end still creates a dynamic linked executable:
# ldd ui:
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x2861a000)
libm.so.4 => /lib/libm.so.4 (0x286e5000)
libc.so.6 => /lib/libc.so.6 (0x286fb000)


So my question is how to avoid any dynamic linking at all.
I found this bug report http://www.vtk.org/Bug/view.php?id=1644 that says
that this has been implemented - but how?


Thanks for your help.

James

___
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