Page 1 of 1

Output directory of libraries in CMake

Posted: Wed Jan 05, 2022 3:09 pm
by amwink

I am using the CMake build plugin for a number of projects that share bin/, lib/, etc. directories.

in each library project I put the General settings:
Output File to lib$(ProjectName).so
Executable to run / execute to $(WorkspacePath)/cmake-build-$(WorkspaceConfiguration)/lib/$(OutputFile)
Working Directory to $(WorkspacePath)/cmake-build-$(WorkspaceConfiguration)/lib

and Global settings
Library Path to .;..;$(WorkspacePath)/cmake-build-$(WorkspaceConfiguration)/lib

So I expected to have each library put in the lib/ directory, and have other libraries link against the files in there as well.
However, each time I run CMake, it overwrites the output directory for the library to $(WorkspacePath)/cmake-build-$(WorkspaceConfiguration)/lib: this is what is in the file CMakeLists.txt:

Code: Select all

set(CL_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/${CL_WORKSPACE_DIRECTORY}/cmake-build-${CONFIGURATION_NAME}/output)

The lib directory occurs once in there, but only as the library path for the linker.
In other words, every time I run CMake, I need to manually change CMakeLists.txt before building.

Is there a setting to do this automatically, or perhaps the possibility to change the template CMakeLists.txt?
Many thanks!