Search code examples
cmakestatic-libraries

is CMake ignoring CMAKE_LIBRARY_OUTPUT_DIRECTORY?


I just read this answer, suggesting the use of CMAKE_LIBRARY_OUTPUT_DIRECTORY for setting the directory in which library targets are created. Well, this doesn't seem to work for me:

# etc. etc.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib/")

cuda_add_library(
    mykernels
    src/kernel_wrappers/kernel1.cu
    src/kernel_wrappers/kernel2.cu)

When I make, the library libmyktkernels.a is created in the main project folder (where my CMakeFiles.txt is located), not in the lib/ subdirectory. Why is that?


Solution

  • Use CMAKE_ARCHIVE_OUTPUT_DIRECTORY for the static libraries.

    CMAKE_LIBRARY_OUTPUT_DIRECTORY applies only to dynamic libraries.