[CMake] Trouble setting LIBRARY_OUTPUT_DIRECTORY

Lober, Randy rrlober at sandia.gov
Thu Jun 4 15:13:53 EDT 2009


Hello, I am a new user of cmake and I am running version 2.6-patch 4 on Linux.

I am setting up a simple project to learn cmake and most everything has worked just as expected except for my attempts to define where an output library target is to be created. Here is part of the CMakeLists.txt

project(ZLIB C)
SET(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)
SET(CMAKE_BUILD_TYPE Release)

set(CMAKE_C_COMPILER gcc)
add_definitions(-O3)
set(BUILD_SHARED_LIBS ON)
cmake_minimum_required(VERSION 2.6)

set(ZLIB_PUBLIC_HDRS
    zconf.h
    zlib.h
)

set(ZLIB_PRIVATE_HDRS
    crc32.h
    deflate.h
    inffast.h
    inffixed.h
    inflate.h
    inftrees.h
    trees.h
    zutil.h
)

set(ZLIB_SRCS
    adler32.c
    compress.c
    crc32.c
    deflate.c
    inflate.c
    infback.c
    inftrees.c
    inffast.c
    gzio.c
    trees.c
    uncompr.c
    zutil.c
)

set(ZLIB_TEST_SRCS
    example.c
)

set(ZLIB_MAN_SRCS
    zlib.3
)

add_library(z ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(z PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set(LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

add_executable(example ${ZLIB_TEST_SRCS})
set(RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

add_dependencies(example z)

target_link_libraries(example z)

install(TARGETS z DESTINATION lib )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include)
install(TARGETS example DESTINATION bin)
install(FILES ${ZLIB_MAN_SRCS} DESTINATION share/man/man3)

I have tried many variations of setting the location for the target z to be created (and the executable "example"), both the new style as shown above and the old style (LIBRARY_OUTPUT_PATH), using variables as above and using absolute paths and nothing works. libz.so is always dropped directly into my build directory.

Interesting, if I hand edit the cache file and add the variable CMAKE_LIBRARY_OUTPUT_DIRECTORY to change the library creation location it works: why does my cmake configuration not respect the above commands and write this into the cache file automatically?

Thanks,

--Randy

+---------------------------------------------------------------------+
|Randy R. Lober                Email: rrlober at sandia.gov              |
|Sandia National Laboratories  Systems Engineering, Integration & Test|
|P.O. Box 5800, MS 0835                                               |
|Albuquerque, NM 87185-0835    (505) 845-9353 FAX 284-1242            |
+---------------------------------------------------------------------+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090604/8e9081db/attachment.htm>


More information about the CMake mailing list