I want to build the static library on a bin
subdir, but cmake seems not not doing what I want.
Here is the Cmake file I wrote.
cmake_minimum_required(VERSION 3.3)
project(FancyLogger)
set(SOURCE_FILES FancyLogger.cpp)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_library(FancyLogger STATIC ${SOURCE_FILES})
I made a build
subdir, and ran cmake ..
and make
in this sub directory, hoping that the output static library will be generated on the bin library.
But the output remains in the build
directory, Why?
Here is my file tree
===== |
| FancyLogger.cpp
| CMakeLists.txt
| /build
| /bin
For static libraries you have to set the CMAKE_ARCHIVE_OUTPUT_DIRECTORY
, not the CMAKE_LIBRARY_OUTPUT_DIRECTORY
.
So you will have:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
See how do I make cmake output into a 'bin' dir?
By the way, it's probably not a good idea to create subfolders within the source directory, especially in an automated way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With