[CMake] Is there a way to omit relative path from the name of the comilation output file (<OBJECT>)?

Alexander Tarnopolsky Alexander.Tarnopolsky at PDGM.com
Mon Nov 30 10:53:03 EST 2009


Dear CMake users list,

In our build system we have to compile source files that reside out of
source/build tree. In some cases there are several hundreds of such
"external" sources in a project.

Consider simplified CMakeLists.txt:
===================================
Project (system)

set(SOURCES
/users/gdadmin/PG41/project/src/library/system/AttachDebugger.cc
/users/gdadmin/PG41/project/src/library/system/CPUInfo.cc
DSOInfo.cc
DSOManip.cc
HelpControl.cc
LocateExe.cc
MksTemp.cc
PathManip.cc
PluginLoader.cc
ProcessAffinity.cc
RTTI.cc
Setenv.cc
ShellUtils.cc
Sleep.cc
SysTime.cc
TraceStack.cc
UserInfo.cc
VTControl.cc
Asm/CPUID_c.cc
)

add_library (system SHARED ${SOURCES})
=======================================

The compilation of the first source produces the following output file:
"CMakeFiles/system.dir/users/gdadmin/PG41/project/src/library/system/Att
achDebugger.cc.o"

Imagine a link command where several hundreds of object files are listed
with this relative path...

Thus we are looking for a way to shorten the path. Ideally - we'd like
to generate compiled objects under the same flat-directory regardless of
the source file location.

I understand that ""CMakeFiles/system.dir" part of the relative path to
object files cannot be changed - I hope we can handle this.

But is there a way to change
"/users/gdadmin/PG41/project/src/library/system" part?

I experimented with CMAKE_CXX_COMPILE_OBJECT rule-variable and tried to
replace the <OBJECT> with something else, but apparently the
rule-command is invoked always when <OBJECT> file is missing, probably
the dependency between <OBJECT> and <SOURCE> drives the rule-command.

Of course there is a possibility to compile objects by a custom command
and to manage object's dependencies by a script etc.. However we don't
like to give up on cmake built-in rules for compilation and dependency
tracking.

Thanks in advance for your help,
Kind Regards,
Alex Tarnopolsky
---------------------------------------------------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.




More information about the CMake mailing list