Skip to content

Use target_compile_features instead of set(CMAKE_CXX_STANDARD 14)#56

Open
chhtz wants to merge 1 commit into
masterfrom
fix/cxx_standard
Open

Use target_compile_features instead of set(CMAKE_CXX_STANDARD 14)#56
chhtz wants to merge 1 commit into
masterfrom
fix/cxx_standard

Conversation

@chhtz
Copy link
Copy Markdown
Member

@chhtz chhtz commented Mar 11, 2026

The latter spills into the maps.pc file, which potentially breaks building dependencies which require a higher standard Also increase cmake_minimum_required to silence a warning

The latter spills into the maps.pc file, which potentially breaks building dependencies which require a higher standard
Also increase cmake_minimum_required to silence a warning
@pierrewillenbrockdfki
Copy link
Copy Markdown
Contributor

The cflags in the .pc file should reflect the requirements of the headers. i see that you are declaring the feature PUBLIC, so i assume the headers require c++14 and that should then be added to the .pc.in file.

The users of .pc files must be smart enough to select the highest required standard; just plopping the concatenation of the cflags onto the compilers commandline just does not work.

@chhtz
Copy link
Copy Markdown
Member Author

chhtz commented Mar 11, 2026

I don't think passing this via pkg-config is in any way practicable. The requirements partially come from pcl for which the pkg-config also does not explicitly add the flags anymore (probably because the default for most compilers is at least c++14, anyways):

$ pkg-config pcl_common --cflags
-I/usr/include/pcl-1.14 -I/usr/include/eigen3 

@pierrewillenbrockdfki
Copy link
Copy Markdown
Contributor

That is pcls choice, and the packages using them pay the price of needing to keep their -std= flags updated to pcls needs. I'd guess the cmake config(if any) automatically sets the target_feature.

I'd like to point to icu, fcl, sdformat and ignition-math4 that all specify some -std= flag on ubuntu 20.04. Gentoo has similar for icu, libobs/obs-frontend-api, xmlb, manifold, libqpdf.

Finally, both Rock.cmake macros and orogen do have infrastructure to deal with -std= flags in .pc files.

@planthaber
Copy link
Copy Markdown
Member

Some (older) verions of PCL check explicitly for this flag in their cmake targets forcing you to have it set.

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.

3 participants