Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update conan v2 imports for main recipe #23

Merged
merged 21 commits into from
Sep 24, 2022
Merged

Conversation

paulocoutinhox
Copy link
Contributor

No description provided.

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
@prince-chrismc
Copy link
Contributor

Hmm the install is being ran from the log

can you confirm I understood?

🤔 your layout says the source and build are the current directory. But I dont see the cmake list there.

I think you might have missed pointing the layout to the correct locations

@prince-chrismc
Copy link
Contributor

@paulocoutinhox
Copy link
Contributor Author

paulocoutinhox commented Sep 22, 2022

Hi @prince-chrismc,

I tried this:

# -----------------------------------------------------------------------------
def layout(self):
    self.folders.root = os.path.join("..", "..")
    cmake_layout(self)

But in my case the command is executed from root:

python3 nativium.py target linux setup

It will run conan install inside build folder:

run_args = [
    "conan",
    "install",
    os.path.join(
        proj_path,
        "conan",
        "recipe",
        const.FILE_NAME_CONANFILE_PY,
    ),
    "-pr:b",
    build_profile,
    "-pr:h",
    os.path.join(
        proj_path, "conan", "profiles", arch["conan_profile"]
    ),
    "-s:h",
    "os.version={0}".format(arch["min_version"]),
]

target.add_target_setup_common_args(
    run_args, target_name, target_config, arch, build_type
)

run_args.append("--build=missing")
run_args.append("--update")
build_dir = os.path.join(
    proj_path,
    "build",
    target_name,
    build_type,
    arch["arch"],
    "conan",
)

It will install into "build/[...]/conan" folder without the cmake toolchain files for build.

And after, need run "build" target verb, that will build with my CMakeLists.txt and need pass/import the cmake file generated by setup command (this flow is correct for v2?):

python3 nativium.py target linux build

It is strange, because with a new project (conan new hello/0.1 -m=cmake_lib), it works and generate the correct files when i run conan install .:

image

@prince-chrismc
Copy link
Contributor

You should read the layout docs I linked above. The intro explains what it's trying to do... were pretty swamped so I am not sure I'll have time to checkout and play with this but I'll try to answer you questions.


You need to tell the recipe where to get information and where to put files. That's the role of layout.
The structure is really unique for your project. So the default is not enough.

I would suggest manually setting up the layout. Set all the properties the same way you building framework does.

I am not sure how you are using the template from conan new but if you more the files you'll see things break.

Please push the code so I can see the logs 🙏 or post the error message.

@paulocoutinhox
Copy link
Contributor Author

paulocoutinhox commented Sep 22, 2022

Hi @prince-chrismc, i have a lot of questions rsrsrsrs

In my case, i only use conan for dependencies and not for build my full project. The conanfile.py is only to generate the .cmake to be imported into my CMakeLists.txt because of dependencies. And at least i link with all conan installed libs:

target_link_libraries(${NATIVIUM_PROJECT_NAME} "${CONAN_LIBS}")

Current questions:

1 - Current project generate file conanbuildinfo.cmake that i include in my cmake (using generators = "cmake"). This is not possible more?
2 - If number 1 is NO, what is correct way to use CMake?

@prince-chrismc
Copy link
Contributor

That's a fair point!

conan-io/conan-io.github.io#222 I call out a few things in that blog

The new CMakeToolchain generator use the cmake toolchain mechanism 😆 https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html that's how cmake knows to use the config files from Conan and a few other important settings

You should remove everything Conan specific from your cmake and use modern cmake to link your dependencies

@paulocoutinhox
Copy link
Contributor Author

paulocoutinhox commented Sep 22, 2022

@prince-chrismc i call you on google chat...here is too slow... or we can talk on slack

I defined my layout vars:

def layout(self):
    generators_dir = os.path.join(
        "build",
        self.options.get_safe("nativium_target").value,
        self.options.get_safe("nativium_build_type").value,
        self.options.get_safe("nativium_arch").value,
        "conan",
    )

    build_dir = os.path.join(
        "build",
        self.options.get_safe("nativium_target").value,
        self.options.get_safe("nativium_build_type").value,
        self.options.get_safe("nativium_arch").value,
        "target"
    )

    self.folders.root = os.path.join("..", "..")
    self.folders.source = "."
    self.folders.build = build_dir
    self.folders.generators = generators_dir

    cmake_layout(self)

1 - When i call conan install the generators are generated in build/generators instead of my generators folder above.

image

2 - A file called CMakeUserPresets.json is always generated on root, it is necessary?

3 - The folder "source", "build", "generators" is appended to "root" folder, correct?

@prince-chrismc
Copy link
Contributor

I'll slack you an appointment slot in the AM :) we can do a zoom hopefully before I leave

My night is your morning but should work nicely

@paulocoutinhox
Copy link
Contributor Author

My english speak is bad, im BR ... i think that is better something to write rsrsrsrsrsrs There is any option?

Im "Paulo Coutinho" on slack "Cpplang".

@paulocoutinhox
Copy link
Contributor Author

@prince-chrismc i discover the problem after debug conan code.

I set all the folder but when i call "cmake_layout(self)", it change all the folder. Example:

def cmake_layout(conanfile, generator=None, src_folder=".", build_folder="build"):
    [...]
    build_folder = build_folder if not subproject else os.path.join(subproject, build_folder)
    custom_conf = get_build_folder_custom_vars(conanfile)
    if custom_conf:
        build_folder = os.path.join(build_folder, custom_conf)

    if multi:
        conanfile.folders.build = build_folder
    else:
        conanfile.folders.build = os.path.join(build_folder, build_type)

    conanfile.folders.generators = os.path.join(build_folder, "generators")
    [...]

Basically, i cant change it.

@paulocoutinhox
Copy link
Contributor Author

@prince-chrismc I created a project to test and understand the details and it appear to work now:
https://github.com/paulocoutinhox/conan-cmake-v2

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (1baf365) compared to base (a095b35).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #23   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           13        13           
=========================================
  Hits            13        13           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@paulocoutinhox paulocoutinhox merged commit 96286a2 into main Sep 24, 2022
@paulocoutinhox paulocoutinhox deleted the recipe-conan-v2 branch September 24, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants