Skip to content

build(cmake): minor tweaks #1274

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

Merged
merged 1 commit into from
May 17, 2022
Merged

build(cmake): minor tweaks #1274

merged 1 commit into from
May 17, 2022

Conversation

Tachi107
Copy link
Contributor

@Tachi107 Tachi107 commented May 16, 2022

CC: @sum01

- Enable THREADS_PREFER_PTHREAD_FLAG to use -pthread where supported
- Remove low-level compile features (closes yhirose#1272)
- Remove unneeded DESTINATION options where possible
@sum01
Copy link
Contributor

sum01 commented May 16, 2022

Looks good.

I don't understand the point in changing DESTINATION, but it's not important I guess. I just say this because TYPE INCLUDE seems to evaluate to read from CMAKE_INSTALL_INCLUDEDIR anyways (if I'm reading the docs right).

As for the prefer pthread flag, is there a reason for that? I'm just curious.
I know a long time ago I couldn't get things to compile without it (on Linux) but it seems to have since been a non-issue.

@Tachi107
Copy link
Contributor Author

I don't understand the point in changing DESTINATION, but it's not important I guess. I just say this because TYPE INCLUDE seems to evaluate to read from CMAKE_INSTALL_INCLUDEDIR anyways

Yes, you're right, but it makes the code a bit cleaner (quite subjective but whatever, I can revert it if you prefer)

As for the prefer pthread flag, is there a reason for that? I'm just curious.

Yes. The first is that the docs "highly recommend" its usage where possible (i.e. In all projects targeting CMake >= 3.1), the second is that it's also the recommended way of enabling pthreads on compiler that support the flag, like GCC (according to their docs). Simply linking to -lpthread isn't always enough as the pthreads headers could require some macro like REENTRANT (or similar) to be defined, and a linker flag of course doesn't define that. So -pthread takes care of defining the necessary macros and linking to the necessary libraries.

@sum01
Copy link
Contributor

sum01 commented May 16, 2022

Thanks for the response. You don't need to change the TYPE INCLUDE, it's fine.

@yhirose
Copy link
Owner

yhirose commented May 17, 2022

@Tachi107, is everything ready for merge?

@Tachi107
Copy link
Contributor Author

Yes

@yhirose yhirose merged commit a449d82 into yhirose:master May 17, 2022
@yhirose
Copy link
Owner

yhirose commented May 17, 2022

Thanks for your help!

@Tachi107 Tachi107 deleted the cmake-tweaks branch May 17, 2022 11:17
ExclusiveOrange pushed a commit to ExclusiveOrange/cpp-httplib-exor that referenced this pull request May 2, 2023
- Enable THREADS_PREFER_PTHREAD_FLAG to use -pthread where supported
- Remove low-level compile features (closes yhirose#1272)
- Remove unneeded DESTINATION options where possible
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