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

Improve handling of compilation flags with CMake #572

Merged
merged 13 commits into from
Dec 12, 2018

Conversation

denizevrenci
Copy link
Contributor

@denizevrenci denizevrenci commented Oct 26, 2018

Use CMake's idiomatic means of passing compilation flags to compilers.

@mjpt777
Copy link
Contributor

mjpt777 commented Oct 28, 2018

Seems reasonable to me. @tmontgomery do you have a view?

@tmontgomery
Copy link
Contributor

I'll review this shortly.

@denizevrenci denizevrenci force-pushed the more_cmake branch 2 times, most recently from 327beed to 48607cd Compare November 1, 2018 10:02
@denizevrenci denizevrenci force-pushed the more_cmake branch 3 times, most recently from 0c9ea16 to 677e511 Compare November 21, 2018 04:40
@denizevrenci denizevrenci force-pushed the more_cmake branch 2 times, most recently from 8a48bcd to e27f882 Compare December 2, 2018 17:27
@denizevrenci denizevrenci force-pushed the more_cmake branch 2 times, most recently from d0f730b to f6aea5c Compare December 6, 2018 06:17
While CMAKE_SOURCE_DIR can point to another project root if Aeron is
included as a subdirectory, PROJECT_SOURCE_DIR always points to
Aeron's project root which will result in the same paths being generated
regardless of a standalone build or subproject build.
This version is the minimum required for the variable
CMAKE_CXX_STANDARD.
This adds the flag -std=c11 to GCC and Clang. Visual Studio does not
seem to have full conformance to C11 standard yet.
This is equal to setting -std=c11 and -std=c++11 as opposed to
-std=gnu11 and -std=gnu++11.
CMake automatically appends these when it detects CMAKE_C_STANDARD and
CMAKE_CXX_STANDARD has been set.
This flag is automatically appended by CMake in debug builds which
include RelWithDebInfo. Release mode should not have debug symbols.
This flag is added automatically by CMake in Debug mode.
add_compile_options works on both C and C++ sources and has a cleaner
usage less prone to wiping off old flags.
add_definitions is semantically used to pass macro definitions to source
files.
CMake automatically adds -O3 for release builds. Ofast adds potentially
breaking non-standard optimizations during compilation. This change
keeps -Ofast enabled for stand alone builds but disables it when Aeron
is added with add_subdirectory command.
If a compiler set different from CC and CXX is used to build Aeron
and tests and benchmarks are enabled by using CMAKE_C_COMPILER and
CMAKE_CXX_COMPILER, Aeron source and the tests are built using
different compilers.
x86 or x86_64 compilation is already based on the architecture of the
machine running the build. These flags are necessary if the target
architecture is different from the one that compiles the code.
fexceptions is enabled for C++ by default.
@mjpt777 mjpt777 merged commit 94da939 into real-logic:master Dec 12, 2018
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