AW: [CMake] Where to find consistent documentation about CMake ?

Sagnes, Frederic frederic.sagnes at siemens.com
Wed Jul 5 05:02:09 EDT 2006


[Sorry if this message appears twice, I was not sure about the address]

Hello Alex, thank you for your quick answer!

The message command works great, as well as the compiler flags settings. No idea about the static libraries? The product we are building should be standalone, even in a Unix environment.

Considering the release/debug profile on Unix, the problem is that I link to debug and release libraries on Visual C++ (I use Boost libraries), this is required because the wrong linked library in either profiles causes library conflict and make the application crash. To generate the linking I use the following code:

FIND_LIBRARY (
  BOOST_PRG_LIBRARY
    ${BOOST_LIB_PREFIX}boost_program_options${BOOST_LIB_SUFFIX}
    ${LINK_DIRECTORIES}
)
FIND_LIBRARY (
  BOOST_PRG_DBG_LIBRARY
    ${BOOST_LIB_PREFIX}boost_program_options${BOOST_LIB_DBG_SUFFIX}
    ${LINK_DIRECTORIES}
)
IF (BOOST_PRG_LIBRARY AND BOOST_PRG_DBG_LIBRARY)
  SET (
    BOOST_PRG_LIBRARY
      optimized ${BOOST_PRG_LIBRARY}
      debug ${BOOST_PRG_DBG_LIBRARY}
  )
ENDIF (BOOST_PRG_LIBRARY AND BOOST_PRG_DBG_LIBRARY)

ADD_EXECUTABLE (
  TestClient
    TestClient.cpp
)

TARGET_LINK_LIBRARIES (
  TestClient
    ${BOOST_PRG_LIBRARY}
)

Which in the end expands ${BOOST_PRG_LIBRARY} to :
optimized;D:\ALM\Boost\vc-8_0\lib\ boost_program_options-vc80-mt.lib;debug; D:\ALM\Boost\vc-8_0\lib\ boost_program_options-vc80-mt-gd.lib
 
This works well under VS, and Unix boost builds also have debug libraries. I thought CMake would create some special targets to generate either release or debug binaries, instead of that it generates one target and does not link to any library, which makes the compilation fail with symbols not found errors. How does CMake handle these profiles with the Makefile generator?

I'll have a look at these project's CMake files, but still, a central and consistent help for CMake would be a real plus. Your project is great; it only lacks a manual to take advantage of all of its features.

Thank you,

Frédéric Sagnes

-----Ursprüngliche Nachricht-----
Von: cmake-bounces+frederic.sagnes=siemens.com at cmake.org [mailto:cmake-bounces+frederic.sagnes=siemens.com at cmake.org] Im Auftrag von Alexander Neundorf
Gesendet: Mittwoch, 5. Juli 2006 10:00
An: cmake at www.cmake.org
Betreff: Re: [CMake] Where to find consistent documentation about CMake ?

Hi,

Am Mittwoch 05 Juli 2006 09:01 schrieb Sagnes, Frederic:
> Hello,
>
> I'm getting used to CMake to build a cross platform project on Windows 
> and Linux, and it really seems to be quite powerful. But the 
> documentation provided on the website is really minimalist, rough (no 
> topics, no real examples ...) and incomplete (no summary of all 
> internal variables and their meanings, some commands are not clearly 
> described ...). I'm really feeling like I'm missing a big part of the 
> magic behind CMake. We could buy the book, but I'm working in a 
> corporate environment and it would take weeks until I get it.

Please check also the cmake wiki and FAQ.
There are also many examples in vtk, itk and KDE 4 svn ( http://websvn.kde.org/trunk/KDE/ )

> Did I miss something or the only available documentation is the 
> command-line generated one, the FAQ and the Wiki?
>
> Here are a few question I couldn't answer by reading the documentation:
> * How can I be sure to link statically on Unix when using the 
> FIND_LIBRARY primitive?

> * How can I raise an error message and stop the generation (when a 
> library I'm depending on is not available for instance)

MESSAGE(FATAL_ERROR "game over")

> * Can I use an
> intern variable so that CMake can automatically raise the compiler 
> error checking level (like CMAKE_CXX_WARNING_LEVEL for Visual Studio), 
> and add for instance -Wall and -pedantic to the GCC command line?

See the flags below.
You can also check
if (MSVC)
and
if (CMAKE_COMPILER_IS_GNUCXX)
to test for the compiler in cmake.

> * How does CMake
> handle release/debug profiles with Unix Makefile generator?

You can set CMAKE_BUILD_TYPE e.g. to DEBUG or RELEASE, and then the specific compile flags will be used:

set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns
-fno-inline")
set(CMAKE_C_FLAGS_RELEASE    "-O2")
set(CMAKE_C_FLAGS_DEBUG      "-g -O2 -fno-reorder-blocks -fno-schedule-insns 
-fno-inline")

Bye
Alex



More information about the CMake mailing list