[CMake] Preventing add_custom_command from removing output
Hi, I have a source file (version.cpp) I need to generate trough a script. What the script does is - generate a version.cpp.new file - if version.cpp does not exists or is different from version.cpp.new, copy version.cpp.new into version.cpp --- add_custom_command(OUTPUT version.cpp always COMMAND bash -x ${CMAKE_SOURCE_DIR}/tools/dev/gen_version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.cpp ) set_source_files_properties(version.cpp PROPERTIES GENERATED TRUE) - the 'always' target is here to make sure the script is alway called (in case the version changed). Unfortunately, it seems that add_custom_command will delete its output before calling the command. As a result the version.cpp's dependancies are always bult. Is there a way to prevent that deletion ? Thanks -- - Alain Miniussi DSI, Pôles Calcul et Genie Log. Tél. : +33492003009 (Mont-Gros) Tél. : +33483618544 (Sophia Antipolis) -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] CMakeLists.txt location
On 13/09/2017 12:49, Nils Gladitz wrote: [...] Do you have a minimal reproducible example for that behaviour? e.g. given: cmake_minimum_required(VERSION 2.8.0) project(Foo NONE) file(WRITE foo/CMakeLists.txt "add_executable()") add_subdirectory(foo) I get: CMake Error at foo/CMakeLists.txt:1 (add_executable): add_executable called with incorrect number of arguments Even with the oldest CMake version currently available to me (2.8.0). That test case works for me too. But my real case does not. I think it would be tricky to minimized, what is failling is the second run of cmake, after a modification in the build system or in a configure_file source. CMake Error at CMakeLists.txt:14 (add_executable): Target "cmTC_60ee6" links to item " -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker /opt/software/common/intel/impi/2017.0.098/intel64/lib/release_mt -Xlinker -rpath -Xlinker /opt/software/common/intel/impi/2017.0.098/intel64/lib -Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib/release_mt -Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib /opt/software/occigen/libraries/boost/1_63_0/intel/17.0/intelmpi/2017.0.098/lib/libboost_serialization.a" which has leading or trailing whitespace. This is now an error according to policy CMP0004. CMake Error: Internal CMake error, TryCompile generation of cmake failed INFO Boost MPI not available or too old: Now, maybe the problem is with a CMakeLists.tx generated by a try_compile. Indicating that I would actually need the location of the try_compile. Thanks Alain Nils -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] CMakeLists.txt location
On 13/09/2017 11:16, Nils Gladitz wrote: On 13.09.2017 10:52, Alain Miniussi wrote: Hi, Is there a way, when printing CMake error, to get the exact location of the CMakeLists.txt ? For example, right now, when I have: CMake Error at CMakeLists.txt:14 (add_executable): I need to scan all my CMakeLists.txt (~200) to check which one has add_executable at line 14. CMake includes the (relative to the root source directory) path for me e.g.: CMake Error at Source/CMakeLists.txt:4 (add_executable): Well, it never did for me: $grep add_executable CMakeLists.txt $ Alain -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] CMakeLists.txt location
Hi, Is there a way, when printing CMake error, to get the exact location of the CMakeLists.txt ? For example, right now, when I have: CMake Error at CMakeLists.txt:14 (add_executable): I need to scan all my CMakeLists.txt (~200) to check which one has add_executable at line 14. Thanks Alain -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] CMAKE_MODULE_PATH ignored
Hi, I am trying to fix FindHDF5.cmake (support for HDF5_ROOT is broken, only environment variable is supported and it will be eventually probably ignored in find_program). To that end, I'd like to copy it in my source tree and use that version instead of the one in /usr/shared/cmake. According to the documentation, all I have to do is to indicate the search directory for the FindXXX.cmak files through CMAKE_MODULE_PATH. From the cmake --trace: /../trunk/CMakeLists.txt(49): message(status CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH} ) ## This is the correct PATH, containing the FindHDF5.cmake file status CMAKE_MODULE_PATH: /scratch/alainm/view/seiscope/codes/3D_Acoustic/FFWI/trunk/tools/build/ ## Next line: /.../trunk/CMakeLists.txt(50): find_package(HDF5 COMPONENTS CXX Fortran ) ## Wrong path selected: /usr/share/cmake/Modules/FindHDF5.cmake(63): include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake ) How do I tell cmake I want *my* path to be selected ? Thanks -- --- Alain -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] CMAKE_MODULE_PATH ignored
On 08/02/2016 18:43, Alain Miniussi wrote: Hi, I am trying to fix FindHDF5.cmake (support for HDF5_ROOT is broken, only environment variable is supported and it will be eventually probably ignored in find_program). To that end, I'd like to copy it in my source tree and use that version instead of the one in /usr/shared/cmake. According to the documentation, all I have to do is to indicate the search directory for the FindXXX.cmak files through CMAKE_MODULE_PATH. From the cmake --trace: /../trunk/CMakeLists.txt(49): message(status CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH} ) ## This is the correct PATH, containing the FindHDF5.cmake file status CMAKE_MODULE_PATH: /scratch/alainm/view/seiscope/codes/3D_Acoustic/FFWI/trunk/tools/build/ ## Next line: /.../trunk/CMakeLists.txt(50): find_package(HDF5 COMPONENTS CXX Fortran ) ## Wrong path selected: /usr/share/cmake/Modules/FindHDF5.cmake(63): include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake ) How do I tell cmake I want *my* path to be selected ? Thanks Renaming FindHDF5.cmake in FindH5.cmake (or whatever is not present in the global cmake install) helps, but then I also need to replicate all dependencies (FindPackageMessage.cmake, SelectLibraryConfigurations.cmake...), shouldn't cmake look in the /usr/shar/cmake/... for those ? Thanks Alain -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] try_compile, again
Hi, I tried using try_compile, and, as usual, fail to understand how it's supposed to work (2.8.12). The documentation says: Some extra flags that can be included are, INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. but does not mention where they can be included (none of the two mentioned form indicate those flags). I tried putting "INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}" just after the CMAKE_FLAGS., but it is just ignored. Also: COMPILE_DEFINITIONS are -Ddefinition that will be passed to the compile line. but that seems incorrect (which is good) as I can use them to pass "-std=c++11" which is not a -D option (and I don't know how I could pass that option otherwise). Thanks -- --- Alain -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] FindMPI
On 11/09/2015 10:53, Nico Schlömer wrote: Hi everyone, I see from the CMake docs [1] that the recommended way for using MPI is to call `find_package(MPI)` and set the linker and include flags appropriately. On the other hand, I see from the OpenMPI specs [2] that > The Open MPI team *strongly* recommends that you simply use Open MPI's > "wrapper" compilers to compile your MPI applications. Is there a way to reconcile these two approaches? I'm still not sure why those wrappers are provided, except that MPI is mostly used in HPC, where code is often written by people with little engineering background who can't always be trusted for setting compilation and link flags. I guess it saves them a lot of support ? The two approaches have theirs draw back, including: Using the wrappers: -Not all MPI implementations have wrappers. - Some implementations do not call the underlying compiler you would expect, meaning you might have to set a sub standard env var to select it. (Intel's mpicc calls gcc by default, not icc, you need to use mpiicc (not a standard name) or set some var or ..) - You might need to mix with another tool which also provides its own "helpful" wrapper. Using CMake to detect the MPI stuff: - depending on the cmake version and implementations, can be a PITA. MPI relies on the presence of some flags in the (sometime non-existing) wrapper (-show...) which are not always present, or are present but won't behave as expected, or maybe are not present but won't dare reporting it properly in order not to hurt the feeling of pre-existing build system too harshly (provided I understood Intel's explanation). Most of the time, I use FindMPI which I feed explicitly with compile and link flags... which feel weird. Cheers Alain Cheers, Nico [1] http://www.cmake.org/cmake/help/v3.0/module/FindMPI.html [2] https://www.open-mpi.org/faq/?category=mpi-apps#general-build -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] No rule to build mod file
Hi, I am experiencing a problem related with dependencies on fortran mod files. Basically, the make -j it's failing with: make[2]: *** No rule to make target `dsfdm3d/inc/modacqui.mod', needed by `dsfdm3d/src/CMakeFiles/dsfdm_sp-exe.dir/main.f90.o'. Stop. mod file are generated as a side effect of source file compilation, so a file A.f90 using a mod B.mod must be compiled after the file producing the module (say B.f90). cmake seems to be able to convert those constraints in terms of build order (that is, B.f90 will be compiled before A.f90) and insert a dependency from A.f90 to B.mod. But sinces there are no specific rule to build B.mod, a full parallel build will fail on the dependencies. That is, before building anything, make will detect that A.f90 depends on a non existing file (yet) and fail to see that the compilation of B.f90 would have produced the file. For some reason, the problem seems to appears only if I build an executable (from A.f90) and have many files suc a B.f90 used to build a library. When building with a simple 'make' everything is okay (I guess because the build order is good), the problem only appears with make -j. I have the problem with cmake 3.1.0-rc1 and 2.8.12.2 the CMakeLists.txt looks like: add_library(somelib OBJECT [some 52 source files.f90 ) set_target_properties(somelib PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../inc) set_target_properties(somelib PROPERTIES COMPILE_FLAGS compile flags) add_executable(exe main.f90 $TARGET_OBJECTS:somelib) set_target_properties(exe PROPERTIES COMPILE_FLAGS compile flags) add_dependencies(exe somelib) Is this something expected ? Thanks -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake