neutronimaging / imagingsuite

Sources for imaging related tools
GNU General Public License v3.0
18 stars 9 forks source link

Build Problem: Wrong generator flag #668

Closed vlocateli closed 1 month ago

vlocateli commented 2 months ago

Hello, I'm currently having a problem to build it on Linux (Kubuntu 22.04 LTS) Error message:

CMake Error at /usr/share/cmake-3.22/Modules/FindHDF5.cmake:241 (try_compile):
  Unknown extension ".c" for file

    /home/victor/Documentos/IC/img-suite-damski/imaging-suite-new/imagingsuite/CMakeFiles/hdf5/cmake_hdf5_test.c

  try_compile() works only for enabled languages.  Currently these are:

    CXX

  See project() command to enable other languages.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindHDF5.cmake:596 (_HDF5_test_regular_compiler_C)
  CMakeLists.txt:57 (find_package)

Steps to reproduce: I changed the following lines in CMakeLists.txt:

find_package(Armadillo REQUIRED) # changed from armadillo to Armadillo because it couldnt find Armadillo
find_package(pybind11 REQUIRED)
find_package(LibXml2 REQUIRED) # same for LibXml 
find_package(BLAS REQUIRED) # here also
find_package(TIFF REQUIRED)
find_package(FFTW3 REQUIRED)
find_package(Fitsio REQUIRED) # here also 
find_package(ZLIB REQUIRED)
find_package(HDF5 REQUIRED) 

and added the following file FindFFTW3.cmake; so it could find FFTW3 library.

From what I've seen, it probably because its a C file being compiled as a CXX file: https://stackoverflow.com/questions/37931068/tell-cmake-to-use-c-compiler-for-c-files-coming-from-cmake

Thanks.

anderskaestner commented 2 months ago

Did you use Conan to fetch the dependencies? It is in the build instructions.


Paul Scherrer Institute Dr. Anders Kaestner Scientist, Applied Materials Group Laboratory for Neutron Scattering and Imaging (LNS) WBBA 110 CH-5232 Villigen PSI Switzerland

Phone: +41 56 310 42 86 Fax: +41 56 310 31 31 email: @.*** web: http://www.psi.ch/lns http://www.psi.ch/niag

On 3 May 2024, at 16:21, Victor Locateli @.***> wrote:

Hello, I'm currently having a problem to build it on Linux (Kubuntu 22.04 LTS) Error message:

CMake Error at /usr/share/cmake-3.22/Modules/FindHDF5.cmake:241 (try_compile): Unknown extension ".c" for file

/home/victor/Documentos/IC/img-suite-damski/imaging-suite-new/imagingsuite/CMakeFiles/hdf5/cmake_hdf5_test.c

try_compile() works only for enabled languages. Currently these are:

CXX

See project() command to enable other languages. Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FindHDF5.cmake:596 (_HDF5_test_regular_compiler_C) CMakeLists.txt:57 (find_package)

Steps to reproduce: I changed the following lines in CMakeLists.txt:

find_package(Armadillo REQUIRED) # changed from armadillo to Armadillo because it couldnt find Armadillo find_package(pybind11 REQUIRED) find_package(LibXml2 REQUIRED) # same for LibXml find_package(BLAS REQUIRED) # here also find_package(TIFF REQUIRED) find_package(FFTW3 REQUIRED) find_package(Fitsio REQUIRED) # here also find_package(ZLIB REQUIRED) find_package(HDF5 REQUIRED)

and added the following file FindFFTW3.cmake; so it could find FFTW3 library.

From what I've seen, it probably because its a C file being compiled as a CXX file: https://stackoverflow.com/questions/37931068/tell-cmake-to-use-c-compiler-for-c-files-coming-from-cmake

Thanks.

— Reply to this email directly, view it on GitHubhttps://github.com/neutronimaging/imagingsuite/issues/668, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACVIDXCUEZO3W2WBPTHNGLLZAOMPTAVCNFSM6AAAAABHFTR64GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TONZYG4YTINQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

vlocateli commented 1 month ago

I used this conan command from github actions:

 conan install . --profile:host profiles/linux_gcc_11_release --profile:build profiles/linux_gcc_11_release

My CMake version is 3.22.1 so I can only use this command:

cmake . -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/user/vboxuser/Documents/IC/build-imagingsuite/Release/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release

but I get the same error.

damskii9992 commented 1 month ago

Hello Victor It appears your build is failing because it does not get the conan dependencies right, the find_package calls should not need to be changed, as they are defined according to their consumption instructions on conancenter.

Your build is currently getting the wrong find files which results in the wrong libraries being found on your system. It should be using config files, such as armadillo-config.cmake to find packages, rather than findArmadillo.cmake.

Try to build in an isolated environment if you're not already doing that and remove the -G flag from the cmake call, as I don't believe Unix Makefiles is the generator that is actually being used as default by Conan in this case :)

vlocateli commented 1 month ago

Hello. I could compile it now! But I'm having a problem to run it. :)

Do you think it's better to open a new issue or can I still use it here?

Thanks.

damskii9992 commented 1 month ago

Better open a new issue, as the problem is likely of a different nature. I will rename and close this one as completed.