Trying to run a project for an example Oat++ framework using Conan (in particular by running the cmake --build command. --config Release), I have a problem opening Conan inclusion files:
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
1>Checking Build System
Building Custom Rule C:/Users/h4thq/prjcts/oat2/oatpp-starter/CMakeLists.txt
MyController.cpp
C:\Users\h4thq\prjcts\oat2\oatpp-starter\src\dto\DTOs.hpp (4.10): error C1083: Cannot open file-enable: oatpp/
macro/codegen.hpp: No such file or directory, [C:\Users\h4thq\prjcts\oat2\oatpp-starter\build\my-project-lib.vcxproj]
Actions performed:
conan install . --output-folder=build --build=missing
cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
cmake --build. --config Release
This is where the error appears.(
conanfile.txt:
[requires]
oatpp/1.3.0
[generators]
CMakeToolchain
CMakeDeps
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
set(project_name my-project)
project(${project_name})
add_library(${project_name}-lib
src/AppComponent.hpp
src/controller/MyController.cpp
src/controller/MyController.hpp
src/dto/DTOs.hpp
)
## link libs
find_package(oatpp CONFIG REQUIRED)
target_link_libraries(${project_name}-lib PUBLIC oatpp::oatpp)
target_include_directories(${project_name}-lib PUBLIC src)
## add executables
add_executable(${project_name}-exe
src/App.cpp
test/app/MyApiTestClient.hpp
)
target_link_libraries(${project_name}-exe ${project_name}-lib)
add_dependencies(${project_name}-exe ${project_name}-lib)
add_executable(${project_name}-test
test/tests.cpp
test/app/TestComponent.hpp
test/app/MyApiTestClient.hpp
test/MyControllerTest.cpp
test/MyControllerTest.hpp
)
target_link_libraries(${project_name}-test ${project_name}-lib)
add_dependencies(${project_name}-test ${project_name}-lib)
set_target_properties(${project_name}-lib ${project_name}-exe ${project_name}-test PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
)
enable_testing()
add_test(project-tests ${project_name}-test)
The structure of the OATTP_STARTER project is:
./build
./src
./test
CMakeLists.txt
conanfile.txt
In catalogs ./src and ./test have other directories and project files.
Your build steps and configuration are correct, no doubt.
Your error is because your source files can not find codegen.hpp
.
Checking both the Conan recipe and upstream, we can find that header file in a different path:
So, you should update your source files to include the correct path:
#include "oatpp/core/macro/codegen.hpp"
The folder core
is missing in your original code.