I have a conda environment where I have installed: cmake, cxx-compiler, make and boost. I want to compile a program I wrote. It works fine if I use the systems compiler but I want to create a conda package using conda-build, where I am having the same problem I have in the normal conda environment. The compiler doesn't find the boost header file:
fatal error: boost/program_options.hpp: No such file or directory
10 | #include <boost/program_options.hpp>
I use CMake and it does find boost:
cmake -S . -B build
-- The CXX compiler identification is GNU 12.3.0
[...]
Found Boost: /home/username/miniforge3/envs/devel/lib/cmake/Boost-1.84.0/BoostConfig.cmake (found suitable version "1.84.0", minimum required is "1.74") found components: system program_options iostreams unit_test_framework
[...]
using this setup in the CMakeLists.txt:
FIND_PACKAGE(Boost 1.74 REQUIRED COMPONENTS system program_options iostreams unit_test_framework)
target_include_directories(my_exectuable
SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}
)
However when running the build step:
cmake --build build
[...]
fatal error: boost/program_options.hpp: No such file or directory
10 | #include <boost/program_options.hpp>
compilation terminated.
If I change to install gxx instead of cxx-compiler then compilation works also fine (but bioconda recipes requires cxx-compiler) so that isn't a solution.
I had a look at existing bioconda recipes and tried different setups where $PREFIX is passed on to CMake but I have always the same result.
The problem was caused by the following line in CMakeLists.txt:
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wunused -pedantic")
Changing it to
add_compile_options(-Wall -Wextra -Wpedantic)
solved the problem.
I assume the the cxx-compiler package sets some specific flags which were overwritten.