-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #666 from palerikm/cmake_with_warnings
Cleaning up cmake and enabled more warnings.
- Loading branch information
Showing
7 changed files
with
285 additions
and
28 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
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,10 @@ | ||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | ||
message( | ||
FATAL_ERROR | ||
"In-source builds not allowed. Please make a build directory.") | ||
endif() | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
message(STATUS "No build type selected, default to Debug") | ||
set(CMAKE_BUILD_TYPE "Debug") | ||
endif() |
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,19 @@ | ||
function(target_enable_lto) | ||
set(oneValueArgs TARGET ENABLE) | ||
cmake_parse_arguments( | ||
LTO | ||
"${options}" | ||
"${oneValueArgs}" | ||
"${multiValueArgs}" | ||
${ARGN}) | ||
|
||
include(CheckIPOSupported) | ||
check_ipo_supported(RESULT result OUTPUT output) | ||
if(result) | ||
message(STATUS "IPO/LTO is supported: ${LTO_TARGET}") | ||
set_property(TARGET ${LTO_TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION | ||
${LTO_ENABLE}) | ||
else() | ||
message(WARNING "IPO/LTO is not supported: ${LTO_TARGET}") | ||
endif() | ||
endfunction() |
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,52 @@ | ||
function(add_sanitizer_flags) | ||
if(NOT ENABLE_SANITIZE_ADDR AND NOT ENABLE_SANITIZE_UNDEF) | ||
return() | ||
endif() | ||
|
||
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU") | ||
add_compile_options("-fno-omit-frame-pointer") | ||
add_link_options("-fno-omit-frame-pointer") | ||
|
||
if(ENABLE_SANITIZE_ADDR) | ||
add_compile_options("-fsanitize=address") | ||
add_link_options("-fsanitize=address") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_UNDEF) | ||
add_compile_options("-fsanitize=undefined") | ||
add_link_options("-fsanitize=undefined") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_LEAK) | ||
add_compile_options("-fsanitize=leak") | ||
add_link_options("-fsanitize=leak") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_THREAD) | ||
if(ENABLE_SANITIZE_ADDR OR ENABLE_SANITIZE_LEAK) | ||
message(WARNING "thread does not work with: address and leak") | ||
endif() | ||
add_compile_options("-fsanitize=thread") | ||
add_link_options("-fsanitize=thread") | ||
endif() | ||
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
if(ENABLE_SANITIZE_ADDR) | ||
add_compile_options("/fsanitize=address") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_UNDEF) | ||
message(STATUS "sanitize=undefined not avail. for MSVC") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_LEAK) | ||
message(STATUS "sanitize=leak not avail. for MSVC") | ||
endif() | ||
|
||
if(ENABLE_SANITIZE_THREAD) | ||
message(STATUS "sanitize=thread not avail. for MSVC") | ||
endif() | ||
else() | ||
message(WARNING "This sanitizer not supported in this environment (${CMAKE_C_COMPILER_ID})") | ||
return() | ||
endif() | ||
endfunction(add_sanitizer_flags) |
Oops, something went wrong.