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