[CMake] Disable linker / only build object files
Greg Peele
gpeele at ara.com
Thu Apr 30 10:51:22 EDT 2009
Tyler,
I know this isn't exactly what you asked, but have you considered
building each directory into a separate static library that is then
linked into your final library target? My understanding is that a
static library is essentially just an archive of object files.
-
Gregory Peele, Jr.
Applied Research Associates, Inc.
(407) 384-2721
gpeele at ara.com
On Wed, Apr 29, 2009 at 7:29 PM, Tyler Roscoe <tyler at cryptio.net> wrote:
I have a fairly complex library with a bunch of small pieces
scattered
throughout subdirectories.
Each subdirectory has its own CMakeLists.txt. This is nice
because the
list of .cpp files for each subdirectory is right there in the
subdirectory, and because these subdirectories behave just like
all the
other subdirectories in the system (you can go to them and build
them
and get something useful dropped into a results directory).
What I would like is for each subdirectory to compile its .cpp
files
into object files and then stop. There is no need for each
subdir to
generate a library because the object files will later be
collected into
a single higher-level library.
Is there a way to tell CMake to only compile a list of source
files and
not to link them? I tried setting CMAKE_CXX_LINK_EXECUTABLE,
CMAKE_LINKER, and LINKER_LANGUAGE to nothing but the generated
Makefiles
still happily call g++.
Should I give up on this approach and just list all my .cpp
files in the
CMakeLists for the higher-level. Maybe I could include() stubs
from the
subdirectories into my higher-level CMakeLists?
A related problem: how can I get the path to the object files
that are
created in my binary directory? We are currently using this, but
it's
kinda ugly and probably quite fragile:
if (WIN32)
set (TEST_OBJ_LOC
${${local_project_name}_BINARY_DIR}/${local_project_name}.dir/debug)
set (OBJ_EXTENSION ${CMAKE_CXX_OUTPUT_EXTENSION})
else ()
string(REPLACE "/_build/.." "/" ABS_OBJ_LOC
${${local_project_name}_SRC})
set (TEST_OBJ_LOC
${${local_project_name}_BINARY_DIR}/CMakeFiles/${local_project_name}.dir${ABS_OBJ_LOC})
set (OBJ_EXTENSION .cpp${CMAKE_CXX_OUTPUT_EXTENSION})
endif ()
thanks,
tyler
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list