ROOT component Fitsio not found when building with cmake

Dear rooters,

I use the following CMakeLists.txt to build a project whose only dependency is root.
If I use the -DUSE_FITISO=ON option when building the project I add Fitsio to the required components for ROOT, in the project’s CMakeLists.txt I added:

# load ROOT libraries, define a cache variable to enable FITSIO support 
# if USE_FITSIO is selected, Fitsio is added to the ROOT requirements   
set(ROOT_REQUIRED_COMPONENTS Minuit)
option(USE_FITSIO "Enable support for FITS files I/O" OFF)                      
if(USE_FITSIO)                     
    list(APPEND ROOT_REQUIRED_COMPONENTS Fitsio)
endif()   
find_package(ROOT REQUIRED ${ROOT_REQUIRED_COMPONENTS})
message("-- Required ROOT components are: ${ROOT_REQUIRED_COMPONENTS}")

Now the problem is that this component is not found, when building I get:

(root_v6-22-6) cosimo@posimo:~/work/gLike/build$ cmake ../ -DUSE_FITSIO=ON
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /home/cosimo/software/miniconda3/envs/root_v6-22-6/bin/x86_64-conda-linux-gnu-cc
-- Check for working C compiler: /home/cosimo/software/miniconda3/envs/root_v6-22-6/bin/x86_64-conda-linux-gnu-cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/cosimo/software/miniconda3/envs/root_v6-22-6/bin/x86_64-conda-linux-gnu-c++
-- Check for working CXX compiler: /home/cosimo/software/miniconda3/envs/root_v6-22-6/bin/x86_64-conda-linux-gnu-c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /home/cosimo/software/miniconda3/envs/root_v6-22-6/cmake/ROOTConfig.cmake:159 (message):
  ROOT component Fitsio not found
Call Stack (most recent call first):
  CMakeLists.txt:17 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/cosimo/work/gLike/build/CMakeFiles/CMakeOutput.log".

Fitsio is not found despite ROOT has been successfully compiled with it

(root_v6-22-6) cosimo@posimo:~/work/gLike/build$ root-config --has-fitsio
yes

I get the same error both if I manually compile root or if I use the root provided with conda.
Am I mistaking the name of the component?

Any help is highly apprectiated,
Thanks a lot!
Cosimo

ROOT Version: 6.22.06
Platform: Ubuntu (18.04 and 20.04)

Hi,
I think you are telling ROOT to use fitsio but you don’t have it installed in your system, so you also need -Dbuiltin_cfitsio=ON to tell ROOT to build it itself.

Does that help?
Cheers,
Enrico

Thanks @eguiraud,

I did compile ROOT with builtin_cfitsio=ON. This is the line I use to build it

cmake -S /soft/root/source/root -Dmathmore=ON -Dminuit2=ON -Dbuiltin_cfitsio=ON

had I not specified that root-config --has-fitsio should have returned no. Right?

I get the same error both if I manually compile root or if I use the root provided with conda.

Also the root available with miniconda has already fitsio extension available, if I am not wrong.

Thanks.

Ah I see, I misunderstood. So you are sure your ROOT has fitsio, but a find_package(ROOT REQUIRED Fitsio) in your project that depends on ROOT fails with ROOT component Fitsio not found anyway.

@oshadura any idea?

So you are sure your ROOT has fitsio, but a find_package(ROOT REQUIRED Fitsio) in your project that depends on ROOT fails with ROOT component Fitsio not found anyway.

That’s exactly it!

Thanks,
Cosimo

Check the ROOT’s targets in your own “ROOTConfig-targets*.cmake” import files (e.g., it’s “FITSIO”, not “Fitsio”).

Please try find_package(ROOT REQUIRED ROOT::FITSIO)

Thank you both @Wile_E_Coyote, @oshadura, it actually worked with find_package(ROOT REQUIRED FITSO), not with find_package(ROOT REQUIRED ROOT::FITSIO).
Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.