[CMake] faking convenience libraries

Bill Hoffman bill.hoffman at kitware.com
Mon Feb 12 09:54:11 EST 2007


Brandon J. Van Every wrote:
>
> Well I figured out the paths to the .OBJ files.  Note they're coming 
> out as .OBJ files on Windows, both for MinGW and for MSVC.  When I 
> dump my .OBJ file absolute pathnames into ADD_LIBRARY, CMakeSetup 
> complains that "the source file doesn't exist," because of course they 
> haven't been built yet.  I tried 
> SET_SOURCE_FILES_PROPERTIES(${theobjs}PROPERTIES GENERATED true), but 
> it doesn't suppress the error.  I don't think that function thinks 
> they're source files.  Says it tried just about every extension, 
> except the .obj and .o extensions I might actually be interested in.
Not sure, must be something wrong in your script.  The following works 
with nmake and gmake with cl, and works  on linux.


project(foo)
add_library(foo foo.c)
set(obj_files 
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/foo.dir/foo${CMAKE_C_OUTPUT_EXTENSION} 
)
set_source_files_properties(
  ${obj_files} PROPERTIES GENERATED true)
add_library(bar ${obj_files})
set_target_properties(bar PROPERTIES LINKER_LANGUAGE C)
add_dependencies(bar foo)

-Bill




More information about the CMake mailing list