Relative paths include in cmake

I’m trying to run my Native C++ project on Android Studio and i need to compile my C++ part using cmake.

I need to use this repository for reading json:

https://github.com/nlohmann/json

NOTE: Using it with this command is not my intention and I cannot use this solution:

find_package(nlohmann_json 3.11.3 REQUIRED)

I have to use the whole repo code in my project.

My problem is that when I try to build it I get the follwing error:

C:/Users/XXXXXXXXXX/AndroidStudioProjects/nav/app/src/main/cpp/nlohmann/json.hpp:34:10:fatal error: 'nlohmann/adl_serializer.hpp' file not found #include <nlohmann/adl_serializer.hpp>

The adl_serializer.hpp file is there 100%. The problem is that i call this include from nlohmann/json.hpp which already is in the nlohmann directory and therefore I think it is looking for something like nlohmann/nlohmann/adl_serializer.hpp.

I already tried to update my cmake:

cmake_minimum_required(VERSION 3.22.1)
project(nav)

set(djinni_dir ../../../../djinni)
# Path to djinni support-lib code
set(support_dir ${djinni_dir}/djinni-support-lib/djinni/jni)
# Path to Djinni-generated files
set(DJINNI_GENERATED_SRC_DIR "${CMAKE_SOURCE_DIR}/../../")
# Path to the nlohmann directory for JSON read
set(NLOHMANN_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/nlohmann")
# Path to the generated code and our own c++ implementations
set(include_dirs
        ${DJINNI_GENERATED_SRC_DIR}/cpp
        ${DJINNI_GENERATED_SRC_DIR}/jni
        ${NLOHMANN_INCLUDE_DIR}
)

# Djinni support code that need to be compiled
file(
        GLOB_RECURSE support_srcs
        ${support_dir}/*.cpp)

# Collect all generated and source files
file(GLOB_RECURSE lib_srcs
        ${DJINNI_GENERATED_SRC_DIR}/cpp/*.cpp
        ${DJINNI_GENERATED_SRC_DIR}/jni/*.cpp
)

# All the implementation files that make up our library
set(complete_srcs ${support_srcs} ${lib_srcs})

add_library( # Sets the name of the library.
        navigator

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp
        nav.cpp

        ${complete_srcs})

target_include_directories(
        navigator
        PUBLIC
        ${include_dirs}
        ${support_dir})

find_library( # Sets the name of the path variable.
        log-lib
        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

target_link_libraries( # Specifies the target library.
        navigator
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

and tried changing this line:

set(NLOHMANN_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/nlohmann")

for that:

set(NLOHMANN_INCLUDE_DIR "${CMAKE_SOURCE_DIR}")

But it doesn’t solve my case.

Another issue is that I probably shouldn’t use <> instead of “” around #includes, but changing this now didn’t solve my problem as well.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật