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

CMake: project() problem (with PROJECT_NAME et al.) in subprojects (IDFGH-1321) #3611

Closed
viettrungluu opened this issue Jun 11, 2019 · 1 comment

Comments

@viettrungluu
Copy link

Environment

  • IDF version (run git describe --tags to find it):
    [latest version on master] 2c55fae
  • Build System: CMake
  • Operating System: Linux

Problem Description

In CMake, after a project() in a subproject (added via add_subdirectory()), PROJECT_NAME (and PROJECT_VERSION, etc.) are not set correctly.

I'm happy that the newer versions try to restore project(); however, something's not right.

Suppose you modify the hello_world's top-level CMakeLists.txt to::

# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hello-world)

add_subdirectory(foo)

and you make a foo/CMakeLists.txt file:

cmake_minimum_required(VERSION 3.5)

project(foo)
message("PROJECT_NAME = " ${PROJECT_NAME})

You get PROJECT_NAME = hello-world, instead of PROJECT_NAME = foo.

I'm not sure what's going on, but it can be a problem with third-party code. (E.g., code I'm importing has write_basic_package_version_file() (from CMakePackageConfigHelpers) failing since PROJECT_VERSION isn't defined.)

Expected Behavior

See above.

Actual Behavior

See above.

Steps to repropduce

See above.

@viettrungluu viettrungluu changed the title New CMake project() issue (with PROJECT_NAME et al.) CMake: project() problem (with PROJECT_NAME et al.) in subprojects Jun 11, 2019
@github-actions github-actions bot changed the title CMake: project() problem (with PROJECT_NAME et al.) in subprojects CMake: project() problem (with PROJECT_NAME et al.) in subprojects (IDFGH-1321) Jun 11, 2019
@renzbagaporo
Copy link
Contributor

Thank you for bringing this to our attention. A fix for this is in the works.

@igrr igrr closed this as completed in 7edef74 Jun 30, 2019
igrr pushed a commit that referenced this issue Jul 18, 2019
ESP-IDF overrides project() definition for user convenience. This
redefinition lacks setting the variables documented at
the project command documentation
https://cmake.org/cmake/help/v3.5/command/project.html in the parent
scope.

This commit sets those variables.

Closes #3611.
trombik pushed a commit to trombik/esp-idf that referenced this issue Aug 9, 2019
ESP-IDF overrides project() definition for user convenience. This
redefinition lacks setting the variables documented at
the project command documentation
https://cmake.org/cmake/help/v3.5/command/project.html in the parent
scope.

This commit sets those variables.

Closes espressif#3611.
0xFEEDC0DE64 pushed a commit to 0xFEEDC0DE64/esp-idf that referenced this issue May 5, 2021
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

No branches or pull requests

2 participants