Re: [CMake] How to get find_package(ZLIB) to set ZLIB_LIBRARIES to 32-bit version ?

2014-06-25 Thread Rolf Eike Beer
Am Dienstag, 24. Juni 2014, 22:32:22 schrieb Glenn Coombs:
 This seems to be the recommended way to link against the zlib library:
 
 find_package(ZLIB)if (ZLIB_FOUND)
 include_directories(${ZLIB_INCLUDE_DIRS})
 target_link_libraries(MyProg ${ZLIB_LIBRARIES})
 endif()
 
 When I run this on linux I see that ZLIB_LIBRARIES has the value
 /usr/lib64/libz.so.  On this machine gcc creates 64-bit binaries by
 default.  In my CMakeLists.txt I have an option for building 32-bit which
 adds -m32 to the compiler and linker command lines.  However the
 ZLIB_LIBRARIES variable is still returning the 64-bit version
 (/usr/lib64/libz.so) instead of the 32-bit version (/usr/lib/libz.so).

That means that CMake doesn't know that it is building a 32 bit executable, 
which is a bad idea for reasons you already discovered. Try CC=gcc -m32 
cmake ... in a clean build tree.

Eke

signature.asc
Description: This is a digitally signed message part.
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] How to get find_package(ZLIB) to set ZLIB_LIBRARIES to 32-bit version ?

2014-06-25 Thread Glenn Coombs
One of the nice things about cmake is that you can hide any complicated
build options inside the CMakeLists.txt file and present options to the
user via the cmake-gui.  Your solution negates that - the user now has to
know which compiler they are using and which options are relevant where as
before all they did was select the option labelled build 32-bit from
inside of cmake-gui.  When building using Visual Studio on Windows there
are separate generator options for the 32-bit and 64-bit builds so again
this is presented to the user via cmake-gui.

I'd really like to keep the cmake-gui as the sole interface for configuring
everything.  Is there no way to get find_package to use the current value
of the COMPILE_OPTIONS variable as modified inside the top level
CMakeLists.txt file based on options set by the user inside cmake-gui ?


On 25 June 2014 07:18, Rolf Eike Beer e...@sf-mail.de wrote:

 Am Dienstag, 24. Juni 2014, 22:32:22 schrieb Glenn Coombs:
  This seems to be the recommended way to link against the zlib library:
 
  find_package(ZLIB)if (ZLIB_FOUND)
  include_directories(${ZLIB_INCLUDE_DIRS})
  target_link_libraries(MyProg ${ZLIB_LIBRARIES})
  endif()
 
  When I run this on linux I see that ZLIB_LIBRARIES has the value
  /usr/lib64/libz.so.  On this machine gcc creates 64-bit binaries by
  default.  In my CMakeLists.txt I have an option for building 32-bit which
  adds -m32 to the compiler and linker command lines.  However the
  ZLIB_LIBRARIES variable is still returning the 64-bit version
  (/usr/lib64/libz.so) instead of the 32-bit version (/usr/lib/libz.so).

 That means that CMake doesn't know that it is building a 32 bit executable,
 which is a bad idea for reasons you already discovered. Try CC=gcc -m32
 cmake ... in a clean build tree.

 Eke
 --

 Powered by www.kitware.com

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

 Kitware offers various services to support the CMake community. For more
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

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

 Follow this link to subscribe/unsubscribe:
 http://public.kitware.com/mailman/listinfo/cmake

-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] How to get find_package(ZLIB) to set ZLIB_LIBRARIES to 32-bit version ?

2014-06-24 Thread Glenn Coombs
This seems to be the recommended way to link against the zlib library:

find_package(ZLIB)if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(MyProg ${ZLIB_LIBRARIES})
endif()

When I run this on linux I see that ZLIB_LIBRARIES has the value
/usr/lib64/libz.so.  On this machine gcc creates 64-bit binaries by
default.  In my CMakeLists.txt I have an option for building 32-bit which
adds -m32 to the compiler and linker command lines.  However the
ZLIB_LIBRARIES variable is still returning the 64-bit version
(/usr/lib64/libz.so) instead of the 32-bit version (/usr/lib/libz.so).

Is there some way for me to let cmake know that I'm building 32-bit so that
the find_package(ZLIB) command sets ZLIB_LIBRARIES to the correct 32-bit
version of the library ?

--
Glenn
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake