Re: [CMake] Multiple occurrences of a library on linux (ldd)
Thiago, I haven’t see the double entry pattern that you mention below. However, you might want to tell CMake to embed a BUILD_RPATH in your libraries. This should get around the issue of manually setting LD_LIBRARY_PATH. https://cmake.org/cmake/help/latest/prop_tgt/BUILD_RPATH.html?highlight=rpath -kt From: CMake On Behalf Of Thiago Crepaldi Sent: Thursday, February 14, 2019 12:43 AM To: cmake@cmake.org Subject: [CMake] Multiple occurrences of a library on linux (ldd) Hello all, After reading CMake Cookbook I have written my first "complex" CMake build script based on the superbuild pattern. I am excited to heave a better understanding on CMake, but I definitely will learn much more from experience and your kind help. In summary, the standalone google test application `standalone_gtests` publicly links to `libdatareader.so` and to pytorch libraries (`libc10.so`,`libcafee2.so`, `libtorch.so`). `libdatareader.so` also publicly links to pytorch libraries (I have a theoretical question on why `standalone_gtests` had to link to pytorch libraries if `libdatareader.so` already did, but that can wait). Compilation finishes successfully, but when I try to run `standalone_gtests`, it aborts because it cant find `libc10.so`. After executing `ldd standalone_gtests`, the weird result was that there were two entries for `libc10.so`. The first one maps to "not found" while the second had the correct path to the library. `libcaffe2.so`, which is also a pytorch library, has a single occurrence with full path. If I add the (...)/pytorch_external/(...) (see ldd output below) path to LD_LIBRARY_PATH, then everything works, but I would like to avoid this, if possible. `ldd ./subprojects/Build/datareaders_core_test/standalone_gtests libdatareader.so => /home/dev/miniconda3/datareaders_py37/build/stage/datareader/lib/libdatareader.so libcaffe2.so => /home/dev/miniconda3/datareaders_py37/build/subprojects/Source/pytorch_external/torch/lib/libcaffe2.so libc10.so => not found libc10.so => /home/dev/miniconda3/datareaders_py37/build/subprojects/Source/pytorch_external/torch/lib/libc10.so (...)` Have anyone seen multiple entries for the same library on ldd before? Why is that? Is it because `standalone_gtests` links to libc10.so and to `libdatareader.so`, which in turn also links to `libc10.so`? Both CMakeLists.txt (libdatareader and standalone_gtests) succeeds at find_package(Torch REQUIRED QUIET) commands (${TORCH_LIBRARY} returns the correct path). I run the same build on my Mac and everything works fine, so that is confined to linux environment. I have destroyed my conda environment and performed multiple clean builds in the process and no luck :( Hoping this was some sort of ldconfig issue, I tried `sudo ldconfig` and `sudo rm /etc/ld.so.cache`, but that doesn't fix it. Any ideas? best regards, Thiago -- 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] How to specify gfortran in an MSVC project
Hi Stephen, I am also interested in Kitware's response to your question. I don't use Qt Creator, but I help maintain several projects that use Visual Studio and MinGW gfortran via the CMakeAddFortranSubdirectory feature. This feature is somewhat limited and not really maintained (in my experience). Background: In my case, I use a heavily modified version of CMakeAddFortranSubdirectory that supports Xcode builds in addition to MSVC. I also have dependencies of the form mycpp.exe -> myf90.lib -> mycpp.lib -> msmpi.lib that standard CMakeAddFortranSubdirectory doesn't know how to deal with. When I run the 'build' target via Visual Studio, the Fortran compiler is discovered by CMakeAddFortranSubdirectory only if gfortran.exe is in %PATH% (via find_program -- I believe that the default code only supports the name 'gfortran.exe'.) You might need to add C:/Qt/Tools/mingw730_64/bin/ to your local path before running cmake for the project. I have found that CMakeAddFortranSubdirectory isn't flexible. You may need modify it for your own needs. -kt From: CMake on behalf of Stephen Morris Sent: Sunday, January 13, 2019 6:14:33 PM To: cmake@cmake.org Subject: [CMake] How to specify gfortran in an MSVC project I would like to try to use 64-bit gfortran to compile a project in which the rest of the code is compiled with Visual C++ 2017. I’ve read the netlib article (http://www.netlib.org/lapack/lawnspdf/lawn270.pdf) but it doesn’t address my problem, which is how to help CMake select the right Fortran compiler. The CMakeLists.txt file is launched from within Qt Creator. My CMakeLists.txt file (which I’ve tested thoroughly using gfortran in Linux and MinGW gfortran on Windows) begins: cmake_minimum_required(VERSION 3.12) project(myProj LANGUAGES Fortran) ...and if I set Qt Creator to parse it with the MSVC compiler option selected, the output is: Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.9.7/msvc2017_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.9.7/msvc2017_64/bin/qmake.exe". The Fortran compiler identification is unknown CMake Error at CMakeLists.txt:2 (project): No CMAKE_Fortran_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. Fair enough; here’s my second attempt: cmake_minimum_required(VERSION 3.12) set(CMAKE_Fortran_COMPILER "C:/Qt/Tools/mingw730_64/bin/gfortran.exe") project(myProj LANGUAGES Fortran) ...and this gives me: Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.9.7/msvc2017_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.9.7/msvc2017_64/bin/qmake.exe". The Fortran compiler identification is unknown Check for working Fortran compiler: C:/Qt/Tools/mingw730_64/bin/gfortran.exe CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_Fortran_PREPROCESS_SOURCE CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestFortranCompiler.cmake:30 (try_compile): Failed to generate test project build system. Call Stack (most recent call first): CMakeLists.txt:3 (project) In place of the “set(CMAKE_Fortran_COMPILER...” line I’ve also tried set($ENV{FC} "C:/Qt/Tools/mingw730_64/bin/gfortran.exe") ...which gave me the error message Could not find compiler set in environment variable FC: CMAKE_Fortran_COMPILER-NOTFOUND ..and set($ENV{FC} "C:/Qt/Tools/mingw730_64/bin") ... which gave me exactly the same error as I got in the first case. So what am I doing wrong here? -- 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: h
Re: [CMake] How to produce a -config.cmake file
Matthieu, I think are asking about the CMakePackageConfigHelpers CMake module (https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html) that defines the macro 'configure_package_config_file'. You can probably find several tutorials or examples by searching github or stackoverflow, etc. for 'CMakePackageConfigHelpers'. It is also covered in some detail in the e-book "Professional CMake" by Craig Scott (requires a purchase). -kt From: CMake On Behalf Of Dorier, Matthieu Sent: Thursday, September 27, 2018 2:42 AM To: cmake@cmake.org Subject: [CMake] How to produce a -config.cmake file Hi, I'm using cmake to build a library (damaris). Once installed, I would like users to be able to find it and its dependencies using find_package(damaris). If I understand correctly, the way to do that is to have cmake create and install a "damaris-config.cmake" file. Is there a tutorial somewhere on how to do that? Here is some more information: the library depends on - Boost (using the default FindBoost.cmake installed with cmake) - XercesC (using a custom FindXercesC.cmake located in my source tree) - XSD (using a custom FindXSD.cmake as well) Additionally, it may have been built with the following optional dependencies: - CppUnit (using a custom FindCppUnit.cmake) - HDF5 (using the default FindHDF5.cmake shipped with cmake) - VisIt (using a custom FindVisIt.cmake) - ParaView (relying on the ParaViewConfig.cmake produced when installing ParaView). Thanks, Matthieu -- 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