Skip to content

build: define CMAKE_EXPORT_COMPILE_COMMANDS as an environment variable not a define #10004

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heitbaum
Copy link
Contributor

When building utfcpp (and other packages) a CMake warning is issued.

CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_COMPILE_COMMANDS

Before this change the following files are present:

$ cd build.LibreELEC-Generic.x86_64-13.0-devel/build

$ find utfcpp-4.0.6 -name build.ninja
utfcpp-4.0.6/.x86_64-libreelec-linux-gnu/build.ninja
$ find utfcpp-4.0.6 -name compile_commands.json

$ find soxr-0.1.3 -name build.ninja
soxr-0.1.3/.x86_64-libreelec-linux-gnu/build.ninja
$ find soxr-0.1.3 -name compile_commands.json
soxr-0.1.3/.x86_64-libreelec-linux-gnu/compile_commands.json

When removing the define CMAKE_EXPORT_COMPILE_COMMANDS:

--- a/scripts/build
+++ b/scripts/build
@@ -147,8 +147,7 @@
   MESON_BUILD_TYPE="plain"
 fi

-CMAKE_GENERATOR_NINJA="-GNinja \
-                       -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
+CMAKE_GENERATOR_NINJA="-GNinja"

 # configure TARGET build defaults
 TARGET_CONFIGURE_OPTS="--host=${TARGET_NAME} \

The resulting build do not have the warning with utfcpp but the files compile_commands.json are not created (as expected.)

$ find utfcpp-4.0.6 -name build.ninja
utfcpp-4.0.6/.x86_64-libreelec-linux-gnu/build.ninja
$ find utfcpp-4.0.6 -name compile_commands.json

$ find soxr-0.1.3 -name build.ninja
soxr-0.1.3/.x86_64-libreelec-linux-gnu/build.ninja
$ find soxr-0.1.3 -name compile_commands.json

With the change to declare CMAKE_EXPORT_COMPILE_COMMANDS as an environment variable the warning is not preset with utfcpp and the compile_commands.json are created, matching the current functionaility but without the warning.

$ find utfcpp-4.0.6 -name build.ninja
utfcpp-4.0.6/.x86_64-libreelec-linux-gnu/build.ninja
$ find utfcpp-4.0.6 -name compile_commands.json

$ find soxr-0.1.3 -name build.ninja
soxr-0.1.3/.x86_64-libreelec-linux-gnu/build.ninja
$ find soxr-0.1.3 -name compile_commands.json
soxr-0.1.3/.x86_64-libreelec-linux-gnu/compile_commands.json

Ref:

…e not a define.

When building utfcpp (and other packages) a CMake warning is issued.

    CMake Warning:
      Manually-specified variables were not used by the project:

        CMAKE_EXPORT_COMPILE_COMMANDS

Before this change the following files are present:

    $ cd build.LibreELEC-Generic.x86_64-13.0-devel/build

    $ find utfcpp-4.0.6 -name build.ninja
    utfcpp-4.0.6/.x86_64-libreelec-linux-gnu/build.ninja
    $ find utfcpp-4.0.6 -name compile_commands.json

    $ find soxr-0.1.3 -name build.ninja
    soxr-0.1.3/.x86_64-libreelec-linux-gnu/build.ninja
    $ find soxr-0.1.3 -name compile_commands.json
    soxr-0.1.3/.x86_64-libreelec-linux-gnu/compile_commands.json

When removing the define CMAKE_EXPORT_COMPILE_COMMANDS:

--- a/scripts/build
+++ b/scripts/build
@@ -147,8 +147,7 @@
   MESON_BUILD_TYPE="plain"
 fi

-CMAKE_GENERATOR_NINJA="-GNinja \
-                       -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
+CMAKE_GENERATOR_NINJA="-GNinja"

 # configure TARGET build defaults
 TARGET_CONFIGURE_OPTS="--host=${TARGET_NAME} \

The resulting build do not have the warning with utfcpp but the files
compile_commands.json are not created (as expected.)

    $ find utfcpp-4.0.6 -name build.ninja
    utfcpp-4.0.6/.x86_64-libreelec-linux-gnu/build.ninja
    $ find utfcpp-4.0.6 -name compile_commands.json

    $ find soxr-0.1.3 -name build.ninja
    soxr-0.1.3/.x86_64-libreelec-linux-gnu/build.ninja
    $ find soxr-0.1.3 -name compile_commands.json

With the change to declare CMAKE_EXPORT_COMPILE_COMMANDS as an environment
variable the warning is not preset with utfcpp and the compile_commands.json
are created, matching the current functionaility but without the warning.

Ref:
- https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
  - This is initialized by the CMAKE_EXPORT_COMPILE_COMMANDS environment variable.
- https://cmake.org/cmake/help/latest/envvar/CMAKE_EXPORT_COMPILE_COMMANDS.html#envvar:CMAKE_EXPORT_COMPILE_COMMANDS
- https://stackoverflow.com/questions/20059670/how-to-use-cmake-export-compile-commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant