I'm adding a component built with CMake into a larger project which currently uses makefiles. There is a single "configuration" makefile, which contains some logic which, among others, sets up target directories in the form of make variables. The config makefiles is included in the current build by setting the MAKEFILES env var, and the actual build makefiles reference these varaibles when building and linking to artifacts in these directories, so e.g.:
# in config.mk
...
MY_TARGET_LIB_DIR=...
# in a build makefile
TGT_LIB=$(MY_TARGET_LIB_DIR)/libsomething.so
# in another build makefile
LDFLAGS=-L$(MY_TARGET_LIB_DIR)
What I would like to do is make use of this in the makefiles generated by CMake, i.e. have CMake generate me a makefile that builds a library (static in this case) in the directory referenced by the variable MY_TARGET_LIB_DIR and another that links to a library in that directory.
I have tried to do something like
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $(MY_TARGET_LIB_DIR))
but no luck - this only causes the generated makefile to output into a subdirectory literally called $(MY_TARGET_LIB_DIR). Is there a solution for this?