-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sagnes, Frederic wrote:
> 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_OPT_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)

In case you only have one of the libraries BOOST_PRG_LIBRARY is empty. A
 better way is too add a few checks

IF(BOOST_PRG_OPT_LIBRARY AND BOOST_PRG_DBG_LIBRARY)
  SET(BOOST_PRG_LIBRARY
    optimized ${BOOST_PRG_OPT_LIBRARY}
    debug ${BOOST_PRG_DBG_LIBRARY})
ELSE(BOOST_PRG_OPT_LIBRARY AND BOOST_PRG_DBG_LIBRARY)
  IF(BOOST_PRG_OPT_LIBRARY)
    SET(BOOST_PRG_LIBRARY ${BOOST_PRG_OPT_LIBRARY})
  ELSE(BOOST_PRG_OPT_LIBRARY)
    IF(BOOST_PRG_DBG_LIBRARY)
      SET(BOOST_PRG_LIBRARY ${BOOST_PRG_DBG_LIBRARY})
    ENDIF(BOOST_PRG_DBG_LIBRARY)
  ENDIF(BOOST_PRG_OPT_LIBRARY)
ENDIF(BOOST_PRG_OPT_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.

You have to set CMAKE_BUILD_TYPE to RELEASE or DEBUG so that cmake can
make a choice between the debug and the optimized library.

> Thank you,
> 
> Frédéric Sagnes
- --
Filipe Sousa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iD8DBQFEq4mhbQdNYqwwwCwRArvZAKCbk5mIJerdzyV5eIvUkf1QGo9iVQCbBQVk
oBOfSuGLVA1r2Y7R43vdZ9o=
=HhnR
-----END PGP SIGNATURE-----
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to