Hi List, I have written a macro in order to use it as a new command in cmake. This macro looks like this;
MACRO(C2ADA _file _option) IF(C2ADA_PARSER) SET(INC_DIRS -I<PATH_ONE>;-I<PATH_TWO>) GET_FILENAME_COMPONENT(_name ${_file} NAME) GET_FILENAME_COMPONENT(_basename ${_file} NAME_WE) SET(ADSFILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.ads) SET(ADBFILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.adb) SET_SOURCE_FILES_PROPERTIES(${ADSFILE} GENERATED) SET_SOURCE_FILES_PROPERTIES(${ADBFILE} GENERATED) IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${_name}) CONFIGURE_FILE(${_file} ${CMAKE_CURRENT_BINARY_DIR}/${_name} COPYONLY) ENDIF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${_name}) ADD_CUSTOM_COMMAND(OUTPUT ${ADSFILE} ${ADBFILE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_name} COMMAND ${C2ADA_PARSER} -O. -DC2ADA -fun -rrc -C -D_LITTLE_ENDIAN_ -DOS_SYSV -noref -erc -mwarn ${INC_DIRS} ${_name} COMMENT "option = ${_option}; file = ${_file}") #IF(${_option} MATCHES "ADS") IF(${_option} STREQUAL "ADS") IF(WIN32) ADD_CUSTOM_TARGET(DELETE_${_basename}_ADB ALL DEPENDS ${ADBFILE} COMMAND del ${ADBFILE}) ELSE(WIN32) ADD_CUSTOM_TARGET(DELETE_${_basename}_ADB ALL DEPENDS ${ADBFILE} COMMAND rm -f ${ADBFILE} COMMENT "delete now ${ADBFILE}") ENDIF(WIN32) ENDIF(${_option} STREQUAL "ADS") #ENDIF(${_option} MATCHES "ADS") ENDIF(C2ADA_PARSER) ENDMACRO(C2ADA) So the idea of this macro is to use a third party parser called c2ada. This uses a .h file and converts it to ada, but it creates both the specfiles .ads (same as .h files) and the body files .adb (same as .c or .cpp). Sometimes these bodies are empty, so you have to delete them from the build tree. If you don't do that the compile will fail. Okay, now in my cmakelists I call the marco with C2ADA(${CMAKE_CURRENT_SOURCE_DIR}/foo.h ADS) I use this macro often in my build process. But sometimes it fails! As a example run, I get this problem: [ 0%] Built target framework [ 0%] option = ADS; file = foo.h 'import site' failed; use -v for traceback Info: Generating ./foo.ads ./foo.adb [ 0%] delete now foo.adb [ 0%] Built target DELETE_foo_ADB [ 1%] Built target foo [ 1%] option = ADS; file = bar.h 'import site' failed; use -v for traceback Info: Generating ./bar.ads ./bar.adb [ 1%] delete now bar.adb [ 1%] Built target DELETE_bar_ADB [ 1%] Built target bar Scanning dependencies of target bar [ 2%] Building Ada object CMakeFiles/bar.dir/baar.o Linking Ada shared library ../../lib/libbar.so [ 2%] Built target bar [ 2%] option = ADS; file = test.h 'import site' failed; use -v for traceback Info: Generating ./test.ads ./test.adb Scanning dependencies of target test test.ads:5:09: package "test" does not allow a body test.ads:5:09: remove incorrect body in file "test.adb" make[2]: *** [CMakeFiles/test.dir/test.o] Error 1 make[1]: *** [CMakeFiles/test.dir/all] Error 2 make: *** [all] Error 2 Why is the macro called correct by calling it with foo and bar, but will fail when I call it for test? There is no difference in all three cmakelists.txt files, expect that when I call the macro with test.h I use the macro once again! Common question: Is it possible that when I use my own macro twice in a cmakelists.txt, then it will fail? Thanks for your help Greetings Alexander ---------------------------------------------------------------- Please note: This e-mail may contain confidential information intended solely for the addressee. If you have received this e-mail in error, please do not disclose it to anyone, notify the sender promptly, and delete the message from your system. Thank you.
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake