Avoid macro when it can easily be done with a local variable
Only build the static library when BUILD_LIBRARIES_ONLY is defined