[CMake] I can use add_custom_command in cmake
Michael Wild
themiwi at gmail.com
Wed May 5 08:06:24 EDT 2010
On 5. May, 2010, at 10:20 , suds wrote:
> Hi there:
> I am new to cmake and I am using Kdevelop, actually , I am new to linux.
> In my project, there are some ice slice files which must be custom parsed
> and generate some cpp/h files.
> So I use the command below to tell cmake to call slice2cpp to generate the
> cpp/h files.
> But every times I build the project, no cpp/h files were generate, and I
> event can not find why.
> The only error message I can see is to tell me that the target source file
> was not found ( because this file was not generated )
> I can't figure out wht happend, and I even don't know to to trace the
> poblem
> Any help on this is appreciated
>
>
> add_custom_command( OUTPUT ../TianShanIce.cpp
> COMMAND /opt/Ice-3.3/bin/slice2cpp -I /opt/Ice-3.3/slice/
> -I../ --output-dir ../ ../TianShanIce.ICE
> DEPENDS ../TianShanIce.ICE )
> add_library(TianShanIce SHARED ../TianShanIce.cpp)
>
>
>
> Suds
Always use full paths in custom commands (and use find_program)
find_program(SLICE2CPP_EXECUTABLE slice2cpp PATHS /opt/Ice-3.3/bin)
set(out_dir "${CMAKE_CURRENT_BINARY_DIR}/.."
set(out_file "${out_dir}/TianShanIce.cpp")
add_custom_command(OUTPUT "${out_file}"
COMMAND "${SLICE2CPP_EXECUTABLE}"
-I /opt/Ice-3.3/slice/
-I "${out_dir}"
--output-dir "${out_dir}"
"${CMAKE_CURRENT_SOURCE_DIR}/../TianShanIce.ICE"
)
add_library(TianShanIce SHARED "${out_file}")
Hope this helps
Michael
More information about the CMake
mailing list