<HTML>
<HEAD>
<TITLE>Re: [CMake] Trouble setting LIBRARY_OUTPUT_DIRECTORY</TITLE>
</HEAD>
<BODY>
<FONT FACE="Courier, Courier New"><SPAN STYLE='font-size:12pt'>Mike – thanks for the idea - I have been blowing away my build dir to be safe all this time, i.e.<BR>
<BR>
rm -rf * ; cmake ../distro/zlib-1.2.3 ; make install<BR>
<BR>
Clint – your suggestion solved this problem. The following commands work iff they appeared prior to the add_library/add_executable statements<BR>
<BR>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)<BR>
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)<BR>
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)<BR>
<BR>
Note that these commands worked, to be complete I tried them again without the leading “CMAKE_” and those commands (per the online 2.6 docs) do not work, word to the wise.<BR>
<BR>
Thanks everyone, this is a valuable forum.<BR>
<BR>
<BR>
On 6/4/09 2:17 PM, "Clinton Stimpson" <<a href="clinton@elemtech.com">clinton@elemtech.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Courier, Courier New"><SPAN STYLE='font-size:12pt'><BR>
<BR>
How about setting the output dir variables before specifying the<BR>
libraries and executables you want.<BR>
<BR>
Clint<BR>
<BR>
Lober, Randy wrote:<BR>
> Thanks for the response and suggestion Mike.<BR>
><BR>
> I had tried directly setting the value CMAKE_LIBRARY_OUTPUT_DIRECTORY<BR>
> once before to no avail but following your idea I tried all three<BR>
> again as you list below. Unfortunately, this still does not succeed in<BR>
> defining a non-default creation location for my targets. Again, even<BR>
> using the commands below no values for the three variables are being<BR>
> written into my CMakeCache.txt file.<BR>
><BR>
> I have changed the rest of my operations in the file to work with the<BR>
> targets from the default location but it is troubling to me that this<BR>
> command (seemingly) is not working for me. I will be moving on to much<BR>
> more difficult builds soon and I will need this functionality.<BR>
><BR>
> If anyone has any other insights I would greatly appreciate them.<BR>
><BR>
> Thanks, Randy<BR>
><BR>
><BR>
> On 6/4/09 1:22 PM, "Michael Jackson" <<a href="mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>> wrote:<BR>
><BR>
> # ---------- Setup output Directories -------------------------<BR>
> SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY<BR>
> ${PROJECT_BINARY_DIR}/Bin )<BR>
><BR>
> # --------- Setup the Executable output Directory -------------<BR>
> SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY<BR>
> ${PROJECT_BINARY_DIR}/Bin )<BR>
><BR>
> # --------- Setup the Executable output Directory -------------<BR>
> SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY<BR>
> ${PROJECT_BINARY_DIR}/Bin )<BR>
><BR>
> Will put every library and executable into a subdirectory called "Bin"<BR>
><BR>
> _________________________________________________________<BR>
> Mike Jackson <a href="mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a><BR>
> BlueQuartz Software www.bluequartz.net<BR>
> Principal Software Engineer Dayton, Ohio<BR>
><BR>
><BR>
><BR>
> On Jun 4, 2009, at 3:13 PM, Lober, Randy wrote:<BR>
><BR>
> > Hello, I am a new user of cmake and I am running version 2.6-patch 4<BR>
> > on Linux.<BR>
> ><BR>
> > I am setting up a simple project to learn cmake and most everything<BR>
> > has worked just as expected except for my attempts to define where<BR>
> > an output library target is to be created. Here is part of the<BR>
> > CMakeLists.txt<BR>
> ><BR>
> > project(ZLIB C)<BR>
> > SET(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)<BR>
> > SET(CMAKE_BUILD_TYPE Release)<BR>
> ><BR>
> > set(CMAKE_C_COMPILER gcc)<BR>
> > add_definitions(-O3)<BR>
> > set(BUILD_SHARED_LIBS ON)<BR>
> > cmake_minimum_required(VERSION 2.6)<BR>
> ><BR>
> > set(ZLIB_PUBLIC_HDRS<BR>
> > zconf.h<BR>
> > zlib.h<BR>
> > )<BR>
> ><BR>
> > set(ZLIB_PRIVATE_HDRS<BR>
> > crc32.h<BR>
> > deflate.h<BR>
> > inffast.h<BR>
> > inffixed.h<BR>
> > inflate.h<BR>
> > inftrees.h<BR>
> > trees.h<BR>
> > zutil.h<BR>
> > )<BR>
> ><BR>
> > set(ZLIB_SRCS<BR>
> > adler32.c<BR>
> > compress.c<BR>
> > crc32.c<BR>
> > deflate.c<BR>
> > inflate.c<BR>
> > infback.c<BR>
> > inftrees.c<BR>
> > inffast.c<BR>
> > gzio.c<BR>
> > trees.c<BR>
> > uncompr.c<BR>
> > zutil.c<BR>
> > )<BR>
> ><BR>
> > set(ZLIB_TEST_SRCS<BR>
> > example.c<BR>
> > )<BR>
> ><BR>
> > set(ZLIB_MAN_SRCS<BR>
> > zlib.3<BR>
> > )<BR>
> ><BR>
> > add_library(z ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})<BR>
> > set_target_properties(z PROPERTIES DEFINE_SYMBOL ZLIB_DLL)<BR>
> > set(LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)<BR>
> ><BR>
> > add_executable(example ${ZLIB_TEST_SRCS})<BR>
> > set(RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)<BR>
> ><BR>
> > add_dependencies(example z)<BR>
> ><BR>
> > target_link_libraries(example z)<BR>
> ><BR>
> > install(TARGETS z DESTINATION lib )<BR>
> > install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include)<BR>
> > install(TARGETS example DESTINATION bin)<BR>
> > install(FILES ${ZLIB_MAN_SRCS} DESTINATION share/man/man3)<BR>
> ><BR>
> > I have tried many variations of setting the location for the target<BR>
> > z to be created (and the executable “example”), both the new style<BR>
> > as shown above and the old style (LIBRARY_OUTPUT_PATH), using<BR>
> > variables as above and using absolute paths and nothing works.<BR>
> > libz.so is always dropped directly into my build directory.<BR>
> ><BR>
> > Interesting, if I hand edit the cache file and add the variable<BR>
> > CMAKE_LIBRARY_OUTPUT_DIRECTORY to change the library creation<BR>
> > location it works: why does my cmake configuration not respect the<BR>
> > above commands and write this into the cache file automatically?<BR>
> ><BR>
> > Thanks,<BR>
> ><BR>
> > --Randy<BR>
> ><BR>
> > +<BR>
> > ---------------------------------------------------------------------+<BR>
> > |Randy R. Lober Email:<BR>
> > <a href="rrlober@sandia.gov">rrlober@sandia.gov</a> |<BR>
> > |Sandia National Laboratories Systems Engineering, Integration &<BR>
> > Test|<BR>
> > |P.O. Box 5800, MS<BR>
> > 0835 |<BR>
> > |Albuquerque, NM 87185-0835 (505) 845-9353 FAX<BR>
> > 284-1242 |<BR>
> > +<BR>
> > ---------------------------------------------------------------------+<BR>
> > _______________________________________________<BR>
> > Powered by www.kitware.com<BR>
> ><BR>
> > Visit other Kitware open-source projects at<BR>
> <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
> ><BR>
> > Please keep messages on-topic and check the CMake FAQ at:<BR>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><BR>
> ><BR>
> > Follow this link to subscribe/unsubscribe:<BR>
> > <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><BR>
><BR>
> _______________________________________________<BR>
> Powered by www.kitware.com<BR>
><BR>
> Visit other Kitware open-source projects at<BR>
> <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
><BR>
> Please keep messages on-topic and check the CMake FAQ at:<BR>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><BR>
><BR>
> Follow this link to subscribe/unsubscribe:<BR>
> <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><BR>
><BR>
><BR>
><BR>
> Regards,<BR>
><BR>
> --Randy<BR>
><BR>
> +---------------------------------------------------------------------+<BR>
> |Randy R. Lober Email: <a href="rrlober@sandia.gov">rrlober@sandia.gov</a> |<BR>
> |Sandia National Laboratories Systems Engineering, Integration & Test|<BR>
> |P.O. Box 5800, MS 0835 |<BR>
> |Albuquerque, NM 87185-0835 (505) 845-9353 FAX 284-1242 |<BR>
> +---------------------------------------------------------------------+<BR>
> ------------------------------------------------------------------------<BR>
><BR>
> _______________________________________________<BR>
> Powered by www.kitware.com<BR>
><BR>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
><BR>
> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><BR>
><BR>
> Follow this link to subscribe/unsubscribe:<BR>
> <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><BR>
<BR>
<BR>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Courier, Courier New"><SPAN STYLE='font-size:12pt'><BR>
Regards,<BR>
<BR>
--Randy<BR>
<BR>
+---------------------------------------------------------------------+<BR>
|Randy R. Lober Email: <a href="rrlober@sandia.gov">rrlober@sandia.gov</a> |<BR>
|Sandia National Laboratories Systems Engineering, Integration & Test| <BR>
|P.O. Box 5800, MS 0835 |<BR>
|Albuquerque, NM 87185-0835 (505) 845-9353 FAX 284-1242 |<BR>
+---------------------------------------------------------------------+<BR>
</SPAN></FONT>
</BODY>
</HTML>