[SPAM?][bcc][SPAM?][faked-from] [CMake] Installing results of ADD_CUSTOM_COMMAND

Dekeyser, Kris Kris.Dekeyser at lms.be
Mon Nov 8 03:30:59 EST 2004


FWIW: here's our code ...

-------- snippet ----------------
# get all idlfiles
FILE(GLOB IdlFiles "${IDL_SRC_DIR}/*.idl")

# iterate over all .idl files found
FOREACH(IdlFile ${IdlFiles})

  # convert to filename without extension
  GET_FILENAME_COMPONENT(IdlName ${IdlFile} NAME_WE)
  
  # add path and extension for generated files
  SET(ClientSource "${IDL_TGT_DIR}/${IdlName}C.cpp")
  SET(ClientHeader "${IDL_TGT_DIR}/${IdlName}C.h")
  SET(ClientInline "${IDL_TGT_DIR}/${IdlName}C.i")
  SET(ServantSource "${IDL_TGT_DIR}/${IdlName}S.cpp")
  SET(ServantHeader "${IDL_TGT_DIR}/${IdlName}S.h")
  SET(ServantInline "${IDL_TGT_DIR}/${IdlName}S.i")

  # add generated files to the source list  
  SET(MySrc "${MySrc}" "${ServantSource}" "${ClientSource}")
  
  # add generated files to the header list
  SET(MyHdr "${MyHdr}" "${ServantHeader}" "${ClientHeader}")
  IF(WIN32)
    SET(MyHdr "${MyHdr}" "${ServantInline}" "${ClienInline}")
  ENDIF(WIN32)
  
  # custom command to generate the client source code
  ADD_CUSTOM_COMMAND(
    OUTPUT ${ClientSource}
    COMMAND ${EDM_IDL_COMPILER}
    ARGS -I${IDL_SRC_DIR} -I${IDL_TGT_DIR} -o ${IDL_TGT_DIR} -Sc ${IdlFile}
    DEPENDS ${IdlFile}
    COMMENT "${IdlName} IDL Stub:")

  # custom command to generate the client header
  ADD_CUSTOM_COMMAND(
    OUTPUT ${ClientHeader}
    COMMAND ${EDM_IDL_COMPILER}
    ARGS -I${IDL_SRC_DIR} -I${IDL_TGT_DIR} -o ${IDL_TGT_DIR} -Sc ${IdlFile}
    DEPENDS ${IdlFile}
    COMMENT "${IdlName} IDL Stub:")

  # custom command to generate the servant source code
  ADD_CUSTOM_COMMAND(
    OUTPUT ${ServantSource}
    COMMAND ${EDM_IDL_COMPILER}
    ARGS -I${IDL_SRC_DIR} -I${IDL_TGT_DIR} -o ${IDL_TGT_DIR} -Sc ${IdlFile}
    DEPENDS ${IdlFile}
    COMMENT "${IdlName} IDL Servant:")
    
  # custom command to generate the servant source header
  ADD_CUSTOM_COMMAND(
    OUTPUT ${ServantHeader}
    COMMAND ${EDM_IDL_COMPILER}
    ARGS -I${IDL_SRC_DIR} -I${IDL_TGT_DIR} -o ${IDL_TGT_DIR} -Sc ${IdlFile}
    DEPENDS ${IdlFile}
    COMMENT "${IdlName} IDL Servant:")

ENDFOREACH(IdlFile)

# Mark source and header files as being generated
SET_SOURCE_FILES_PROPERTIES(${MySrc} PROPERTIES GENERATED true)
SET_SOURCE_FILES_PROPERTIES(${MyHdr} PROPERTIES GENERATED true)

# make clean should delete all generated files
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MySrc}
${MyHdr}")
------- end snippet ----------

... and somewhere else the header files are added to the install directory.
This seems to work for us ...

Regards, Kris

> -----Original Message-----
> From: Alex Brooks [mailto:a.brooks at acfr.usyd.edu.au]
> Sent: Sunday, November 07, 2004 15:27
> To: cmake at www.cmake.org
> Subject: [SPAM?][bcc][SPAM?][faked-from] [CMake] Installing results of
> ADD_CUSTOM_COMMAND
> 
> 
> Hi,
> 
> I have a bit of a problem using cmake for IDL files.
> 
> I used ADD_CUSTOM_COMMAND to generate .h/.cpp files from .idl files:
> 
> FOREACH ( SUFFIX ${IDL_SUFFIXES} )
>       STRING( REGEX REPLACE "\\.idl" ${SUFFIX} OUTPUT 
> "${IDL_SOURCE}" )
>       ADD_CUSTOM_COMMAND(
>         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}
>         COMMAND ${TAO_IDL}
>         ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_SOURCE} ${TAO_IDL_ARGS}
>         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_SOURCE}
>         )
> 	...
> 
> The .cpp files are then compiled into a library and marked for
> installation:
> 
> ADD_LIBRARY( ${LIB_NAME} ${IDL_CPP_FILES} ${HUMAN_SOURCE_LIST} )
> 
> I also want to install the .h files.
> 
> I tell cmake to install the header files with:
> 
> FOREACH ( FILE ${IDL_HEADER_FILES} )
>     INSTALL_FILES( /include/orca ${FILE} )
> ENDFOREACH ( FILE ${IDL_HEADER_FILES} )
> 
> The problem is that cmake can't find the IDL_HEADER_FILES 
> when it is run
> (because they're only generated from .idl later, when 'make' is run).
> 
> The only way I've found to make it work correctly is to do:
> 'cmake .; make; cmake .; make install'
> 
> The second 'cmake .' can see the generated header files and 
> creates the
> correct install rules.  There's gotta be a better way of doing this
> though -- can anyone offer any suggestions?
> 
> 
> Thanks,
> 
> Alex
> 
> _______________________________________________
> CMake mailing list
> CMake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 
+-+-+- Email Confidentiality Footer +-+-+- 
Privileged/Confidential Information may be contained in this message. If you
are not the addressee indicated in this message (or responsible for delivery
of the message to such person), you may not print, retain, copy nor
disseminate this message or any part of it to anyone and you should notify
the sender by reply email and destroy this message. Neglecting this clause
could be a breach of confidence. Please advise immediately if you or your
employer does not consent to Internet email for messages of this kind.
Opinions, conclusions and other information in this message that are not
related to the official business of my firm shall be understood as neither
given nor endorsed by it.



More information about the CMake mailing list