-
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build_system: move compiler flags definitions in their own cmake file
- Loading branch information
1 parent
704de34
commit fa87bac
Showing
2 changed files
with
44 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
if(MSVC) | ||
add_definitions(-DWINDOWS) | ||
set(warnings "-WX -W2") | ||
|
||
# We need this so Windows links to e.g. dronecore_telemetry.dll. | ||
# Without this option it will look for dronecore_telemetry.lib and fail. | ||
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Export all symbols on Windows" ON) | ||
else() | ||
# We are not using exceptions to make it easier to write wrappers. | ||
add_definitions(-fno-exceptions) | ||
|
||
set(warnings "-Wall -Wextra -Werror -Wshadow -Wno-strict-aliasing -Wold-style-cast -Wdouble-promotion -Wformat=2") | ||
|
||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6) | ||
set(warnings "${warnings} -Wduplicated-cond -Wnull-dereference") | ||
endif() | ||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7) | ||
set(warnings "${warnings} -Wduplicated-branches") | ||
endif() | ||
|
||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5) | ||
set(warnings "${warnings} -Wno-missing-field-initializers") | ||
endif() | ||
|
||
set(warnings "${warnings} -Wuseless-cast -Wlogical-op") | ||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
set(warnings "${warnings} -Wno-missing-braces") | ||
endif() | ||
endif() | ||
|
||
# We need a define if on APPLE | ||
if(APPLE) | ||
add_definitions("-DAPPLE") | ||
endif() | ||
|
||
# Add DEBUG define for Debug target | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") | ||
|
||
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} --coverage") | ||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_COVERAGE} --coverage") | ||
set(CMAKE_LINKER_FLAGS_COVERAGE "${CMAKE_LINKER_FLAGS_COVERAGE} --coverage") |