On 11/07/2010 03:37 PM, luxInteg wrote: > On Sunday 07 November 2010 11:34:47 Richard Wackerbarth wrote: >> First let me suggest that you word your request in a more complete manner. >> What "does not work"? > cant get an executable generated because the 'COMMAND' syntax is incorrect" > so could you suggest the correct syntax please? > >> What were you expecting and what did you get? >> It is difficult, if not impossible, for us to guess. >> >> I suspect that the problem is related to the ">" (specifying the output >> file in Unix). Are you on a Un*x platform? > yes linux >> Remember that CMake uses a >> different syntax because it assumes that the platform may not be >> Unix-based. >> >> I also have no idea just what "BouncyBall" is supposed to do > generate BouncyBall.out > >> They look very much like a call to the >> Unix "diff" command to verify that the output matches some previous >> version (stored in BouncyBall.out) > correct > > which requires the generation an executable file first. > >> >> Provide additional details. Then we may be able to be more helpful. > > DETAILS: as requested: > > add_executable(BouncyBall BouncyBall.c) > find_library(OLD_LIBRARY OLD) > target_link_libraries(BouncyBall ${OLD_LIBRARY}) > COMMAND(./BouncyBall > my_BouncyBall.out > - diff BouncyBall.out my_BouncyBall.out) > > > what is needed:- > > > a) syntax for generating BouncyBall executable with oppropriate linking to > ${OLD_LIBRARY}
The ADD_EXECUTABLE(), FIND_LIBRARY() and TARGET_LINK_LIBRARIES() commands look good, provided the library OLD is actually found. > b) syntax within cmake for executing BouncyBall executable and diffing > output to 'existing' outputfile > > i.e this bit:- > ( > COMMAND(./BouncyBall > my_BouncyBall.out > - diff BouncyBall.out my_BouncyBall.out ) > ) Here, you might use a test driven by a simple CMake script: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(BOUNCYBALL C) ENABLE_TESTING() FILE(WRITE ${CMAKE_BINARY_DIR}/bouncyball.out "bouncyball\n") FILE(WRITE ${CMAKE_BINARY_DIR}/bouncyball.cmake " EXECUTE_PROCESS( COMMAND \${EXEC} COMMAND diff - \${FILE} RESULT_VARIABLE RESULT ) IF(NOT RESULT EQUAL 0) MESSAGE(FATAL_ERROR) ENDIF() ") FILE(WRITE ${CMAKE_BINARY_DIR}/bouncyball.c " #include <stdio.h> int main(void){ printf(\"bouncyball\\n\"); return 0; } ") ADD_EXECUTABLE(bouncyball bouncyball.c) ADD_TEST(NAME bouncyball COMMAND ${CMAKE_COMMAND} -DEXEC=$<TARGET_FILE:bouncyball> -DFILE=${CMAKE_BINARY_DIR}/bouncyball.out -P ${CMAKE_BINARY_DIR}/bouncyball.cmake ) After configuration, if you edit bouncyball.out you can see the test pass or fail, depending on its contents; use "make test" or "ctest". Regards, Michael > I hope I did provide the example unix Makefile that is being translated. > > thanks > and > regards > >> On Nov 7, 2010, at 6:08 AM, luxInteg wrote: >>> Greetings, >>> >>> I am learning cmake. and I have taken the following from an old >>> Makefile:- INC = ../include/BouncyBall.h >>> >>> BouncyBall: BouncyBall.c library $(INC) >>> >>> ${CC} ${CFLAGS} -o BouncyBall BouncyBall.c ../lib/libOLD.a >>> ./BouncyBall > my_BouncyBall.out - diff BouncyBall.out >>> my_BouncyBall.out >>> >>> and 'translated' for cmake as the following:- >>> ----------------------- >>> add_executable(BouncyBall BouncyBall.c) >>> find_library(OLD_LIBRARY OLD) >>> target_link_libraries(BouncyBall ${OLD_LIBRARY}) >>> COMMAND(./BouncyBall > my_BouncyBall.out >>> >>> - diff BouncyBall.out my_BouncyBall.out) >>> >>> install(TARGETS >>> BouncyBall >>> BouncyBall.out >>> my_BouncyBall.out >>> DESTINATION bin) >>> ----------------------- >>> but it does not work >>> >>> advice would be appreciated >>> >>> sincerely >>> luxInteg _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake