[CMake] generating code from compiled program
James Bigler
bigler at cs.utah.edu
Wed Sep 26 13:10:18 EDT 2007
On Sep 26, 2007, at 10:11 AM, Juan Sanchez wrote:
> Hello James,
>
> I'm curious why your target name is ExtractSymbolsFromXML, but your
> dependency is ${ExtractSymbolsFromXML_exe}.
>
> Shouldn't your dependency be the name of the target?
I tried both, and neither work.
> In addition, if you add a custom command, don't you have to have use
> add_custom_target as well.
>
> For example:
> ADD_CUSTOM_COMMAND(
> OUTPUT main.pdf
> DEPENDS main.ps
> COMMAND ps2pdf
> ARGS main.ps
> )
>
> ADD_CUSTOM_TARGET( Docs ALL
> DEPENDS main.pdf
> )
I thought that by having the generated source file be a dependency on
a library it would pull it in:
ADD_CUSTOM_COMMAND(
OUTPUT mysource.cc
...
)
ADD_LIBRARY(mylib mysource.cc)
I'll try and play around with ADD_CUSTOM_TARGET, but I hate how it
always seems to run (though I may have been using it wrong).
James
>
> James Bigler wrote:
>> Has anyone any examples of building a compiler (of sorts) and
>> using that
>> compiler to generate code then integrated into another CMake target?
>>
>> Thanks,
>> James
>>
>> James Bigler wrote:
>>> I have a program built within CMake that generates some code. I
>>> need
>>> this generated code to compile some other libraries. The problem
>>> I'm
>>> having is setting the dependency of the generated source file to its
>>> compiler. This is what I have currently:
>>>
>>> # This is the helper compiler
>>> ADD_EXECUTABLE(ExtractSymbolsFromXML ExtractSymbolsFromXML.cc)
>>> TARGET_LINK_LIBRARIES(ExtractSymbolsFromXML Dataflow_Network)
>>>
>>> # Get the full path to the ExtractSymbolsFromXML executable
>>> GET_TARGET_PROPERTY(ExtractSymbolsFromXML_exe
>>> ExtractSymbolsFromXML
>>> ${CMAKE_BUILD_TYPE}_LOCATION)
>>> # Get the path to the executable, so that I can stuff the
>>> generated
>>> file in the same place
>>> GET_FILENAME_COMPONENT(binary_path ${ExtractSymbolsFromXML_exe}
>>> PATH)
>>> SET(Loader_cc "${binary_path}/Loader.cc")
>>> SET_SOURCE_FILES_PROPERTIES(
>>> ${Loader_cc}
>>> PROPERTIES GENERATED TRUE
>>> )
>>> ADD_CUSTOM_COMMAND(
>>> OUTPUT ${Loader_cc}
>>> COMMAND ${ExtractSymbolsFromXML_exe} -o ${Loader_cc}
>>> # This is where I get hung up.
>>> MAIN_DEPENDENCY ${ExtractSymbolsFromXML_exe}
>>> COMMENT "Generating static loader file: ${Loader_cc}"
>>> )
>>>
>>> ADD_LIBRARY(StaticHelper Loader.h ${Loader_cc})
>>>
>>> ==================================================================
>>> I can't seem to get the dependency for ${Loader_cc} right. Any
>>> ideas of
>>> what I'm doing wrong?
>>>
>>> Thanks,
>>> James
More information about the CMake
mailing list