Skip to content

Conversation

@bkueng
Copy link
Contributor

@bkueng bkueng commented Mar 30, 2022

I got this error in a CI build:

CMake Error at cmake/common/check_configuration.cmake:120 (target_compile_options):
  Error evaluating generator expression:

    $<COMPILE_LANGUAGE:CXX>

  $<COMPILE_LANGUAGE:...> Unknown language.

The same build works locally though.

Other projects are affected by this as well.

@bkueng bkueng force-pushed the fix_enable_language branch from 27524b7 to 4311393 Compare March 30, 2022 11:12
@richiprosima
Copy link
Contributor

Build status:

  • Linux Build Status
  • Windows Build Status

@pablogs9
Copy link
Contributor

Which toolchain are you using?

@bkueng
Copy link
Contributor Author

bkueng commented Mar 30, 2022

GCC on linux

@pablogs9
Copy link
Contributor

Can you provide instructions for replicating the issue?

@gavanderhoorn
Copy link
Contributor

gavanderhoorn commented Mar 30, 2022

This was changed in #67 to fix #57.

Micro-CDR is not a C++ project -- the tests use it though, but there the sub-CMakeLists.txt configures it.

@bkueng
Copy link
Contributor Author

bkueng commented Mar 31, 2022

I only saw it in a CI build, and the same build works locally. I'm not sure where the difference comes from. The change fixes the CI build though, and given the instructions further down $<$<COMPILE_LANGUAGE:CXX>, it's clearly incorrect if C++ isn't enabled.

The alternative (and IMO better) way is to remove $<COMPILE_LANGUAGE:CXX>. It shouldn't be required, as it's C code.

@gavanderhoorn
Copy link
Contributor

given the instructions further down $<$<COMPILE_LANGUAGE:CXX>, it's clearly incorrect if C++ isn't enabled.

$<COMPILE_LANGUAGE:CXX> is a generator expression, specifically a conditional which checks whether CXX has been enabled previously (see the docs).

What makes you suggest it's incorrect?

@bkueng
Copy link
Contributor Author

bkueng commented Mar 31, 2022

It checks for the language used for a given compilation unit, not whether a language is enabled.
It does not mention the case where a language is specified by the expression, but not enabled by the project (possibly because it seems like a logical expectation), so the behavior might depend on the cmake version.

@bkueng
Copy link
Contributor Author

bkueng commented Mar 31, 2022

I can reproduce with cmake version 3.10.2, with this case:

project(test LANGUAGES C)

add_executable(test test.c)
target_compile_options(test PRIVATE -Wall
	-Wextra
	-Wshadow
	$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>
	)
CMake Error at CMakeLists.txt:4 (target_compile_options):
  Error evaluating generator expression:

    $<COMPILE_LANGUAGE:CXX>

  $<COMPILE_LANGUAGE:...> Unknown language.

cmake version 3.22.2 does not produce an error.

@bkueng bkueng force-pushed the fix_enable_language branch from 4311393 to 79082ce Compare April 4, 2022 06:53
@richiprosima
Copy link
Contributor

Build status:

  • Linux Build Status
  • Windows Build Status

@bkueng
Copy link
Contributor Author

bkueng commented Apr 4, 2022

@pablogs9 do you have any reason not to remove COMPILE_LANGUAGE:CXX?

@pablogs9 pablogs9 requested review from Acuadros95 and pablogs9 April 4, 2022 07:24
pablogs9
pablogs9 previously approved these changes Apr 4, 2022
Copy link
Contributor

@pablogs9 pablogs9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM since C++ related warnings does not apply to the C codebase of this project. Please @Acuadros95 take a look also.

@pablogs9 pablogs9 changed the base branch from master to develop April 4, 2022 12:04
@pablogs9 pablogs9 dismissed their stale review April 4, 2022 12:04

The base branch was changed.

…n_compile_options

cmake version 3.10.2 fails with this error:
CMake Error at cmake/common/check_configuration.cmake:120 (target_compile_options):
  Error evaluating generator expression:

    $<COMPILE_LANGUAGE:CXX>

  $<COMPILE_LANGUAGE:...> Unknown language.

version 3.22.2 does not produce this error.

Signed-off-by: Beat Küng <[email protected]>
@pablogs9 pablogs9 force-pushed the fix_enable_language branch from 79082ce to 5960775 Compare April 4, 2022 12:06
@richiprosima
Copy link
Contributor

Build status:

  • Linux Build Status
  • Windows Build Status

@Acuadros95
Copy link
Contributor

LGTM

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.

5 participants