<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi,<br>I'm new to cmake. Here is the version i'm using on a linux box. <br><br>cmake version 2.6-patch 3<br><br>In my main directory i've the fllowing in my cmakelists.txt file.<br><br>assume my main directory to be /home/srini<br><br>SET (XDR_FILES_HOME /home/thirdparty/xdr ) <br>SET (XDR_FILES <br> ${XDR_FILES_HOME}/xdrPrt.h <br> ${XDR_FILES_HOME}/xdrPrtBuf.c<br> ${XDR_FILES_HOME}/xdrPrt.c <br> )<br><br><br>add_subdirectory (lib0 ) <br>add_subdirectory (lib1) <br><br><br>Notice that the xdr files are not in my project heirarchy. <br>The source files in both lib0 and lib1 depend on xdrPrt.h file generated at run time. <br><br><br><br>In lib0/cmakelists.txt file i've <br><br>
ADD_CUSTOM_COMMAND(<br>
OUTPUT ${XDR_FILES}<br>
COMMAND my_xdr_gen.exe<br>
WORKING_DIRECTORY ${XDR_FILES_HOME}<br>
)<br><br>ADD_CUSTOM_TARGET(lib0_xdr ALL DEPENDS ${XDR_FILES} )<br>add_library (LIB0_LIB SHARED ${XDR_FILES} lib0_src.c ) <br><br><br>and in lib1/cmakelists.txt file, i almost repeat the same.<br>ADD_CUSTOM_COMMAND(<br>
OUTPUT ${XDR_FILES}<br>
COMMAND my_xdr_gen.exe<br>
WORKING_DIRECTORY ${XDR_FILES_HOME}<br>
)<br>
<br>
ADD_CUSTOM_TARGET(lib1_xdr ALL DEPENDS ${XDR_FILES} )<br>
add_library (LIB1_LIB SHARED ${XDR_FILES} lib1_src.c ) <br><br><br>The
above works for me (i can't seem to move the common code to main
cmakelists.txt file) when i do gmake in the build dir. In
my_xdr_gen.exe i added print statement to make sure it was called.
However when i do gmake -j4 i see 2 print statements from it. As if
both lib0 and lib1 called custom command at the same time. <br><br>Here are my questions, since i'm newbie and i'm sure what i'm doing is not correct.<br><br>How can i not duplicate code in lib0/cmakelists.txt and lib1/cmakelists.txt <br>I want to call my custom command just once and i want the lib0 and lib1 comilation to wait for the generation of my XDR_FILES. <br>And i should be able to do parallel build also.<br><br>Many thanks,<br>Srini<br>
<br /><hr />Windows Live™: Keep your life in sync. <a href='http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009' target='_new'>Check it out.</a></body>
</html>