[CMake] Get all required shared libs from a target
Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael ___ 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
Re: [CMake] Compiled file cannot be executed
You must be doing something wrong. Have a look at this example: generate.cpp: --8-- #include iostream #include fstream int main(int argc, char* argv[]) { if( argc 2 ) { std::cerr Usage: argv[0] outputFile\n; } std::ofstream str(argv[1]); str #include iostream\nint main() {\n; std::cout \Hello World!\\n\;\n; return 0;\n}\n; str.close(); return 0; } --8-- CMakeLists.txt: --8-- cmake_minimum_required(VERSION 2.6) project(test CXX) add_executable(generate generate.cpp) set(HELLO_SRCS ${CMAKE_CURRENT_BINARY_DIR}/hello.cpp) add_custom_command( OUTPUT ${HELLO_SRCS} COMMAND generate ${HELLO_SRCS} DEPENDS generate COMMENT Generating ${HELLO_SRCS} VERBATIM ) add_executable(hello ${HELLO_SRCS}) --8-- The executable generate takes the name of an output file as its argument and then generates the code for a simple hello world program. This output is then used to generate the program hello. I hope this helps Michael On 28. Aug, 2009, at 6:05, Swaroop Ramachandra wrote: I did. The same problem persists. Is there a work-around - maybe some other command that I can use? 2009/8/27 Michael Wild them...@gmail.com David is probably right, that you need to add the dependency on generate. However, only add it's target name to both the COMMAND and DEPENDS arguments, CMake should figure this out. Michael On 27. Aug, 2009, at 21:31, Swaroop Ramachandra wrote: Still no luck :( . I really wonder why it is trying to execute my generate binary even before it is built. Here are my updated lines of code. #Trying to compile and run generate.c. generate.c creates a new file someoutput.txt and copies all data from someinput.txt to someoutput.txt add_executable(generate server/generate.c) add_custom_command( # I want to generate someoutput.txt OUTPUT ${CMAKE_BINARY_DIR}/server/someoutput.txt # using the generate program. cmake knows that generate refers to the above target COMMAND generate ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt # only run if sominput.txt changed DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt ${CMAKE_BINARY_DIR}/bin/generate${CMAKE_EXECUTABLE_SUFFIX} # tell to run in current binary dir WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin # some nice comment in the output COMMENT Generating ${CMAKE_BINARY_DIR}/someoutput.txt VERBATIM ) 2009/8/27 David Cole david.c...@kitware.com Use full path file names as DEPENDS arguments. Also: depend on the executable file too so that cmake knows not to try to run the custom command before the executable is built... i.e. : DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt ${CMAKE_BINARY_DIR}/bin/generate${CMAKE_EXECUTABLE_SUFFIX} HTH, David On Thu, Aug 27, 2009 at 2:41 PM, Swaroop Ramachandra swaroo...@gmail.com wrote: Hi Michael, Thanks for your reply. I still have the same problem. * * gmake-3.81[2]: bin/generate: Command not found lin: gmake-3.81[2]: *** [bin/generate] Error 127 lin: gmake-3.81[1]: *** [CMakeFiles/generate.dir/all] Error 2 Here's my code as is: #Trying to compile and run generate.c. generate.c creates a new file someoutput.txt and copies all data from someinput.txt to someoutput.txt add_executable(generate server/generate.c) add_custom_command( # I want to generate someoutput.txt OUTPUT ${CMAKE_BINARY_DIR}/server/someoutput.txt # using the generate program. cmake knows that generate refers to the above target COMMAND generate ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt # only run if sominput.txt changed DEPENDS server/someinput.txt # tell to run in current binary dir WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin # some nice comment in the output COMMENT Generating ${CMAKE_BINARY_DIR}/someoutput.txt VERBATIM ) Still the same issue. I guess it is trying to execute my generate even before it is compiled. Does CMake see that in the line COMMAND generate refers to the compiled one? Again, since generate is created in round one of make, the second run sees the generate and runs fine. Any help is greatly appreciated! Thanks for your time! Regards, Swaroop 2009/8/27 Michael Wild them...@gmail.com On 27. Aug, 2009, at 0:58, Swaroop Ramachandra wrote: Hi, I'm trying to do the following in my CMake file: 1. Generate a xyz.txt file 2. Compile a generate.c file to give out a generate binary in my bin directory. 3. Execute the generate binary (The binary just reads contents of xyz.txt and creates a copy of xyz.txtusing read() and write() functions in C) The problem: When I do a fresh build, 1 and 2 succeed. 3 fails with the following error *bin/generate: Command not found* However, if I *re-run the build immediately* after, since the generate binary is already created, all 3 successfully execute. Here's a snippet of what I have written. /* Code to generate xyz.txt -- Successfully generated each time--*/ -- - ADD_EXECUTABLE(generate
Re: [CMake] Get all required shared libs from a target
On 28. Aug, 2009, at 8:29, Müller Michael wrote: Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael Hi You don't need this (for the case you described). CMake remembers for you: add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) As you see in the last line, c is mentioned to link against b. CMake, however, remembers that b also links against a, and consequently also adds a to the list of libraries to link against. HTH Michael ___ 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
Re: [CMake] Get all required shared libs from a target
Hi Michael, Thanks for your repsonse but I need the required DLLs to copy them in a post-build step. So I need the information which libaries are required for executing something. E.g., in your example add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) I`d like to have something like GET_TARGET_PROPERTY(LIBS c IMPORTED_LINK_DEPENDENT_LIBRARIES) and then LIBS would contain C:\project\a.dll;C:\project\b.dll. I also tried it with IMPORTED_LINK_DEPENDENT_LIBRARIES but that gives me an empty variable. Hopefully, this made my problem clearer. Michael -Ursprüngliche Nachricht- Von: Michael Wild [mailto:them...@gmail.com] Gesendet: Freitag, 28. August 2009 09:30 An: Müller Michael Cc: cmake@cmake.org Betreff: Re: [CMake] Get all required shared libs from a target On 28. Aug, 2009, at 8:29, Müller Michael wrote: Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael Hi You don't need this (for the case you described). CMake remembers for you: add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) As you see in the last line, c is mentioned to link against b. CMake, however, remembers that b also links against a, and consequently also adds a to the list of libraries to link against. HTH Michael ___ 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
[CMake] FindThreads: the odd one out?
Hi all, Up till now I've been using the not officially supported and released FindPthreads.cmake macro to check for the presence of pthreads. However, the maintainer of that macro wrote (a comment in Mantis) that he would drop support for FindPthreads in favor of the more general and officially supported FindThreads.cmake macro. However, I have some difficulty understandig how to properly use FindThreads.cmake. Contrary to most FindXXX macros it does not set THREADS_INCLUDE_DIR and THREADS_LIBRARY. It does set some *_INIT variables, but I thought that *_INIT variables were only used by CMake itself to preset compiler and linker flags, and that these were not to be used outside. Could someone shed a light on this? Best regards, Marcel Loose. ___ 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
Re: [CMake] Get all required shared libs from a target
You could use CMAKE_RUNTIME_OUTPUT_DIRECTORY or the RUNTIME_OUTPUT_DIRECTORY target property to specify where CMake should put all the produced runtime stuff (on Windows, AFAIK this is *.exe and *.dll), so you don't have to copy them around manually. If the dll's are not built by you, you might want to have a look at the GetPrerequisites and InstallRequiredSystemLibraries modules. Michael On 28. Aug, 2009, at 10:12, Müller Michael wrote: Hi Michael, Thanks for your repsonse but I need the required DLLs to copy them in a post-build step. So I need the information which libaries are required for executing something. E.g., in your example add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) I`d like to have something like GET_TARGET_PROPERTY(LIBS c IMPORTED_LINK_DEPENDENT_LIBRARIES) and then LIBS would contain C:\project\a.dll;C:\project\b.dll. I also tried it with IMPORTED_LINK_DEPENDENT_LIBRARIES but that gives me an empty variable. Hopefully, this made my problem clearer. Michael -Ursprüngliche Nachricht- Von: Michael Wild [mailto:them...@gmail.com] Gesendet: Freitag, 28. August 2009 09:30 An: Müller Michael Cc: cmake@cmake.org Betreff: Re: [CMake] Get all required shared libs from a target On 28. Aug, 2009, at 8:29, Müller Michael wrote: Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael Hi You don't need this (for the case you described). CMake remembers for you: add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) As you see in the last line, c is mentioned to link against b. CMake, however, remembers that b also links against a, and consequently also adds a to the list of libraries to link against. HTH Michael ___ 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 ___ 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
Re: [CMake] installing a module
On Tue, Aug 25, 2009 at 3:35 PM, Michael Wild them...@gmail.com wrote: On 25. Aug, 2009, at 15:23, David Ojeda wrote: On Tue, Aug 25, 2009 at 12:47 PM, Andreas Pakulat ap...@gmx.de wrote: On 25.08.09 12:37:46, David Ojeda wrote: I have a shared library that I managed to compile and install using cmake. This is working great but now I want to use this library in another cmake-based development. Normally, as with any other shared library, I use a FindPackage to get the include and linker flags. However, since I am using my shared library, I wrote a cmake module. Once again this is working ok and I would like to include this module as a part of the files installed by the library. So you don't want that, you want it to be either part of cmake or part of all projects using that library. The reason is simple, if the library is not installed, its find-module won't be installed. Hence upon the cmake-run in the project using the lib you'll get a cryptic error message that library_DIR is not set properly. Thank you for your response Andreas, Actually I get a not so cryptic error, which says that it does not find the module: CMake Warning at CMakeLists.txt:12 (find_package): Could not find module Findmylib.cmake or a configuration file for package mylib. Adjust CMAKE_MODULE_PATH to find Findmylib.cmake or set mylib_DIR to the directory containing a CMake configuration file for mylib. The file will have one of the following names: mylibConfig.cmake mylib-config.cmake So, to my understanding, cmake will search the module at CMAKE_MODULE_PATH or at /usr/share/cmake-2.6/Modules/ Does it also search somewhere else such as: /usr/local/share/cmake-2.6/Modules ? I've tried this and apparently it doesn't search there... (maybe it searches somewhere else?) If cmake does not do this at all... would this be useful? I think so, personally... since usually it is common to install libraries/programs at /usr/local/... You want to read http://www.cmake.org/cmake/help/cmake2.6docs.html#command:find_package, especially where it starts to talk about config mode: CMake constructs a set of possible installation prefixes for the package. Under each prefix several directories are searched for a configuration file. The tables below show the directories searched. Each entry is meant for installation trees following Windows (W), UNIX (U), or Apple (A) conventions. prefix/ (W) prefix/(cmake|CMake)/ (W) prefix/name*/ (W) prefix/name*/(cmake|CMake)/ (W) prefix/(share|lib)/cmake/name*/ (U) prefix/(share|lib)/name*/ (U) prefix/(share|lib)/name*/(cmake|CMake)/ (U) On systems supporting OS X Frameworks and Application Bundles the following directories are searched for frameworks or bundles containing a configuration file: prefix/name.framework/Resources/ (A) prefix/name.framework/Resources/CMake/ (A) prefix/name.framework/Versions/*/Resources/ (A) prefix/name.framework/Versions/*/Resources/CMake/ (A) prefix/name.app/Contents/Resources/ (A) prefix/name.app/Contents/Resources/CMake/ (A) In all cases the name is treated as case-insensitive and corresponds to any of the names specified (package or names given by NAMES). If PATH_SUFFIXES is specified the suffixes are appended to each (W) or (U) directory entry one-by-one. Michael Thank you Michael, I did not know this. I found another interesting solution, just by filling the HINT section of the find_package David ___ 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
Re: [CMake] Compiled file cannot be executed
The extra thing that Michael put at the end is probably the key to everything here. He did an add_executable with the output of the custom command. You either need to have a library or executable or custom target use the output of your custom command so that it is properly chained with dependency rules through the cmake generated make files... Try adding an add_custom_target that depends on the output of your add_custom_command. (Unless you will be using the output in a library or executable -- then add it there instead...) HTH, David On Fri, Aug 28, 2009 at 3:26 AM, Michael Wild them...@gmail.com wrote: You must be doing something wrong. Have a look at this example: generate.cpp: --8-- #include iostream #include fstream int main(int argc, char* argv[]) { if( argc 2 ) { std::cerr Usage: argv[0] outputFile\n; } std::ofstream str(argv[1]); str #include iostream\nint main() {\n; std::cout \Hello World!\\n\;\n; return 0;\n}\n; str.close(); return 0; } --8-- CMakeLists.txt: --8-- cmake_minimum_required(VERSION 2.6) project(test CXX) add_executable(generate generate.cpp) set(HELLO_SRCS ${CMAKE_CURRENT_BINARY_DIR}/hello.cpp) add_custom_command( OUTPUT ${HELLO_SRCS} COMMAND generate ${HELLO_SRCS} DEPENDS generate COMMENT Generating ${HELLO_SRCS} VERBATIM ) add_executable(hello ${HELLO_SRCS}) --8-- The executable generate takes the name of an output file as its argument and then generates the code for a simple hello world program. This output is then used to generate the program hello. I hope this helps Michael On 28. Aug, 2009, at 6:05, Swaroop Ramachandra wrote: I did. The same problem persists. Is there a work-around - maybe some other command that I can use? 2009/8/27 Michael Wild them...@gmail.com David is probably right, that you need to add the dependency on generate. However, only add it's target name to both the COMMAND and DEPENDS arguments, CMake should figure this out. Michael On 27. Aug, 2009, at 21:31, Swaroop Ramachandra wrote: Still no luck :( . I really wonder why it is trying to execute my generate binary even before it is built. Here are my updated lines of code. #Trying to compile and run generate.c. generate.c creates a new file someoutput.txt and copies all data from someinput.txt to someoutput.txt add_executable(generate server/generate.c) add_custom_command( # I want to generate someoutput.txt OUTPUT ${CMAKE_BINARY_DIR}/server/someoutput.txt # using the generate program. cmake knows that generate refers to the above target COMMAND generate ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt # only run if sominput.txt changed DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt ${CMAKE_BINARY_DIR}/bin/generate${CMAKE_EXECUTABLE_SUFFIX} # tell to run in current binary dir WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin # some nice comment in the output COMMENT Generating ${CMAKE_BINARY_DIR}/someoutput.txt VERBATIM ) 2009/8/27 David Cole david.c...@kitware.com Use full path file names as DEPENDS arguments. Also: depend on the executable file too so that cmake knows not to try to run the custom command before the executable is built... i.e. : DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt ${CMAKE_BINARY_DIR}/bin/generate${CMAKE_EXECUTABLE_SUFFIX} HTH, David On Thu, Aug 27, 2009 at 2:41 PM, Swaroop Ramachandra swaroo...@gmail.com wrote: Hi Michael, Thanks for your reply. I still have the same problem. * * gmake-3.81[2]: bin/generate: Command not found lin: gmake-3.81[2]: *** [bin/generate] Error 127 lin: gmake-3.81[1]: *** [CMakeFiles/generate.dir/all] Error 2 Here's my code as is: #Trying to compile and run generate.c. generate.c creates a new file someoutput.txt and copies all data from someinput.txt to someoutput.txt add_executable(generate server/generate.c) add_custom_command( # I want to generate someoutput.txt OUTPUT ${CMAKE_BINARY_DIR}/server/someoutput.txt # using the generate program. cmake knows that generate refers to the above target COMMAND generate ${CMAKE_CURRENT_SOURCE_DIR}/server/someinput.txt # only run if sominput.txt changed DEPENDS server/someinput.txt # tell to run in current binary dir WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin # some nice comment in the output COMMENT Generating ${CMAKE_BINARY_DIR}/someoutput.txt VERBATIM ) Still the same issue. I guess it is trying to execute my generate even before it is compiled. Does CMake see that in the line COMMAND generate refers to the compiled one? Again, since generate is created in round one of make, the second run sees the generate and runs fine. Any help is greatly appreciated! Thanks for your time! Regards, Swaroop 2009/8/27 Michael Wild them...@gmail.com On 27. Aug, 2009, at 0:58, Swaroop Ramachandra wrote: Hi, I'm trying to do the following in my CMake file: 1.
Re: [CMake] Get all required shared libs from a target
See also the BundleUtilities module. Work in CVS CMake recently has extended the fixup_bundle function so that it works on Windows/Linux as well as on a Mac. And what you are looking for is exactly what it does. If executed in an install script, fixup_bundle will analyze a given executable and then copy/fixup any required non-system shared libraries making it easy to depend on third party dlls without adding a bunch of explicit copy steps yourself... The prime example of its use is still Mac-only, though: grep for CompleteBundle in the ParaView source tree for the canonical example. HTH, David On Fri, Aug 28, 2009 at 4:44 AM, Michael Wild them...@gmail.com wrote: You could use CMAKE_RUNTIME_OUTPUT_DIRECTORY or the RUNTIME_OUTPUT_DIRECTORY target property to specify where CMake should put all the produced runtime stuff (on Windows, AFAIK this is *.exe and *.dll), so you don't have to copy them around manually. If the dll's are not built by you, you might want to have a look at the GetPrerequisites and InstallRequiredSystemLibraries modules. Michael On 28. Aug, 2009, at 10:12, Müller Michael wrote: Hi Michael, Thanks for your repsonse but I need the required DLLs to copy them in a post-build step. So I need the information which libaries are required for executing something. E.g., in your example add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) I`d like to have something like GET_TARGET_PROPERTY(LIBS c IMPORTED_LINK_DEPENDENT_LIBRARIES) and then LIBS would contain C:\project\a.dll;C:\project\b.dll. I also tried it with IMPORTED_LINK_DEPENDENT_LIBRARIES but that gives me an empty variable. Hopefully, this made my problem clearer. Michael -Ursprüngliche Nachricht- Von: Michael Wild [mailto:them...@gmail.com] Gesendet: Freitag, 28. August 2009 09:30 An: Müller Michael Cc: cmake@cmake.org Betreff: Re: [CMake] Get all required shared libs from a target On 28. Aug, 2009, at 8:29, Müller Michael wrote: Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael Hi You don't need this (for the case you described). CMake remembers for you: add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) As you see in the last line, c is mentioned to link against b. CMake, however, remembers that b also links against a, and consequently also adds a to the list of libraries to link against. HTH Michael ___ 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 ___ 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 ___ 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
Re: [CMake] Get all required shared libs from a target
If you pull the boost 1.39.0 sources there is an experimental CMake based build system. In those cmake files the developers have somehow figured out how to do what you want. For a given library, you can get all the dependencies. So in your case you would say that lib B depends on Lib A. Then when you did your C target the cmake code figures out that C, which depends on B, will also have a dependency on A. If you can wade through the CMake files it might be worth a look. If you want to manually do this yourself the really ugly but effective way would be to create all the necessary cmake variables in the top CMakeLists.txt. If the variables are declared in that cmake file then they will be available to any other included CMake file. This isn't the best and does not really scale well but for small projects it does work. Just some thoughts. -- Mike Jackson www.bluequartz.net On Aug 28, 2009, at 4:12 AM, Müller Michael wrote: Hi Michael, Thanks for your repsonse but I need the required DLLs to copy them in a post-build step. So I need the information which libaries are required for executing something. E.g., in your example add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) I`d like to have something like GET_TARGET_PROPERTY(LIBS c IMPORTED_LINK_DEPENDENT_LIBRARIES) and then LIBS would contain C:\project\a.dll;C:\project\b.dll. I also tried it with IMPORTED_LINK_DEPENDENT_LIBRARIES but that gives me an empty variable. Hopefully, this made my problem clearer. Michael -Ursprüngliche Nachricht- Von: Michael Wild [mailto:them...@gmail.com] Gesendet: Freitag, 28. August 2009 09:30 An: Müller Michael Cc: cmake@cmake.org Betreff: Re: [CMake] Get all required shared libs from a target On 28. Aug, 2009, at 8:29, Müller Michael wrote: Hi guys, is it possible to investigate a target for all required shared libs (transitively). That means i dont which libraries where set with TARGET_LINK_LIBRARIES and somewhere in my CMakeLists.txt i want to find it out again. Thank you Michael Hi You don't need this (for the case you described). CMake remembers for you: add_library(a ${A_SRCS}) add_library(b ${B_SRCS}) target_link_libraries(b a) add_executable(c ${C_SRCS}) target_link_libraries(c b) As you see in the last line, c is mentioned to link against b. CMake, however, remembers that b also links against a, and consequently also adds a to the list of libraries to link against. HTH Michael ___ 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 ___ 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
Re: [CMake] [New Module] FindHDF5.cmake
On Aug 24, 2009, at 10:20 AM, Will Dicharry wrote: All, I've committed the FindHDF5 and SelectLibraryConfigurations modules to the CMake CVS repository. Thanks for your input and feel free to contact me with questions regarding the modules. --Will Will, Thank you for your initiative in putting this together. Now that I have tried using it, I have a question: how do I specify additional search path(s) for hdf5 if I have it installed in a non-standard place? Thanks, James ___ 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
Re: [CMake] [New Module] FindHDF5.cmake
On Aug 28, 2009, at 9:14 AM, James C. Sutherland wrote: On Aug 24, 2009, at 10:20 AM, Will Dicharry wrote: All, I've committed the FindHDF5 and SelectLibraryConfigurations modules to the CMake CVS repository. Thanks for your input and feel free to contact me with questions regarding the modules. --Will Will, Thank you for your initiative in putting this together. Now that I have tried using it, I have a question: how do I specify additional search path(s) for hdf5 if I have it installed in a non-standard place? Thanks, James Got it. set( ENV{HDF5_ROOT} path ) I have a question about the static library option. I did: set( HDF5_USE_STATIC_LIBRARIES 1 ) which should trigger linkage with static libraries, right? But what I see in the link line is: /usr/lib/libz.dylib /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/ libhdf5_cpp.dylib /usr/lib/libz.dylib /usr/lib/libm.dylib /jcs/apps/ hdf5_serial/lib/libhdf5_cpp.dylib FYI in the configure step the static libs are found, i.e., -- Found HDF5: debug;/jcs/apps/hdf5_serial/lib/libhdf5_cpp.a;/usr/ lib/libz.dylib;/usr/lib/libm.dylib;optimized;/jcs/apps/hdf5_serial/ lib/libhdf5_cpp.a;/usr/lib/libz.dylib;/usr/lib/libm.dylib Any tips on getting the static library linkage working? ___ 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
Re: [CMake] [New Module] FindHDF5.cmake
I have a question about the static library option. I did: set( HDF5_USE_STATIC_LIBRARIES 1 ) which should trigger linkage with static libraries, right? But what I see in the link line is: /usr/lib/libz.dylib /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/ libhdf5_cpp.dylib /usr/lib/libz.dylib /usr/lib/libm.dylib /jcs/apps/ hdf5_serial/lib/libhdf5_cpp.dylib Okay - it appears that was due to an out of date cache. It now tries to link static HDF5 libraries, but is still trying to link dynamic z and m libraries: /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/libhdf5_cpp.a /usr/lib/ libz.dylib /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/libhdf5_cpp.a Previously, I was adding these via target_link_libraries( ... z ) Are these two equivalent? One other question: if one requests the CXX component for HDF5, the hdf5_cpp library is linked in, but the hdf5 library is also required. Adding C and CXX as components fixes this problem. Perhaps the FindHDF5.cmake file could automatically activate C if CXX is requested? That might be more robust... Thanks again for the contribution! James ___ 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
[CMake] generating CTest tests
Hello, I am really a total noob in this CTest stuffs, I read the documentation and it says that I need to use the ADD_TEST method to test an executable right?the format is the following: ADD_TEST(test1 ../build/executable 1) where test1 is the name of the test and 1 is the argument passed to the executable. Question is how do I specify if the test pass then print something, otherwiseprint the other thing? Thanks Alex _ See all the ways you can stay connected to friends and family http://www.microsoft.com/windows/windowslive/default.aspx___ 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
Re: [CMake] generating CTest tests
On Fri, Aug 28, 2009 at 12:57 PM, Aditya Herlambangaditya15...@hotmail.com wrote: Hello, I am really a total noob in this CTest stuffs, I read the documentation and it says that I need to use the ADD_TEST method to test an executable right? the format is the following: ADD_TEST(test1 ../build/executable 1) where test1 is the name of the test and 1 is the argument passed to the executable. Question is how do I specify if the test pass then print something, otherwise print the other thing? You should not be printing anything. I mean from your main return 0 for success any thing non zero for failure. John ___ 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
Re: [CMake] generating CTest tests
Hello, In the ADD_TEST command in the example below I mentioned the test name is test1, is this only a naming thing or does it meanthat I have to have an actual file called test1 in the system to be run by the executable? Sorry, I read the documentation several times and still don't understand as somewhere on the documentation it also mentions test files, I am not sure what to put inside this test file though. Should I put this ADD_TEST inside the test file or the CMakeLists.txt? Thanks Alex Date: Fri, 28 Aug 2009 13:11:01 -0400 Subject: Re: [CMake] generating CTest tests From: dresche...@gmail.com To: aditya15...@hotmail.com; cmake@cmake.org On Fri, Aug 28, 2009 at 12:57 PM, Aditya Herlambangaditya15...@hotmail.com wrote: Hello, I am really a total noob in this CTest stuffs, I read the documentation and it says that I need to use the ADD_TEST method to test an executable right? the format is the following: ADD_TEST(test1 ../build/executable 1) where test1 is the name of the test and 1 is the argument passed to the executable. Question is how do I specify if the test pass then print something, otherwise print the other thing? You should not be printing anything. I mean from your main return 0 for success any thing non zero for failure. John _ With Windows Live, you can organize, edit, and share your photos. http://www.microsoft.com/indonesia/windows/windowslive/products/photo-gallery-edit.aspx___ 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
[CMake] Fwd: generating CTest tests
-- Forwarded message -- From: John Drescher dresche...@gmail.com Date: Fri, Aug 28, 2009 at 1:53 PM Subject: Re: [CMake] generating CTest tests To: Alex H aditya15...@hotmail.com On Fri, Aug 28, 2009 at 1:38 PM, Alex Haditya15...@hotmail.com wrote: Hello, In the ADD_TEST command in the example below I mentioned the test name is test1, is this only a naming thing or does it mean that I have to have an actual file called test1 in the system to be run by the executable? Sorry, I read the documentation several times and still don't understand as somewhere on the documentation it also mentions test files, I am not sure what to put inside this test file though. Should I put this ADD_TEST inside the test file or the CMakeLists.txt? Thanks Alex You make a separate target for this. Here is an example. I have a main project Called QtBasicUtils in that main project I have in the main application CMakeLists.txt option (BUILD_TESTING Build Tests ON) IF(BUILD_TESTING) ENABLE_TESTING() add_subdirectory(Testing) ENDIF(BUILD_TESTING) And then in the CMakeLists.txt file in QtBasicUtils/Testing #This file contains the automated unit testing for QtBasicUtils LINK_LIBRARIES(BasicTest QtBasicUtils ${QT_LIBRARIES}) include_directories( ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/.. ${PROJECT_SOURCE_DIR}/include ./include) set(TEST_SRCS ./src/basic.cxx ./src/testxml.cxx ./src/testUserProps.cxx ) set(TEST_HDRS ./include/testxml.h ./include/testUserProps.h ) add_executable(BasicTest ${TEST_SRCS} ${TEST_HDRS}) add_dependencies(BasicTest QtBasicUtils) file(WRITE ${EXECUTABLE_OUTPUT_PATH}/test0.txt +FLOATARGS 1.0 2.0 2.0 2.0 2.0 -S9.0) add_test(FileCMD0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest @${EXECUTABLE_OUTPUT_PATH}/test0.txt) #This will fail because the file should not exist. add_test(FileCMD1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest @${EXECUTABLE_OUTPUT_PATH}/../test11.txt) SET_TESTS_PROPERTIES(FileCMD1 PROPERTIES WILL_FAIL TRUE) ADD_TEST(Test0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +?) ADD_TEST(Test1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +Test 1.0) ADD_TEST(StringListArg0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTARG 1 2 3 4 . -S10) ADD_TEST(StringListArg1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTARG 1 2 3 . -S6) ADD_TEST(StringListOpt0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTOPT -I1 2 3 . -S6) ADD_TEST(StringListOpt1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTOPT -I1 2 3 4 . -S10) ADD_TEST(BoolOpt1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +BOOLOPT -B) ADD_TEST(BoolOpt2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +BOOLOPT -B-) SET_TESTS_PROPERTIES(BoolOpt2 PROPERTIES WILL_FAIL TRUE) ADD_TEST(ExtBoolOpt1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended=+) ADD_TEST(ExtBoolOpt2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended=-) ADD_TEST(ExtBoolOpt3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended+) ADD_TEST(ExtBoolOpt4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended-) ADD_TEST(ExtBoolOpt5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended) SET_TESTS_PROPERTIES(ExtBoolOpt2 PROPERTIES WILL_FAIL TRUE) SET_TESTS_PROPERTIES(ExtBoolOpt4 PROPERTIES WILL_FAIL TRUE) ADD_TEST(FloatArgs0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 -S5.0) ADD_TEST(FloatArgs1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 2.0 -S6.0) ADD_TEST(FloatArgs2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 1.0 -S5.0) ADD_TEST(FloatArgs3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 -S6.0) ADD_TEST(FloatArgs4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 1.0 1.0 1.0 1.0 -S5.0) ADD_TEST(FloatArgs5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 2.0 2.0 2.0 2.0 2.0 -S10.0) ADD_TEST(FloatArgs6 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS -2.0 2.0 2.0 2.0 2.0 -S6.0) ADD_TEST(FloatArgs7 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 2.0 2.0 2.0 -S10.0) SET_TESTS_PROPERTIES(FloatArgs7 PROPERTIES WILL_FAIL TRUE) ADD_TEST(FloatArgs8 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 2.0 2.0 2.0 1.0 -S10.0) SET_TESTS_PROPERTIES(FloatArgs8 PROPERTIES WILL_FAIL TRUE) ADD_TEST(DoubleArgs0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 1.0 -S5.0) ADD_TEST(DoubleArgs1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 2.0 -S6.0) ADD_TEST(DoubleArgs2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 1.0 1.0 -S5.0) ADD_TEST(DoubleArgs3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 1.0 2.0 -S6.0) ADD_TEST(DoubleArgs4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 1.0 1.0 1.0 1.0 1.0 -S5.0) ADD_TEST(DoubleArgs5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +DOUBLEARGS 2.0 2.0 2.0 2.0 2.0 -S10.0) ADD_TEST(DoubleArgs6
Re: [CMake] Fwd: generating CTest tests
Hello, My problem is actually really simple I have a .cpp file and the program just basically take an int as an argument, if the argument is from certain numbers it returns a 1 otherwise 0.Now I need to create a unit test that would allow me to do this... how can I check the return value of the program? The add_test command just adds the test to be performed using aspecific argument but it never tests the output... Alex Date: Fri, 28 Aug 2009 13:53:33 -0400 From: dresche...@gmail.com To: cmake@cmake.org Subject: [CMake] Fwd: generating CTest tests -- Forwarded message -- From: John Drescher dresche...@gmail.com Date: Fri, Aug 28, 2009 at 1:53 PM Subject: Re: [CMake] generating CTest tests To: Alex H aditya15...@hotmail.com On Fri, Aug 28, 2009 at 1:38 PM, Alex Haditya15...@hotmail.com wrote: Hello, In the ADD_TEST command in the example below I mentioned the test name is test1, is this only a naming thing or does it mean that I have to have an actual file called test1 in the system to be run by the executable? Sorry, I read the documentation several times and still don't understand as somewhere on the documentation it also mentions test files, I am not sure what to put inside this test file though. Should I put this ADD_TEST inside the test file or the CMakeLists.txt? Thanks Alex You make a separate target for this. Here is an example. I have a main project Called QtBasicUtils in that main project I have in the main application CMakeLists.txt option (BUILD_TESTING Build Tests ON) IF(BUILD_TESTING) ENABLE_TESTING() add_subdirectory(Testing) ENDIF(BUILD_TESTING) And then in the CMakeLists.txt file in QtBasicUtils/Testing #This file contains the automated unit testing for QtBasicUtils LINK_LIBRARIES(BasicTest QtBasicUtils ${QT_LIBRARIES}) include_directories( ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/.. ${PROJECT_SOURCE_DIR}/include ./include) set(TEST_SRCS ./src/basic.cxx ./src/testxml.cxx ./src/testUserProps.cxx ) set(TEST_HDRS ./include/testxml.h ./include/testUserProps.h ) add_executable(BasicTest ${TEST_SRCS} ${TEST_HDRS}) add_dependencies(BasicTest QtBasicUtils) file(WRITE ${EXECUTABLE_OUTPUT_PATH}/test0.txt +FLOATARGS 1.0 2.0 2.0 2.0 2.0 -S9.0) add_test(FileCMD0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest @${EXECUTABLE_OUTPUT_PATH}/test0.txt) #This will fail because the file should not exist. add_test(FileCMD1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest @${EXECUTABLE_OUTPUT_PATH}/../test11.txt) SET_TESTS_PROPERTIES(FileCMD1 PROPERTIES WILL_FAIL TRUE) ADD_TEST(Test0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +?) ADD_TEST(Test1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +Test 1.0) ADD_TEST(StringListArg0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTARG 1 2 3 4 . -S10) ADD_TEST(StringListArg1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTARG 1 2 3 . -S6) ADD_TEST(StringListOpt0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTOPT -I1 2 3 . -S6) ADD_TEST(StringListOpt1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +STRLSTOPT -I1 2 3 4 . -S10) ADD_TEST(BoolOpt1${EXECUTABLE_OUTPUT_PATH}/BasicTest +BOOLOPT -B) ADD_TEST(BoolOpt2${EXECUTABLE_OUTPUT_PATH}/BasicTest +BOOLOPT -B-) SET_TESTS_PROPERTIES(BoolOpt2 PROPERTIES WILL_FAIL TRUE) ADD_TEST(ExtBoolOpt1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended=+) ADD_TEST(ExtBoolOpt2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended=-) ADD_TEST(ExtBoolOpt3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended+) ADD_TEST(ExtBoolOpt4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended-) ADD_TEST(ExtBoolOpt5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +EXTBOOLOPT --use_extended) SET_TESTS_PROPERTIES(ExtBoolOpt2 PROPERTIES WILL_FAIL TRUE) SET_TESTS_PROPERTIES(ExtBoolOpt4 PROPERTIES WILL_FAIL TRUE) ADD_TEST(FloatArgs0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 -S5.0) ADD_TEST(FloatArgs1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 2.0 -S6.0) ADD_TEST(FloatArgs2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 1.0 -S5.0) ADD_TEST(FloatArgs3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 -S6.0) ADD_TEST(FloatArgs4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 1.0 1.0 1.0 1.0 -S5.0) ADD_TEST(FloatArgs5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 2.0 2.0 2.0 2.0 2.0 -S10.0) ADD_TEST(FloatArgs6 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS -2.0 2.0 2.0 2.0 2.0 -S6.0) ADD_TEST(FloatArgs7 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 2.0 2.0 2.0 -S10.0) SET_TESTS_PROPERTIES(FloatArgs7 PROPERTIES WILL_FAIL TRUE) ADD_TEST(FloatArgs8 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +FLOATARGS 1.0 2.0 2.0 2.0 2.0 1.0 -S10.0)
Re: [CMake] Fwd: generating CTest tests
On Fri, Aug 28, 2009 at 2:07 PM, Alex Haditya15...@hotmail.com wrote: Hello, My problem is actually really simple I have a .cpp file and the program just basically take an int as an argument, if the argument is from certain numbers it returns a 1 otherwise 0. Now I need to create a unit test that would allow me to do this... how can I check the return value of the program? The add_test command just adds the test to be performed using a specific argument but it never tests the output... CMake automatically does this for you when you build the RUN_TESTS target on Visual Studio or do a make test on other systems Here is an example of the output of RUN_TESTS under visual studio 2005 for the project I posted the CMakeLists.txt 1Performing Post-Build Event... 1Start processing tests 1Test project X:/32Bit/VC.80/Qt/QtBasicUtils 1 1/ 48 Testing FileCMD0 . Passed0.55 sec 1 2/ 48 Testing FileCMD1 . Passed1.58 sec 1 3/ 48 Testing Test0 Passed0.17 sec 1 4/ 48 Testing Test1 Passed0.16 sec 1 5/ 48 Testing StringListArg0 ... Passed0.06 sec 1 6/ 48 Testing StringListArg1 ... Passed0.06 sec 1 7/ 48 Testing StringListOpt0 ... Passed0.16 sec 1 8/ 48 Testing StringListOpt1 ... Passed0.06 sec 1 9/ 48 Testing BoolOpt1 . Passed0.16 sec 1 10/ 48 Testing BoolOpt2 . Passed0.14 sec 1 11/ 48 Testing ExtBoolOpt1 .. Passed0.25 sec 1 12/ 48 Testing ExtBoolOpt2 .. Passed0.16 sec 1 13/ 48 Testing ExtBoolOpt3 .. Passed0.06 sec 1 14/ 48 Testing ExtBoolOpt4 .. Passed0.16 sec 1 15/ 48 Testing ExtBoolOpt5 .. Passed0.17 sec 1 16/ 48 Testing FloatArgs0 ... Passed0.19 sec 1 17/ 48 Testing FloatArgs1 ... Passed0.06 sec 1 18/ 48 Testing FloatArgs2 ... Passed0.16 sec 1 19/ 48 Testing FloatArgs3 ... Passed0.16 sec 1 20/ 48 Testing FloatArgs4 ... Passed0.16 sec 1 21/ 48 Testing FloatArgs5 ... Passed0.16 sec 1 22/ 48 Testing FloatArgs6 ... Passed0.14 sec 1 23/ 48 Testing FloatArgs7 ... Passed0.16 sec 1 24/ 48 Testing FloatArgs8 ... Passed1.30 sec 1 25/ 48 Testing DoubleArgs0 .. Passed0.16 sec 1 26/ 48 Testing DoubleArgs1 .. Passed0.16 sec 1 27/ 48 Testing DoubleArgs2 .. Passed0.14 sec 1 28/ 48 Testing DoubleArgs3 .. Passed0.19 sec 1 29/ 48 Testing DoubleArgs4 .. Passed0.16 sec 1 30/ 48 Testing DoubleArgs5 .. Passed0.06 sec 1 31/ 48 Testing DoubleArgs6 .. Passed0.14 sec 1 32/ 48 Testing DoubleArgs7 .. Passed0.16 sec 1 33/ 48 Testing DoubleArgs8 .. Passed2.03 sec 1 34/ 48 Testing XMLExport0 ... Passed0.17 sec 1 35/ 48 Testing XMLExport1 ... Passed0.17 sec 1 36/ 48 Testing XMLExport2 ... Passed0.14 sec 1 37/ 48 Testing XMLExport3 ... Passed0.14 sec 1 38/ 48 Testing XMLExport4 ... Passed0.14 sec 1 39/ 48 Testing XMLExport5 ... Passed0.17 sec 1 40/ 48 Testing XMLExport6 ... Passed0.14 sec 1 41/ 48 Testing UserProp0 Passed0.14 sec 1 42/ 48 Testing UserProp1 Passed0.16 sec 1 43/ 48 Testing UserProp2 Passed0.06 sec 1 44/ 48 Testing UserProp3 Passed0.14 sec 1 45/ 48 Testing UserProp4 Passed0.16 sec 1 46/ 48 Testing UserProp5 Passed0.14 sec 1 47/ 48 Testing UserProp6 Passed0.22 sec 1 48/ 48 Testing UserProp7 Passed0.14 sec 1100% tests passed, 0 tests failed out of 48 1Total CPU time = 11.78 sec 1Build log was saved at file://x:\32Bit\VC.80\Qt\QtBasicUtils\RUN_TESTS.dir\RelWithDebInfo\BuildLog.htm 1RUN_TESTS - 0 error(s), 0 warning(s) == Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped == ___ 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
[CMake] dependency in custom command?
Hello List, I'm new to cmake and liking it a lot. I'm using cmake 2.6.3 on Linux. I'm building a dynamically loadable module and an executable to test it. Each lives in a different directory. My test program needs to know the location of the dll when calling dlopen(). To solve this, I created a custom command to copy the dll to the binary directory of the test program. This works, but I have an annoying dependency problem. Specifically, if the dll gets rebuilt, the copy command does not execute. The copy command only executes if the test program gets rebuilt. I do not understand how to make this copy depend on the dll being rebuilt. I want all test programs to pull the rebuilt dll as needed. I do not want the CMakeLists.txt for the dll to have any knowledge of the test programs. In CMakeLists.txt for the test program: add_executable( test_my_module test_main.cpp ) add_dependencies ( test_my_module my_module # not needed? ) # Loadable modules are never listed at link time. target_link_libraries ( test_my_module dl ) # Put the location of the .so library we need in the SO_LOCATION variable. # We then use this location in the copy command below. get_target_property ( SO_LOCATION my_module# .so library target LOCATION ) # Create a custom build step to copy the dynamically loaded .so file # into the this directory so our test executable can find it. add_custom_command( TARGET test_my_module POST_BUILD DEPENDS my_module # no effect? COMMAND ${CMAKE_COMMAND} -E copy ${SO_LOCATION} ${CMAKE_CURRENT_BINARY_DIR} COMMENT CUSTOM COMMAND: Copy my_module to build directory ) What should I do make the copy happen if the dll is rebuilt? Thanks for any advice, -steve ___ 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
Re: [CMake] dependency in custom command?
On Fri, Aug 28, 2009 at 11:28:53AM -0700, King, Steven R wrote: I'm building a dynamically loadable module and an executable to test it. Each lives in a different directory. My test program needs to know the location of the dll when calling dlopen(). To solve this, I created a custom command to copy the dll to the binary directory of the test program. This works, but I have an annoying dependency problem. Specifically, if the dll gets rebuilt, the copy command does not execute. The copy command only executes if the test program gets rebuilt. I do not understand how to make this copy depend on the dll being rebuilt. I want all test programs to pull the rebuilt dll as needed. I do not want the CMakeLists.txt for the dll to have any knowledge of the test programs. Wrap your custom_command with a custom_target. See the CMake FAQ for some recipes. Then just do: add_dependencies (test_my_module custom_target_that_copies_my_module) In CMakeLists.txt for the test program: add_dependencies ( test_my_module my_module # not needed? ) You do want this stanza. # Put the location of the .so library we need in the SO_LOCATION variable. # We then use this location in the copy command below. get_target_property ( SO_LOCATION my_module# .so library target LOCATION ) You don't need to do this. Since my_module is a CMake target, you can just use my_module instead of ${SO_LOCATION} in the custom_command below and CMake will figure out where the .so is on the disk # Create a custom build step to copy the dynamically loaded .so file # into the this directory so our test executable can find it. add_custom_command( TARGET test_my_module POST_BUILD DEPENDS my_module # no effect? COMMAND ${CMAKE_COMMAND} -E copy ${SO_LOCATION} ${CMAKE_CURRENT_BINARY_DIR} COMMENT CUSTOM COMMAND: Copy my_module to build directory ) You may want to use -E copy_if_different there instead. tyler ___ 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
Re: [CMake] Fwd: generating CTest tests
Hello, So where do we specify/put in the CMakeLists.txt where test1 is expected to fail or pass? How does CTest knows this... Just to clarify the add_test command should be put inside a CMakeLists.txt? What if I want to invokectest using the following command: ctest -R testpage What should testpage have inside of it? Alex H. Date: Fri, 28 Aug 2009 14:14:21 -0400 Subject: Re: [CMake] Fwd: generating CTest tests From: dresche...@gmail.com To: aditya15...@hotmail.com; cmake@cmake.org On Fri, Aug 28, 2009 at 2:07 PM, Alex Haditya15...@hotmail.com wrote: Hello, My problem is actually really simple I have a .cpp file and the program just basically take an int as an argument, if the argument is from certain numbers it returns a 1 otherwise 0. Now I need to create a unit test that would allow me to do this... how can I check the return value of the program? The add_test command just adds the test to be performed using a specific argument but it never tests the output... CMake automatically does this for you when you build the RUN_TESTS target on Visual Studio or do a make test on other systems Here is an example of the output of RUN_TESTS under visual studio 2005 for the project I posted the CMakeLists.txt 1Performing Post-Build Event... 1Start processing tests 1Test project X:/32Bit/VC.80/Qt/QtBasicUtils 1 1/ 48 Testing FileCMD0 . Passed0.55 sec 1 2/ 48 Testing FileCMD1 . Passed1.58 sec 1 3/ 48 Testing Test0 Passed0.17 sec 1 4/ 48 Testing Test1 Passed0.16 sec 1 5/ 48 Testing StringListArg0 ... Passed0.06 sec 1 6/ 48 Testing StringListArg1 ... Passed0.06 sec 1 7/ 48 Testing StringListOpt0 ... Passed0.16 sec 1 8/ 48 Testing StringListOpt1 ... Passed0.06 sec 1 9/ 48 Testing BoolOpt1 . Passed0.16 sec 1 10/ 48 Testing BoolOpt2 . Passed0.14 sec 1 11/ 48 Testing ExtBoolOpt1 .. Passed0.25 sec 1 12/ 48 Testing ExtBoolOpt2 .. Passed0.16 sec 1 13/ 48 Testing ExtBoolOpt3 .. Passed0.06 sec 1 14/ 48 Testing ExtBoolOpt4 .. Passed0.16 sec 1 15/ 48 Testing ExtBoolOpt5 .. Passed0.17 sec 1 16/ 48 Testing FloatArgs0 ... Passed0.19 sec 1 17/ 48 Testing FloatArgs1 ... Passed0.06 sec 1 18/ 48 Testing FloatArgs2 ... Passed0.16 sec 1 19/ 48 Testing FloatArgs3 ... Passed0.16 sec 1 20/ 48 Testing FloatArgs4 ... Passed0.16 sec 1 21/ 48 Testing FloatArgs5 ... Passed0.16 sec 1 22/ 48 Testing FloatArgs6 ... Passed0.14 sec 1 23/ 48 Testing FloatArgs7 ... Passed0.16 sec 1 24/ 48 Testing FloatArgs8 ... Passed1.30 sec 1 25/ 48 Testing DoubleArgs0 .. Passed0.16 sec 1 26/ 48 Testing DoubleArgs1 .. Passed0.16 sec 1 27/ 48 Testing DoubleArgs2 .. Passed0.14 sec 1 28/ 48 Testing DoubleArgs3 .. Passed0.19 sec 1 29/ 48 Testing DoubleArgs4 .. Passed0.16 sec 1 30/ 48 Testing DoubleArgs5 .. Passed0.06 sec 1 31/ 48 Testing DoubleArgs6 .. Passed0.14 sec 1 32/ 48 Testing DoubleArgs7 .. Passed0.16 sec 1 33/ 48 Testing DoubleArgs8 .. Passed2.03 sec 1 34/ 48 Testing XMLExport0 ... Passed0.17 sec 1 35/ 48 Testing XMLExport1 ... Passed0.17 sec 1 36/ 48 Testing XMLExport2 ... Passed0.14 sec 1 37/ 48 Testing XMLExport3 ... Passed0.14 sec 1 38/ 48 Testing XMLExport4 ... Passed0.14 sec 1 39/ 48 Testing XMLExport5 ... Passed0.17 sec 1 40/ 48 Testing XMLExport6 ... Passed0.14 sec 1 41/ 48 Testing UserProp0 Passed0.14 sec 1 42/ 48 Testing UserProp1 Passed0.16 sec 1 43/ 48 Testing UserProp2 Passed0.06 sec 1 44/ 48 Testing UserProp3 Passed0.14 sec 1 45/ 48 Testing UserProp4 Passed0.16 sec 1 46/ 48 Testing UserProp5 Passed0.14 sec 1 47/ 48 Testing UserProp6 Passed0.22 sec 1 48/ 48 Testing UserProp7 Passed0.14 sec 1100% tests passed, 0 tests failed out of 48 1Total CPU time = 11.78 sec 1Build log was saved at file://x:\32Bit\VC.80\Qt\QtBasicUtils\RUN_TESTS.dir\RelWithDebInfo\BuildLog.htm 1RUN_TESTS - 0 error(s), 0 warning(s) == Build: 1 succeeded, 0 failed, 1
Re: [CMake] Fwd: generating CTest tests
On Fri, Aug 28, 2009 at 3:11 PM, Alex H aditya15...@hotmail.com wrote: Hello, So where do we specify/put in the CMakeLists.txt where test1 is expected to fail or pass? How does CTest knows this... If your program returns a 0, it passes. If it does not, it fails. If you want to invert this logic, set the test property WILL_FAIL. If you want to base the pass/fail value on test output, set the test property PASS_REGULAR_EXPRESSION or FAIL_REGULAR_EXPRESSION : if the output matches the regex, it passes or fails accordingly. i.e.: set_property(TEST test1 PROPERTY WILL_FAIL TRUE) would invert the pass/fail logic see also: $ cmake --help-property WILL_FAIL $ cmake --help-property PASS_REGULAR_EXPRESSION $ cmake --help-property FAIL_REGULAR_EXPRESSION $ cmake --help-command set_property Just to clarify the add_test command should be put inside a CMakeLists.txt? Yes, that's correct. What if I want to invoke ctest using the following command: ctest -R testpage What should testpage have inside of it? testpage should be the name of a test added using add_test. It can have *anything you want to test* inside of it ctest -R testpage will execute the test as specified in the add_test command. HTH, David ___ 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
Re: [CMake] dependency in custom command?
You don't have to do the copying yourself. Just tell CMake in which directory it should create the module by either setting the LIBRARY_OUTPUT_DIRECTORY target property or the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable. AFAIK the LOCATION property is only present for compatibility with CMake 2.4, and shouldn't be used in new code. HTH Michael On 28. Aug, 2009, at 20:28, King, Steven R wrote: Hello List, I'm new to cmake and liking it a lot. I'm using cmake 2.6.3 on Linux. I'm building a dynamically loadable module and an executable to test it. Each lives in a different directory. My test program needs to know the location of the dll when calling dlopen(). To solve this, I created a custom command to copy the dll to the binary directory of the test program. This works, but I have an annoying dependency problem. Specifically, if the dll gets rebuilt, the copy command does not execute. The copy command only executes if the test program gets rebuilt. I do not understand how to make this copy depend on the dll being rebuilt. I want all test programs to pull the rebuilt dll as needed. I do not want the CMakeLists.txt for the dll to have any knowledge of the test programs. In CMakeLists.txt for the test program: add_executable( test_my_module test_main.cpp ) add_dependencies ( test_my_module my_module # not needed? ) # Loadable modules are never listed at link time. target_link_libraries ( test_my_module dl ) # Put the location of the .so library we need in the SO_LOCATION variable. # We then use this location in the copy command below. get_target_property ( SO_LOCATION my_module# .so library target LOCATION ) # Create a custom build step to copy the dynamically loaded .so file # into the this directory so our test executable can find it. add_custom_command( TARGET test_my_module POST_BUILD DEPENDS my_module # no effect? COMMAND ${CMAKE_COMMAND} -E copy $ {SO_LOCATION} ${CMAKE_CURRENT_BINARY_DIR} COMMENT CUSTOM COMMAND: Copy my_module to build directory ) What should I do make the copy happen if the dll is rebuilt? Thanks for any advice, -steve ___ 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 ___ 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
Re: [CMake] dependency in custom command?
You don't need to do this. Since my_module is a CMake target, you can just use my_module instead of ${SO_LOCATION} in the custom_command below and CMake will figure out where the .so is on the disk Hi Tyler -- Substituting my_module did not work. The copy fails. Is this a cmake bug? Thanks for the other pointers. ___ 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
Re: [CMake] dependency in custom command?
You don't have to do the copying yourself. Just tell CMake in which directory it should create the module by either setting the LIBRARY_OUTPUT_DIRECTORY target property or the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable. AFAIK the LOCATION property is only present for compatibility with CMake 2.4, and shouldn't be used in new code. Hi Mike -- I don't know from which directory my module test will run when using ctest. So, my test program does not have an easy way to know the relative path to LIBRARY_OUTPUT_DIRECTORY when making the dlopen() call. Allowing my test program to assume the dll is in its local directory seemed to be the easiest solution. ___ 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
[CMake] CMake bundle app for OSX
Hello: I've been using CMake and CPack a bit on Linux. Now I have an application that uses Qt and needs to be used on Linux and Mac OSX. I want to create an installer using CMake / CPack for the application. The application is called following The following is from my CMakeLists.txt file set( MACOSX_RESOURCE_FILES ${CMAKE_SOURCE_DIR}/icons/ff.icns ) set( MACOSX_BUNDLE_INFO_STRING @EXE_NAME@ - Version ${VERSION} ) set( MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION} ) set( MACOSX_BUNDLE_ICON_FILE ff.icns ) set( MACOSX_BUNDLE_GUI_IDENTIFIER com.sri.aic ) set( MACOSX_BUNDLE_BUNDLE_NAME @EXE_NAME@ ) add_executable( ${MODULE} MACOSX_BUNDLE ${SOURCE_FILES} ${MOC_SOURCE_FILES} ${UI_SOURCE_FILES} ${RESOURCE_SOURCE_FILES} ${HEADER_FILES} ${MACOSX_RESOURCE_FILES} ) target_link_libraries( ${MODULE} ${QT_LIBRARIES}) set_source_files_properties( ${MACOSX_RESOURCE_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) This creates a folder called following.app/ with the appropriate sub-directories and contents. I can zip it up and send it to the perspn who needs to install it? My question is how do I create an installer based on this? (for instance like a .dmg file or something?) What are the CPACK variables I need to set? Does anybody have an example file? Thanks, Aravind. PS. I'm a newbie as far as OSX is concerned - so please bear with poor notation. ___ 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
Re: [CMake] Fwd: generating CTest tests
I am going to take an example from your a snippet test in your previous example: ADD_TEST(XMLExport0 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 0) ADD_TEST(XMLExport1 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 1) ADD_TEST(XMLExport2 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 2) ADD_TEST(XMLExport3 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 3) ADD_TEST(XMLExport4 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 4) ADD_TEST(XMLExport5 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 5) ADD_TEST(XMLExport6 ${EXECUTABLE_OUTPUT_PATH}/BasicTest +XMLEXP 6)if this is put inside the CMakeLists.txt then if I want to run it as ctest -R testpagethen inside testing I should have an implementation of the test XMLExport0..up to XMLExport6??What language should testpage be written in? I guess that's the question.. I am confused what to put inside testpage, an example would help. Date: Fri, 28 Aug 2009 15:27:43 -0400 Subject: Re: [CMake] Fwd: generating CTest tests From: david.c...@kitware.com To: aditya15...@hotmail.com CC: cmake@cmake.org On Fri, Aug 28, 2009 at 3:11 PM, Alex H aditya15...@hotmail.com wrote: Hello, So where do we specify/put in the CMakeLists.txt where test1 is expected to fail or pass? How does CTest knows this... If your program returns a 0, it passes. If it does not, it fails. If you want to invert this logic, set the test property WILL_FAIL.If you want to base the pass/fail value on test output, set the test property PASS_REGULAR_EXPRESSION or FAIL_REGULAR_EXPRESSION : if the output matches the regex, it passes or fails accordingly. i.e.:set_property(TEST test1 PROPERTY WILL_FAIL TRUE)would invert the pass/fail logic see also:$ cmake --help-property WILL_FAIL $ cmake --help-property PASS_REGULAR_EXPRESSION $ cmake --help-property FAIL_REGULAR_EXPRESSION $ cmake --help-command set_property Just to clarify the add_test command should be put inside a CMakeLists.txt? Yes, that's correct. What if I want to invokectest using the following command: ctest -R testpage What should testpage have inside of it? testpage should be the name of a test added using add_test. It can have *anything you want to test* inside of it ctest -R testpage will execute the test as specified in the add_test command. HTH,David _ Share your memories online with anyone you want. http://www.microsoft.com/indonesia/windows/windowslive/products/photos-share.aspx?tab=1___ 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
[CMake] exit_failure
My problem is that in my executable test cpp code, the code may return a cpp EXIT_FAILURE macro. Problem is how can I use the cpp macro inside the set_tests_properties regex arguments? _ Share your memories online with anyone you want. http://www.microsoft.com/indonesia/windows/windowslive/products/photos-share.aspx?tab=1___ 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
Re: [CMake] dependency in custom command?
Wrap your custom_command with a custom_target. See the CMake FAQ for some recipes. OK, my CMakeLists.txt is growing rapidly. :^( All I've managed to do is cause the module to be copied every time. Again, my goal is to copy the dll to the directory of the corresponding test program if the dll has been rebuilt. Any pointers are very much appreciated. There must be some newb problems here. My new approach with the add_custom_target: add_dependencies ( test_my_module my_module test_my_module_copy ) target_link_libraries ( test_my_module dl ) get_target_property ( SO_LOCATION my_module# .so library target LOCATION ) get_target_property ( SO_NAME my_module# .so library target OUTPUT_NAME ) # Create a custom build step to copy the dynamically loaded .so file # into the this directory so our test executable can find it. add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SO_NAME} COMMAND ${CMAKE_COMMAND} -E copy ${SO_LOCATION} ${CMAKE_CURRENT_BINARY_DIR} DEPENDS my_module COMMENT CUSTOM COMMAND: Copy ${SO_NAME} to build directory ) add_custom_target ( test_my_module_copy DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SO_NAME} DEPENDS my_module ) ___ 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
Re: [CMake] dependency in custom command?
You don't have to do the copying yourself. Just tell CMake in which directory it should create the module by either setting the LIBRARY_OUTPUT_DIRECTORY target property or the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable. AFAIK the LOCATION property is only present for compatibility with CMake 2.4, and shouldn't be used in new code. Hi Mike -- I don't know from which directory my module test will run when using ctest. So, my test program does not have an easy way to know the relative path to LIBRARY_OUTPUT_DIRECTORY when making the dlopen() call. Allowing my test program to assume the dll is in its local directory seemed to be the easiest solution. Can't you put all executables and shared libraries in one directory, so they are all local to each other? In the top level CMakeLists.txt file just add SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) The executables you specify in ADD_TEST() will have a working directory that is ${CMAKE_CURRENT_BINARY_DIR} Clint ___ 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