Re: [CMake] newbie q - where do I put what in which CMakeLists file? out of source build
2011/3/10 David Cole david.c...@kitware.com: Well if the build directory is *in* the source directory, then make package_source *should* include it. This is not a problem, but the expected behavior. If you don't want the build tree in the source tree, then don't put it there. Or do include ${CMAKE_BINARY_DIR}/* in CPACK_SOURCE_IGNORE_FILES Note that there is a special case where excluding CMAKE_BINARY_DIR is annoying, this is when you do in-source build, i.e. if CMAKE_BINARY_DIR == CMAKE_SOURCE_DIR. What I usually do is: IF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) SET(CPACK_SOURCE_IGNORE_FILES usual list) ELSE(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) SET(CPACK_SOURCE_IGNORE_FILES usuallist;${CMAKE_BINARY_DIR}/*) ENDIF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) -- Erk Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org ___ 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] newbie q - where do I put what in which CMakeLists file? out of source build
On 03/10/2011 03:11 AM, Pierre Abbat wrote: On Wednesday 09 March 2011 13:09:39 Michael Hertling wrote: Could you boil down your project to a minimal but complete example which demonstrates the issues with the header not being found and the files not being placed properly and post it here? Here's an example of it compiling correctly, but making a package wrong: minimal.tar.gz . -bash-4.1$ cd build -bash-4.1$ cmake ../src -- The C compiler identification is GNU -- The CXX compiler identification is GNU snip -bash-4.1$ make Scanning dependencies of target readmidi [100%] Building CXX object CMakeFiles/readmidi.dir/midi.o Linking CXX executable readmidi [100%] Built target readmidi -bash-4.1$ ./readmidi Header, 6 bytes Track, 19 bytes Track, 655 bytes Track, 675 bytes Track, 1491 bytes Track, 1334 bytes -bash-4.1$ make package_source snip bash-4.1$ cd /tmp -bash-4.1$ tar xvzf ~/minimal/build/minimal-0.1.1-Source.tar.gz x minimal-0.1.1-Source/config.h.in x minimal-0.1.1-Source/midi.h x minimal-0.1.1-Source/CMakeLists.txt~ x minimal-0.1.1-Source/midi.cpp x minimal-0.1.1-Source/CMakeLists.txt x minimal-0.1.1-Source/midi.cpp~ For minimal2, follow the same steps except start with cmake ... The program doesn't compile; the package is rooted correctly, but contains contents of the build directory as well as the src directory. Pierre The question w.r.t. your first minimal example should be answered by David and Eric in the meantime. The reason why your minimal2 example doesn't compile is that you mentioned INCLUDE_DIRECTORIES() *after* ADD_SUBDIRECTORY() in your top-level CMakeLists.txt, so it does not take effect for the compilation of sources in the src directory. In general, the order of commands in CMakeLists.txt files does matter. Furthermore, you have a persistent file in the build directory; you should not do so. Besides that you don't really do an out-of-source build in such a manner, a build directory is usually temporary, i.e. the users create and enter it, configure/build/test/install/package the project from within in and finally throw it away. Instead, you should place the MIDI files in their own directory, refer to them by, say, ${CMAKE_SOURCE_DIR}/midi and reserve the build directory for the build process only. Moreover, while it's common to create a subdirectory of the project's top-level directory for building, it's also common to use another one for that purpose, e.g. /tmp, /var/tmp, ~/tmp, /dev/shm etc., and the users are completely free to choose, so you should not insist on the usage of ${CMAKE_SOURCE_DIR}/build. Additionally, ${CMAKE_SOURCE_DIR} might be read-only, and build directories that are descendants of the source directory could have some pitfalls - as you have seen. Finally, with single-configuration generators, notably the Makefile ones, you can build only one configuration per build directory, i.e. *either* RELEASE *or* DEBUG *or* your-config-here etc., so it's perfectly legal to have multiple build trees side by side at the same time. Regards, 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] newbie q - where do I put what in which CMakeLists file? out of source build
configure_file(src/config.h.in config.h) In CMake, use of relative filenames is (mostly) discouraged. A robust way to do this would be to write: configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIRECTORY}/include/config.h ) include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY}/include ) The include_directories tells cmake to add a -I/path/to/tone12/build/include directive, so config.h can be found. ~/tone12/src/CMakeLists.txt: add_executable(tone12 tone12.cpp midi.cpp midi.h riffwave.cpp riffwave.cpp tonegen.cpp tonegen.h) configure_file(config.h.in config.h) It's normally not a good idea to call configure_file twice. You have to decide which of the two configure_file statements you really want (which fits your project style, is more robust when changing directory names,...). You have the same issue with relative paths here, as above. If you want to configure your header here, you could write: configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIRECTORY}/config.h ) include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY} ) (Current binary directory in this case evaluates to /path/to/tone12/build/src.) HTH, Johannes -- Johannes Zarl Virtual Reality Services Johannes Kepler University Informationsmanagement Altenbergerstrasze 69 4040 Linz, Austria Phone: +43 732 2468-8321 johannes.z...@jku.at http://vrc.zid.jku.at ___ 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] newbie q - where do I put what in which CMakeLists file? out of source build
On Wednesday 09 March 2011 05:19:42 Johannes Zarl wrote: configure_file(src/config.h.in config.h) In CMake, use of relative filenames is (mostly) discouraged. A robust way to do this would be to write: configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIRECTORY}/include/config.h ) include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY}/include ) I got it to work, typing cmake ../src and leaving ~/tone12/CMakeLists.txt empty. INCLUDE_DIRECTORIES has to be in all caps (at least I didn't see it add -I when I had it in lowercase) and it's CMAKE_CURRENT_BINARY_DIR (with ...DIRECTORY it tried to write to /include). I ran make package_source and get a tarball containing the following: -rw-r--r-- 0 phma phma 2460 Mar 9 15:07 tone12-0.1.1-Source/riffwave.cpp -rw-r--r-- 0 phma phma 65 Mar 9 15:07 tone12-0.1.1-Source/config.h.in -rw-r--r-- 0 phma phma 2316 Mar 9 15:07 tone12-0.1.1-Source/midi.h -rw-r--r-- 0 phma phma 384 Mar 9 15:07 tone12-0.1.1-Source/CMakeLists.txt~ -rw-r--r-- 0 phma phma 2303 Mar 9 15:07 tone12-0.1.1-Source/midi.cpp -rw-r--r-- 0 phma phma 384 Mar 9 15:07 tone12-0.1.1-Source/CMakeLists.txt -rw-r--r-- 0 phma phma10551 Mar 9 15:07 tone12-0.1.1-Source/tonegen.cpp -rw-r--r-- 0 phma phma14625 Mar 9 15:07 tone12-0.1.1-Source/tone12.cpp~ -rw-r--r-- 0 phma phma 2322 Mar 9 15:07 tone12-0.1.1-Source/midi.h~ -rw-r--r-- 0 phma phma14625 Mar 9 15:07 tone12-0.1.1-Source/tone12.cpp -rw-r--r-- 0 phma phma 1455 Mar 9 15:07 tone12-0.1.1-Source/riffwave.h -rw-r--r-- 0 phma phma 4339 Mar 9 15:07 tone12-0.1.1-Source/tonegen.h Those should be tone12-0.1.1-Source/src/midi.h etc. How can I fix this? Pierre -- I believe in Yellow when I'm in Sweden and in Black when I'm in Wales. ___ 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] newbie q - where do I put what in which CMakeLists file? out of source build
On 03/09/2011 04:14 PM, Pierre Abbat wrote: On Wednesday 09 March 2011 05:19:42 Johannes Zarl wrote: configure_file(src/config.h.in config.h) In CMake, use of relative filenames is (mostly) discouraged. A robust way to do this would be to write: configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIRECTORY}/include/config.h ) include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY}/include ) I got it to work, typing cmake ../src and leaving ~/tone12/CMakeLists.txt empty. INCLUDE_DIRECTORIES has to be in all caps (at least I didn't see it add -I when I had it in lowercase) and it's CMAKE_CURRENT_BINARY_DIR (with ...DIRECTORY it tried to write to /include). I ran make package_source and get a tarball containing the following: -rw-r--r-- 0 phma phma 2460 Mar 9 15:07 tone12-0.1.1-Source/riffwave.cpp -rw-r--r-- 0 phma phma 65 Mar 9 15:07 tone12-0.1.1-Source/config.h.in -rw-r--r-- 0 phma phma 2316 Mar 9 15:07 tone12-0.1.1-Source/midi.h -rw-r--r-- 0 phma phma 384 Mar 9 15:07 tone12-0.1.1-Source/CMakeLists.txt~ -rw-r--r-- 0 phma phma 2303 Mar 9 15:07 tone12-0.1.1-Source/midi.cpp -rw-r--r-- 0 phma phma 384 Mar 9 15:07 tone12-0.1.1-Source/CMakeLists.txt -rw-r--r-- 0 phma phma10551 Mar 9 15:07 tone12-0.1.1-Source/tonegen.cpp -rw-r--r-- 0 phma phma14625 Mar 9 15:07 tone12-0.1.1-Source/tone12.cpp~ -rw-r--r-- 0 phma phma 2322 Mar 9 15:07 tone12-0.1.1-Source/midi.h~ -rw-r--r-- 0 phma phma14625 Mar 9 15:07 tone12-0.1.1-Source/tone12.cpp -rw-r--r-- 0 phma phma 1455 Mar 9 15:07 tone12-0.1.1-Source/riffwave.h -rw-r--r-- 0 phma phma 4339 Mar 9 15:07 tone12-0.1.1-Source/tonegen.h Those should be tone12-0.1.1-Source/src/midi.h etc. How can I fix this? Pierre Make the ~/tone12/CMakeLists.txt your main CMake file (i.e. put the project() command in there and all other commands that apply to the whole project) and add a add_subdirectory(src) call, and then call CMake with cmake .. instead. Also, the built-in commands, function and macro names are AFAIK case-insensitive since the 2.6 days. I always use include_directories(). 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] newbie q - where do I put what in which CMakeLists file? out of source build
On Wednesday 09 March 2011 10:22:50 Michael Wild wrote: Make the ~/tone12/CMakeLists.txt your main CMake file (i.e. put the project() command in there and all other commands that apply to the whole project) and add a add_subdirectory(src) call, and then call CMake with cmake .. instead. Doesn't work. config.h is in ~/tone12/build as before, but it says it can't find it, and with VERBOSE=1 it appears to be compiling the file into ~/tone12/src/, which shouldn't exist. The package contains everything in ~/tone12/build and lots of temporary files, which shouldn't be in a package. Pierre -- li ze te'a ci vu'u ci bi'e te'a mu du li ci su'i ze te'a mu bi'e vu'u ci ___ 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] newbie q - where do I put what in which CMakeLists file? out of source build
On 03/09/2011 05:54 PM, Pierre Abbat wrote: On Wednesday 09 March 2011 10:22:50 Michael Wild wrote: Make the ~/tone12/CMakeLists.txt your main CMake file (i.e. put the project() command in there and all other commands that apply to the whole project) and add a add_subdirectory(src) call, and then call CMake with cmake .. instead. Doesn't work. config.h is in ~/tone12/build as before, but it says it can't find it, and with VERBOSE=1 it appears to be compiling the file into ~/tone12/src/, which shouldn't exist. The package contains everything in ~/tone12/build and lots of temporary files, which shouldn't be in a package. Pierre Could you boil down your project to a minimal but complete example which demonstrates the issues with the header not being found and the files not being placed properly and post it here? Regards, 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] newbie q - where do I put what in which CMakeLists file? out of source build
On 03/09/2011 07:09 PM, Michael Hertling wrote: On 03/09/2011 05:54 PM, Pierre Abbat wrote: On Wednesday 09 March 2011 10:22:50 Michael Wild wrote: Make the ~/tone12/CMakeLists.txt your main CMake file (i.e. put the project() command in there and all other commands that apply to the whole project) and add a add_subdirectory(src) call, and then call CMake with cmake .. instead. Doesn't work. config.h is in ~/tone12/build as before, but it says it can't find it, and with VERBOSE=1 it appears to be compiling the file into ~/tone12/src/, which shouldn't exist. The package contains everything in ~/tone12/build and lots of temporary files, which shouldn't be in a package. Pierre Could you boil down your project to a minimal but complete example which demonstrates the issues with the header not being found and the files not being placed properly and post it here? Regards, Michael IMHO this is a typical case of someone being too lazy to RTFM, just trying to stumble his way through... Sorry for the harsh words, but you REALLY should type man cmake and read, read, read... 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] newbie q - where do I put what in which CMakeLists file? out of source build
On Wednesday 09 March 2011 13:09:39 Michael Hertling wrote: Could you boil down your project to a minimal but complete example which demonstrates the issues with the header not being found and the files not being placed properly and post it here? Here's an example of it compiling correctly, but making a package wrong: minimal.tar.gz . -bash-4.1$ cd build -bash-4.1$ cmake ../src -- The C compiler identification is GNU -- The CXX compiler identification is GNU snip -bash-4.1$ make Scanning dependencies of target readmidi [100%] Building CXX object CMakeFiles/readmidi.dir/midi.o Linking CXX executable readmidi [100%] Built target readmidi -bash-4.1$ ./readmidi Header, 6 bytes Track, 19 bytes Track, 655 bytes Track, 675 bytes Track, 1491 bytes Track, 1334 bytes -bash-4.1$ make package_source snip bash-4.1$ cd /tmp -bash-4.1$ tar xvzf ~/minimal/build/minimal-0.1.1-Source.tar.gz x minimal-0.1.1-Source/config.h.in x minimal-0.1.1-Source/midi.h x minimal-0.1.1-Source/CMakeLists.txt~ x minimal-0.1.1-Source/midi.cpp x minimal-0.1.1-Source/CMakeLists.txt x minimal-0.1.1-Source/midi.cpp~ For minimal2, follow the same steps except start with cmake ... The program doesn't compile; the package is rooted correctly, but contains contents of the build directory as well as the src directory. Pierre -- Jews use a lunisolar calendar; Muslims use a solely lunar calendar. minimal.tar.gz Description: application/tgz minimal2.tar.gz Description: application/tgz ___ 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] newbie q - where do I put what in which CMakeLists file? out of source build
Well if the build directory is *in* the source directory, then make package_source *should* include it. This is not a problem, but the expected behavior. If you don't want the build tree in the source tree, then don't put it there. On Wed, Mar 9, 2011 at 9:11 PM, Pierre Abbat p...@phma.optus.nu wrote: On Wednesday 09 March 2011 13:09:39 Michael Hertling wrote: Could you boil down your project to a minimal but complete example which demonstrates the issues with the header not being found and the files not being placed properly and post it here? Here's an example of it compiling correctly, but making a package wrong: minimal.tar.gz . -bash-4.1$ cd build -bash-4.1$ cmake ../src -- The C compiler identification is GNU -- The CXX compiler identification is GNU snip -bash-4.1$ make Scanning dependencies of target readmidi [100%] Building CXX object CMakeFiles/readmidi.dir/midi.o Linking CXX executable readmidi [100%] Built target readmidi -bash-4.1$ ./readmidi Header, 6 bytes Track, 19 bytes Track, 655 bytes Track, 675 bytes Track, 1491 bytes Track, 1334 bytes -bash-4.1$ make package_source snip bash-4.1$ cd /tmp -bash-4.1$ tar xvzf ~/minimal/build/minimal-0.1.1-Source.tar.gz x minimal-0.1.1-Source/config.h.in x minimal-0.1.1-Source/midi.h x minimal-0.1.1-Source/CMakeLists.txt~ x minimal-0.1.1-Source/midi.cpp x minimal-0.1.1-Source/CMakeLists.txt x minimal-0.1.1-Source/midi.cpp~ For minimal2, follow the same steps except start with cmake ... The program doesn't compile; the package is rooted correctly, but contains contents of the build directory as well as the src directory. Pierre -- Jews use a lunisolar calendar; Muslims use a solely lunar calendar. ___ 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